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. * 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. rt_show_version();
  34. /* init timer system */
  35. rt_system_timer_init();
  36. /* init memory system */
  37. #ifdef RT_USING_HEAP
  38. #ifdef __CC_ARM
  39. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)0x40010000);
  40. #else
  41. rt_system_heap_init((void *)&__bss_end, (void *)0x40010000);
  42. #endif
  43. #endif
  44. /* init scheduler system */
  45. rt_system_scheduler_init();
  46. /* init application */
  47. rt_application_init();
  48. /* init soft timer thread */
  49. rt_system_timer_thread_init();
  50. /* init idle thread */
  51. rt_thread_idle_init();
  52. /* start scheduler */
  53. rt_system_scheduler_start();
  54. /* never reach here */
  55. return ;
  56. }
  57. #ifdef __CC_ARM
  58. int main(void)
  59. {
  60. /* disable interrupt first */
  61. rt_hw_interrupt_disable();
  62. /* invoke rtthread_startup */
  63. rtthread_startup();
  64. return 0;
  65. }
  66. #endif
  67. /*@}*/