startup.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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-01-05 Bernard first implementation
  9. * 2010-03-04 Magicoe for LPC17xx
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. /**
  14. * @addtogroup LPC176x
  15. */
  16. /*@{*/
  17. #include <board.h>
  18. extern int rt_application_init(void);
  19. #ifdef __CC_ARM
  20. extern int Image$$RW_IRAM1$$ZI$$Limit;
  21. #elif __ICCARM__
  22. #pragma section="HEAP"
  23. #else
  24. extern int __bss_end;
  25. #endif
  26. /**
  27. * This function will startup RT-Thread RTOS.
  28. */
  29. void rtthread_startup(void)
  30. {
  31. /* initialize board */
  32. rt_hw_board_init();
  33. /* show version */
  34. rt_show_version();
  35. #ifdef RT_USING_HEAP
  36. /* initialize memory system */
  37. #ifdef __CC_ARM
  38. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x10008000);
  39. #elif __ICCARM__
  40. rt_system_heap_init(__segment_end("HEAP"), (void*)0x10008000);
  41. #else
  42. rt_system_heap_init((void*)&__bss_end, (void*)0x10008000);
  43. #endif
  44. #endif
  45. /* initialize scheduler system */
  46. rt_system_scheduler_init();
  47. /* initialize application */
  48. rt_application_init();
  49. /* initialize timer */
  50. rt_system_timer_init();
  51. /* initialize timer thread */
  52. rt_system_timer_thread_init();
  53. /* initialize idle thread */
  54. rt_thread_idle_init();
  55. /* start scheduler */
  56. rt_system_scheduler_start();
  57. /* never reach here */
  58. return ;
  59. }
  60. int main(void)
  61. {
  62. /* disable interrupt first */
  63. rt_hw_interrupt_disable();
  64. /* startup RT-Thread RTOS */
  65. rtthread_startup();
  66. return 0;
  67. }
  68. /*@}*/