startup.c 1.3 KB

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