startup.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * 2009-02-16 Bernard first implementation
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #ifdef RT_USING_FINSH
  13. #include <finsh.h>
  14. #endif
  15. #include "board.h"
  16. #ifdef RT_USING_LWIP
  17. #include <netif/ethernetif.h>
  18. #include "dm9000.h"
  19. #endif
  20. #ifdef RT_USING_DFS
  21. #include "sd.h"
  22. #endif
  23. /**
  24. * @addtogroup lpc2148
  25. */
  26. /*@{*/
  27. extern int rt_application_init(void);
  28. extern void rt_show_version(void);
  29. #ifdef RT_USING_DEVICE
  30. extern rt_err_t rt_hw_serial_init(void);
  31. #endif
  32. #ifdef __CC_ARM
  33. extern int Image$$RW_IRAM1$$ZI$$Limit;
  34. #else
  35. extern int __bss_end;
  36. #endif
  37. /**
  38. * This function will startup RT-Thread RTOS.
  39. */
  40. void rtthread_startup(void)
  41. {
  42. /* init hardware interrupt */
  43. rt_hw_interrupt_init();
  44. /* init board */
  45. rt_hw_board_init();
  46. rt_show_version();
  47. /* init timer system */
  48. rt_system_timer_init();
  49. #ifdef RT_USING_HEAP
  50. #ifdef __CC_ARM
  51. rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)0x40008000);
  52. #else
  53. /* init memory system */
  54. rt_system_heap_init((void *)&__bss_end, (void *)0x40008000);
  55. #endif
  56. #endif
  57. /* init scheduler system */
  58. rt_system_scheduler_init();
  59. /* init application */
  60. rt_application_init();
  61. /* init idle thread */
  62. rt_thread_idle_init();
  63. /* start scheduler */
  64. rt_system_scheduler_start();
  65. /* never reach here */
  66. return ;
  67. }
  68. int main(void)
  69. {
  70. /* invoke rtthread_startup */
  71. rtthread_startup();
  72. return 0;
  73. }
  74. /*@}*/