demo_thread.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. */
  9. #include <rtthread.h>
  10. #include "drv_led.h"
  11. #include "drv_uart.h"
  12. static void thread1_entry(void* parameter)
  13. {
  14. while(1)
  15. {
  16. Led_Control(0,1);
  17. rt_thread_delay(RT_TICK_PER_SECOND);
  18. Led_Control(0,0);
  19. rt_thread_delay(RT_TICK_PER_SECOND);
  20. }
  21. }
  22. static void thread2_entry(void* parameter)
  23. {
  24. while(1)
  25. {
  26. Led_Control(1,1);
  27. rt_thread_delay(RT_TICK_PER_SECOND);
  28. Led_Control(1,0);
  29. rt_thread_delay(RT_TICK_PER_SECOND);
  30. }
  31. }
  32. int demo_init(void)
  33. {
  34. rt_thread_t thread1 = RT_NULL;
  35. rt_thread_t thread2 = RT_NULL;
  36. rt_led_hw_init();
  37. thread1 = rt_thread_create("t1",thread1_entry, RT_NULL,512,10,5);
  38. if (thread1 != RT_NULL)
  39. rt_thread_startup(thread1);
  40. thread2 = rt_thread_create("t2",thread2_entry, RT_NULL,512,10,5);
  41. if (thread2 != RT_NULL)
  42. rt_thread_startup(thread2);
  43. return 0;
  44. }