startup.c 1.8 KB

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