applications.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <rtthread.h>
  2. static void rt_init_thread_entry(void* parameter)
  3. {
  4. #ifdef RT_USING_COMPONENTS_INIT
  5. /* initialization RT-Thread Components */
  6. rt_components_init();
  7. #endif
  8. rt_thread_delay( RT_TIMER_TICK_PER_SECOND*2 ); /* sleep 0.5 second and switch to other thread */
  9. }
  10. #include <encoding.h>
  11. #include <platform.h>
  12. static void led_thread_entry(void* parameter)
  13. {
  14. unsigned int count=0;
  15. rt_hw_led_init();
  16. while (0)
  17. {
  18. /* led1 on */
  19. #ifndef RT_USING_FINSH
  20. /* rt_kprintf("led on, count : %d\r\n",count);*/
  21. #endif
  22. rt_kprintf("core freq at %d Hz\n", get_cpu_freq());
  23. count++;
  24. rt_thread_delay( RT_TIMER_TICK_PER_SECOND/2 ); /* sleep 0.5 second and switch to other thread */
  25. /* rt_hw_led_on(0);*/
  26. /* led1 off */
  27. #ifndef RT_USING_FINSH
  28. /* rt_kprintf("led off\r\n");*/
  29. #endif
  30. rt_hw_led_off(0);
  31. /* rt_thread_delay( RT_TIMER_TICK_PER_SECOND*2);*/
  32. }
  33. }
  34. static rt_uint8_t led_stack[ 1024];
  35. static struct rt_thread led_thread;
  36. void rt_application_init()
  37. {
  38. rt_thread_t init_thread;
  39. rt_err_t result;
  40. /* init led thread */
  41. result = rt_thread_init(&led_thread,
  42. "led",
  43. led_thread_entry,
  44. RT_NULL,
  45. (rt_uint8_t*)&led_stack[0],
  46. sizeof(led_stack),
  47. 20,
  48. 5);
  49. if (result == RT_EOK)
  50. {
  51. rt_thread_startup(&led_thread);
  52. }
  53. init_thread = rt_thread_create("init",
  54. rt_init_thread_entry,
  55. RT_NULL,
  56. 512,
  57. 8,
  58. 20);
  59. if (init_thread != RT_NULL)
  60. rt_thread_startup(init_thread);
  61. return;
  62. }