startup.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * 2011-04-16 nsj first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #ifdef RT_USING_FINSH
  13. #include <finsh.h>
  14. extern int finsh_system_init(void);
  15. #endif
  16. extern int rt_application_init(void);
  17. #ifdef RT_USING_DEVICE
  18. extern rt_err_t rt_hw_serial_init(void);
  19. #endif
  20. extern int __heap_start;
  21. extern int __heap_end;
  22. /**
  23. * This function will startup RT-Thread RTOS.
  24. */
  25. void rtthread_startup(void)
  26. {
  27. /* init hardware interrupt */
  28. rt_hw_interrupt_init();
  29. /* init board */
  30. rt_hw_board_init();
  31. rt_show_version();
  32. /* init timer system */
  33. rt_system_timer_init();
  34. /* init memory system */
  35. #ifdef RT_USING_HEAP
  36. rt_system_heap_init((void*)&__heap_start, (void*)&__heap_end);
  37. #endif
  38. /* init scheduler system */
  39. rt_system_scheduler_init();
  40. /* init application */
  41. rt_application_init();
  42. #ifdef RT_USING_FINSH
  43. /* init finsh */
  44. finsh_system_init();
  45. #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
  46. finsh_set_device("uart1");
  47. #endif
  48. #endif
  49. /* init soft timer thread */
  50. rt_system_timer_thread_init();
  51. /* init idle thread */
  52. rt_thread_idle_init();
  53. /* start scheduler */
  54. rt_system_scheduler_start();
  55. /* never reach here */
  56. return ;
  57. }