startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * File : startup.c
  3. * COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18. *
  19. * Change Logs:
  20. * Date Author Notes
  21. * 2017-08-08 Yang the first version
  22. */
  23. #include <rthw.h>
  24. #include <rtthread.h>
  25. #include "board.h"
  26. #include "drv_sram.h"
  27. extern int rt_application_init(void);
  28. /**
  29. * This function will startup RT-Thread RTOS.
  30. */
  31. void rtthread_startup(void)
  32. {
  33. /* initialize board */
  34. rt_hw_board_init();
  35. /* show version */
  36. rt_show_version();
  37. #ifdef RT_USING_HEAP
  38. #ifdef BSP_DRV_SDRAM
  39. rt_kprintf(" heap: [0x%08x - 0x%08x]\n", LPC_EXT_SDRAM_BEGIN, LPC_EXT_SDRAM_END);
  40. rt_system_heap_init((void *)LPC_EXT_SDRAM_BEGIN, (void *)LPC_EXT_SDRAM_END);
  41. sram_init();
  42. #else
  43. rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
  44. #endif
  45. #endif
  46. /* initialize scheduler system */
  47. rt_system_scheduler_init();
  48. /* initialize system timer*/
  49. rt_system_timer_init();
  50. /* initialize application */
  51. rt_application_init();
  52. /* initialize timer thread */
  53. rt_system_timer_thread_init();
  54. /* initialize idle thread */
  55. rt_thread_idle_init();
  56. /* start scheduler */
  57. rt_system_scheduler_start();
  58. /* never reach here */
  59. return ;
  60. }
  61. int main(void)
  62. {
  63. /* disable interrupt first */
  64. rt_hw_interrupt_disable();
  65. /* startup RT-Thread RTOS */
  66. rtthread_startup();
  67. return 0;
  68. }