startup.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-02-24 Bernard first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. /**
  14. * @addtogroup FM3
  15. */
  16. /*@{*/
  17. extern int rt_application_init(void);
  18. #ifdef __CC_ARM
  19. extern int Image$$RW_IRAM1$$ZI$$Limit;
  20. #elif __ICCARM__
  21. #pragma section="HEAP"
  22. #else
  23. extern int __bss_end;
  24. #endif
  25. /**
  26. * This function will startup RT-Thread RTOS.
  27. */
  28. void rtthread_startup(void)
  29. {
  30. /* init board */
  31. rt_hw_board_init();
  32. /* show version */
  33. rt_show_version();
  34. /* init timer system */
  35. rt_system_timer_init();
  36. #ifdef RT_USING_HEAP
  37. #ifdef __CC_ARM
  38. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  39. #elif __ICCARM__
  40. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  41. #else
  42. /* init memory system */
  43. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  44. #endif
  45. #endif
  46. /* init scheduler system */
  47. rt_system_scheduler_init();
  48. /* init timer thread */
  49. rt_system_timer_thread_init();
  50. /* init application */
  51. rt_application_init();
  52. /* init idle thread */
  53. rt_thread_idle_init();
  54. /* start scheduler */
  55. rt_system_scheduler_start();
  56. /* never reach here */
  57. return ;
  58. }
  59. int main(void)
  60. {
  61. /* disable interrupt first */
  62. rt_hw_interrupt_disable();
  63. /* startup RT-Thread RTOS */
  64. rtthread_startup();
  65. return 0;
  66. }
  67. /*@}*/