startup.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * 2012-12-05 Bernard the first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include <board.h>
  13. extern int rt_application_init(void);
  14. extern void rt_hw_board_init(void);
  15. /**
  16. * This function will startup RT-Thread RTOS.
  17. */
  18. void rtthread_startup(void)
  19. {
  20. /* initialzie hardware interrupt */
  21. rt_hw_interrupt_init();
  22. /* initialize board */
  23. rt_hw_board_init();
  24. /* show RT-Thread version */
  25. rt_show_version();
  26. /* initialize memory system */
  27. #ifdef RT_USING_HEAP
  28. rt_system_heap_init(HEAP_BEGIN, HEAP_END);
  29. #endif
  30. /* initialize scheduler system */
  31. rt_system_scheduler_init();
  32. /* initialize timer and soft timer thread */
  33. rt_system_timer_init();
  34. rt_system_timer_thread_init();
  35. /* initialize application */
  36. rt_application_init();
  37. /* initialize idle thread */
  38. rt_thread_idle_init();
  39. /* start scheduler */
  40. rt_system_scheduler_start();
  41. /* never reach here */
  42. return ;
  43. }
  44. int main(void)
  45. {
  46. /* disable interrupt first */
  47. rt_hw_interrupt_disable();
  48. /* invoke rtthread_startup */
  49. rtthread_startup();
  50. return 0;
  51. }