application.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2014, 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. * 2016-12-05 Pluto first implementation
  13. */
  14. /**
  15. * @addtogroup NUVOTON_M451
  16. */
  17. /*@{*/
  18. #include <stdio.h>
  19. #include <board.h>
  20. #include <rtthread.h>
  21. #ifdef RT_USING_COMPONENTS_INIT
  22. #include <components.h>
  23. #endif /* RT_USING_COMPONENTS_INIT */
  24. #include "led.h"
  25. /* led thread entry */
  26. static void led_thread_entry(void* parameter)
  27. {
  28. rt_hw_led_init();
  29. while(1)
  30. {
  31. rt_hw_led_on();
  32. rt_thread_delay(RT_TICK_PER_SECOND);
  33. rt_hw_led_off();
  34. rt_thread_delay(RT_TICK_PER_SECOND);
  35. }
  36. }
  37. static void rt_init_thread_entry(void* parameter)
  38. {
  39. rt_thread_t led_thread;
  40. /* Initialization RT-Thread Components */
  41. #ifdef RT_USING_COMPONENTS_INIT
  42. rt_components_init();
  43. #endif
  44. /* Create led thread */
  45. led_thread = rt_thread_create("led",
  46. led_thread_entry, RT_NULL,
  47. 256, 20, 20);
  48. if(led_thread != RT_NULL)
  49. rt_thread_startup(led_thread);
  50. }
  51. int rt_application_init()
  52. {
  53. rt_thread_t init_thread;
  54. #if (RT_THREAD_PRIORITY_MAX == 32)
  55. init_thread = rt_thread_create("init",
  56. rt_init_thread_entry, RT_NULL,
  57. 512, 8, 20);
  58. #else
  59. init_thread = rt_thread_create("init",
  60. rt_init_thread_entry, RT_NULL,
  61. 512, 80, 20);
  62. #endif
  63. if(init_thread != RT_NULL)
  64. rt_thread_startup(init_thread);
  65. return 0;
  66. }
  67. /*@}*/