startup.c 1.6 KB

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