application.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #include "led.h"
  22. /* led thread entry */
  23. static void led_thread_entry(void* parameter)
  24. {
  25. rt_hw_led_init();
  26. while(1)
  27. {
  28. rt_hw_led_on();
  29. rt_thread_delay(RT_TICK_PER_SECOND);
  30. rt_hw_led_off();
  31. rt_thread_delay(RT_TICK_PER_SECOND);
  32. }
  33. }
  34. static void rt_init_thread_entry(void* parameter)
  35. {
  36. rt_thread_t led_thread;
  37. /* Initialization RT-Thread Components */
  38. #ifdef RT_USING_COMPONENTS_INIT
  39. rt_components_init();
  40. #endif
  41. /* Create led thread */
  42. led_thread = rt_thread_create("led",
  43. led_thread_entry, RT_NULL,
  44. 256, 20, 20);
  45. if(led_thread != RT_NULL)
  46. rt_thread_startup(led_thread);
  47. }
  48. int rt_application_init()
  49. {
  50. rt_thread_t init_thread;
  51. #if (RT_THREAD_PRIORITY_MAX == 32)
  52. init_thread = rt_thread_create("init",
  53. rt_init_thread_entry, RT_NULL,
  54. 512, 8, 20);
  55. #else
  56. init_thread = rt_thread_create("init",
  57. rt_init_thread_entry, RT_NULL,
  58. 512, 80, 20);
  59. #endif
  60. if(init_thread != RT_NULL)
  61. rt_thread_startup(init_thread);
  62. return 0;
  63. }
  64. /*@}*/