startup.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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-09-03 prife first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. /**
  14. * @addtogroup win32
  15. */
  16. /*@{*/
  17. extern int rt_application_init(void);
  18. extern rt_uint8_t *heap;
  19. /**
  20. * This function will startup RT-Thread RTOS.
  21. */
  22. void rtthread_startup(void)
  23. {
  24. /* init board */
  25. rt_hw_board_init();
  26. /* show version */
  27. rt_show_version();
  28. /* init timer system */
  29. rt_system_timer_init();
  30. #ifdef RT_USING_HEAP
  31. /* init memory system */
  32. rt_system_heap_init((void *)heap, (void *)&heap[RT_HEAP_SIZE - 1]);
  33. #endif
  34. /* init scheduler system */
  35. rt_system_scheduler_init();
  36. /* init application */
  37. rt_application_init();
  38. /* init timer thread */
  39. rt_system_timer_thread_init();
  40. /* init idle thread */
  41. rt_thread_idle_init();
  42. /* start scheduler */
  43. rt_system_scheduler_start();
  44. /* never reach here */
  45. return ;
  46. }
  47. int main(void)
  48. {
  49. /* disable interrupt first */
  50. rt_hw_interrupt_disable();
  51. /* startup RT-Thread RTOS */
  52. rtthread_startup();
  53. return 0;
  54. }
  55. /*@}*/