startup.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. * 2017-08-08 Yang the first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include "board.h"
  13. #include "drv_sram.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. #ifdef BSP_DRV_SDRAM
  26. rt_kprintf(" heap: [0x%08x - 0x%08x]\n", LPC_EXT_SDRAM_BEGIN, LPC_EXT_SDRAM_END);
  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. }