startup.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2008-12-11 xuxinming first version
  9. * 2010-4-3 LiJin add init soft timer thread
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include <LPC24xx.h>
  14. /**
  15. * @addtogroup LPC2478
  16. */
  17. /*@{*/
  18. extern int rt_application_init(void);
  19. #ifdef __CC_ARM
  20. extern int Image$$RW_IRAM1$$ZI$$Limit;
  21. #else
  22. extern int __bss_end;
  23. #endif
  24. /**
  25. * This function will startup RT-Thread RTOS.
  26. */
  27. void rtthread_startup(void)
  28. {
  29. /* init hardware interrupt */
  30. rt_hw_interrupt_init();
  31. /* init board */
  32. rt_hw_board_init();
  33. /* init tick */
  34. rt_system_tick_init();
  35. /* init kernel object */
  36. rt_system_object_init();
  37. rt_show_version();
  38. /* init timer system */
  39. rt_system_timer_init();
  40. /* init memory system */
  41. #ifdef RT_USING_HEAP
  42. #ifdef __CC_ARM
  43. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)0x40010000);
  44. #else
  45. rt_system_heap_init((void *)&__bss_end, (void *)0x40010000);
  46. #endif
  47. #endif
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. /* init application */
  51. rt_application_init();
  52. /* init soft timer thread */
  53. rt_system_timer_thread_init();
  54. /* init idle thread */
  55. rt_thread_idle_init();
  56. /* start scheduler */
  57. rt_system_scheduler_start();
  58. /* never reach here */
  59. return ;
  60. }
  61. #ifdef __CC_ARM
  62. int main(void)
  63. {
  64. /* disable interrupt first */
  65. rt_hw_interrupt_disable();
  66. /* invoke rtthread_startup */
  67. rtthread_startup();
  68. return 0;
  69. }
  70. #endif
  71. /*@}*/