startup.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2011, RT-Thread Development 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. * 2011-02-24 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. /**
  18. * @addtogroup FM3
  19. */
  20. /*@{*/
  21. extern int rt_application_init(void);
  22. #ifdef __CC_ARM
  23. extern int Image$$RW_IRAM1$$ZI$$Limit;
  24. #elif __ICCARM__
  25. #pragma section="HEAP"
  26. #else
  27. extern int __bss_end;
  28. #endif
  29. /**
  30. * This function will startup RT-Thread RTOS.
  31. */
  32. void rtthread_startup(void)
  33. {
  34. /* init board */
  35. rt_hw_board_init();
  36. /* show version */
  37. rt_show_version();
  38. /* init timer system */
  39. rt_system_timer_init();
  40. #ifdef RT_USING_HEAP
  41. #ifdef __CC_ARM
  42. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  43. #elif __ICCARM__
  44. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  45. #else
  46. /* init memory system */
  47. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  48. #endif
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. /* init timer thread */
  53. rt_system_timer_thread_init();
  54. /* init application */
  55. rt_application_init();
  56. /* init idle thread */
  57. rt_thread_idle_init();
  58. /* start scheduler */
  59. rt_system_scheduler_start();
  60. /* never reach here */
  61. return ;
  62. }
  63. int main(void)
  64. {
  65. /* disable interrupt first */
  66. rt_hw_interrupt_disable();
  67. /* startup RT-Thread RTOS */
  68. rtthread_startup();
  69. return 0;
  70. }
  71. /*@}*/