startup.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2015, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2017-09-11 Haley the first version
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. /**
  18. * @addtogroup Apollo2
  19. */
  20. /*@{*/
  21. extern int rt_application_init(void);
  22. #ifdef __CC_ARM
  23. extern int Image$$RW_IRAM1$$ZI$$Limit;
  24. #define AM_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
  25. #elif __ICCARM__
  26. #pragma section="HEAP"
  27. #define AM_SRAM_BEGIN (__segment_end("HEAP"))
  28. #else
  29. extern int __bss_end;
  30. #define NRF_SRAM_BEGIN (&__bss_end)
  31. #endif
  32. /**
  33. * This function will startup RT-Thread RTOS.
  34. */
  35. void rtthread_startup(void)
  36. {
  37. /* init board */
  38. rt_hw_board_init();
  39. /* show version */
  40. rt_show_version();
  41. /* init tick */
  42. rt_system_tick_init();
  43. /* init kernel object */
  44. rt_system_object_init();
  45. /* init timer system */
  46. rt_system_timer_init();
  47. #ifdef RT_USING_HEAP
  48. rt_system_heap_init((void*)AM_SRAM_BEGIN, (void*)AM_SRAM_END);
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. /* init application */
  53. rt_application_init();
  54. /* init timer thread */
  55. rt_system_timer_thread_init();
  56. /* init idle thread */
  57. rt_thread_idle_init();
  58. /* start scheduler */
  59. rt_system_scheduler_start();
  60. /* never reach here */
  61. return ;
  62. }
  63. int main(void)
  64. {
  65. /* disable interrupt first */
  66. // rt_hw_interrupt_disable();
  67. /* startup RT-Thread RTOS */
  68. rtthread_startup();
  69. return 0;
  70. }
  71. /*@}*/