startup.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. * 2014-07-13 xiaonong for LPC43xx
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include "board.h"
  14. extern int rt_application_init(void);
  15. /**
  16. * This function will startup RT-Thread RTOS.
  17. */
  18. void rtthread_startup(void)
  19. {
  20. /* initialize board */
  21. rt_hw_board_init();
  22. /* show version */
  23. rt_show_version();
  24. #ifdef RT_USING_HEAP
  25. #if LPC_EXT_SDRAM
  26. rt_system_heap_init((void *)LPC_EXT_SDRAM_BEGIN, (void *)LPC_EXT_SDRAM_END);
  27. sram_init();
  28. #else
  29. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  30. #endif
  31. #endif
  32. /* initialize scheduler system */
  33. rt_system_scheduler_init();
  34. /* initialize system timer*/
  35. rt_system_timer_init();
  36. /* initialize application */
  37. rt_application_init();
  38. /* initialize timer thread */
  39. rt_system_timer_thread_init();
  40. /* initialize idle thread */
  41. rt_thread_idle_init();
  42. /* start scheduler */
  43. rt_system_scheduler_start();
  44. /* never reach here */
  45. return ;
  46. }
  47. int main(void)
  48. {
  49. /* disable interrupt first */
  50. rt_hw_interrupt_disable();
  51. /* startup RT-Thread RTOS */
  52. rtthread_startup();
  53. return 0;
  54. }