1
0

startup.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2012-12-05 Bernard the first version
  13. * 2015-11-11 zchong support iar compiler
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include <board.h>
  18. extern int rt_application_init(void);
  19. #ifdef __ICCARM__
  20. #pragma section="HEAP"
  21. #endif
  22. /**
  23. * This function will startup RT-Thread RTOS.
  24. */
  25. void rtthread_startup(void)
  26. {
  27. /* initialzie hardware interrupt */
  28. rt_hw_interrupt_init();
  29. /* initialize board */
  30. rt_hw_board_init();
  31. /* show RT-Thread version */
  32. rt_show_version();
  33. /* initialize memory system */
  34. #ifdef RT_USING_HEAP
  35. #ifdef __ICCARM__
  36. rt_system_heap_init(__segment_end("HEAP"), (void*)0x8FFFFFFF);
  37. #else
  38. rt_system_heap_init(HEAP_BEGIN, HEAP_END);
  39. #endif
  40. #endif
  41. /* initialize scheduler system */
  42. rt_system_scheduler_init();
  43. /* initialize timer */
  44. rt_system_timer_init();
  45. /* initialize soft timer thread */
  46. rt_system_timer_thread_init();
  47. /* initialize application */
  48. rt_application_init();
  49. /* initialize idle thread */
  50. rt_thread_idle_init();
  51. /* start scheduler */
  52. rt_system_scheduler_start();
  53. /* never reach here */
  54. return ;
  55. }
  56. int main(void)
  57. {
  58. /* disable interrupt first */
  59. rt_hw_interrupt_disable();
  60. /* invoke rtthread_startup */
  61. rtthread_startup();
  62. return 0;
  63. }