application.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard the first version
  9. * 2013-11-15 bright add init thread and components initial
  10. */
  11. /**
  12. * @addtogroup STM32
  13. */
  14. /*@{*/
  15. #include <stdio.h>
  16. #include <rthw.h>
  17. #include <rtdevice.h>
  18. #include "board.h"
  19. #include <rtthread.h>
  20. static void rt_init_thread_entry(void* parameter)
  21. {
  22. extern void led_thread_entry(void* parameter);
  23. rt_thread_t thread;
  24. /* Initialization RT-Thread Components */
  25. #ifdef RT_USING_COMPONENTS_INIT
  26. rt_components_init();
  27. #endif
  28. /* Set finsh device */
  29. #ifdef RT_USING_FINSH
  30. finsh_set_device(RT_CONSOLE_DEVICE_NAME);
  31. #endif /* RT_USING_FINSH */
  32. /* Create led thread */
  33. thread = rt_thread_create("led",
  34. led_thread_entry, RT_NULL,
  35. 256, 20, 20);
  36. if(thread != RT_NULL)
  37. rt_thread_startup(thread);
  38. }
  39. int rt_application_init()
  40. {
  41. rt_thread_t init_thread;
  42. #if (RT_THREAD_PRIORITY_MAX == 32)
  43. init_thread = rt_thread_create("init",
  44. rt_init_thread_entry, RT_NULL,
  45. 512, 8, 20);
  46. #else
  47. init_thread = rt_thread_create("init",
  48. rt_init_thread_entry, RT_NULL,
  49. 512, 80, 20);
  50. #endif
  51. if(init_thread != RT_NULL)
  52. rt_thread_startup(init_thread);
  53. return 0;
  54. }
  55. /*@}*/