main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-11-16 Dystopia the first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. void rt_init_thread_entry(void *parameter)
  14. {
  15. rt_kprintf("hello rt-thread\n");
  16. }
  17. int rt_application_init(void)
  18. {
  19. rt_thread_t tid;
  20. tid = rt_thread_create("init", rt_init_thread_entry, RT_NULL, 4096, 3, 200);
  21. if (tid != RT_NULL)
  22. {
  23. rt_thread_startup(tid);
  24. } else {
  25. return -1;
  26. }
  27. return 0;
  28. }
  29. /**
  30. * This function will startup RT-Thread RTOS.
  31. */
  32. void rtthread_startup(void)
  33. {
  34. /* disable interrupt first */
  35. rt_hw_interrupt_disable();
  36. /* init board */
  37. rt_hw_board_init();
  38. /* show version */
  39. rt_show_version();
  40. /* init timer system */
  41. rt_system_timer_init();
  42. /* init scheduler system */
  43. rt_system_scheduler_init();
  44. /* init application */
  45. rt_application_init();
  46. /* init timer thread */
  47. rt_system_timer_thread_init();
  48. /* init idle thread */
  49. rt_thread_idle_init();
  50. /* start scheduler */
  51. rt_system_scheduler_start();
  52. /* never reach here */
  53. return ;
  54. }
  55. void main(void)
  56. {
  57. /* startup RT-Thread RTOS */
  58. rtthread_startup();
  59. for(;;){}
  60. }