application.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard the first version
  13. * 2013-11-15 bright add init thread and components initial
  14. */
  15. /**
  16. * @addtogroup STM32
  17. */
  18. /*@{*/
  19. #include <stdio.h>
  20. #include <rthw.h>
  21. #include <rtdevice.h>
  22. #include "board.h"
  23. #include <rtthread.h>
  24. #ifdef RT_USING_COMPONENTS_INIT
  25. #include <components.h>
  26. #endif /* RT_USING_COMPONENTS_INIT */
  27. static void rt_init_thread_entry(void* parameter)
  28. {
  29. extern void led_thread_entry(void* parameter);
  30. rt_thread_t thread;
  31. /* Initialization RT-Thread Components */
  32. #ifdef RT_USING_COMPONENTS_INIT
  33. rt_components_init();
  34. #endif
  35. /* Set finsh device */
  36. #ifdef RT_USING_FINSH
  37. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  38. #endif /* RT_USING_FINSH */
  39. /* Create led thread */
  40. thread = rt_thread_create("led",
  41. led_thread_entry, RT_NULL,
  42. 256, 20, 20);
  43. if(thread != RT_NULL)
  44. rt_thread_startup(thread);
  45. }
  46. int rt_application_init()
  47. {
  48. rt_thread_t init_thread;
  49. #if (RT_THREAD_PRIORITY_MAX == 32)
  50. init_thread = rt_thread_create("init",
  51. rt_init_thread_entry, RT_NULL,
  52. 512, 8, 20);
  53. #else
  54. init_thread = rt_thread_create("init",
  55. rt_init_thread_entry, RT_NULL,
  56. 512, 80, 20);
  57. #endif
  58. if(init_thread != RT_NULL)
  59. rt_thread_startup(init_thread);
  60. return 0;
  61. }
  62. /*@}*/