startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. #include "mb9bf506r.h"
  18. /**
  19. * @addtogroup FM3
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef __CC_ARM
  24. extern int Image$$RW_IRAM1$$ZI$$Limit;
  25. #elif __ICCARM__
  26. #pragma section="HEAP"
  27. #else
  28. extern int __bss_end;
  29. #endif
  30. /**
  31. * This function will startup RT-Thread RTOS.
  32. */
  33. void rtthread_startup(void)
  34. {
  35. /* init board */
  36. rt_hw_board_init();
  37. /* show version */
  38. rt_show_version();
  39. /* init timer system */
  40. rt_system_timer_init();
  41. #ifdef RT_USING_HEAP
  42. #ifdef __CC_ARM
  43. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  44. #elif __ICCARM__
  45. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  46. #else
  47. /* init memory system */
  48. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  49. #endif
  50. #endif
  51. /* init scheduler system */
  52. rt_system_scheduler_init();
  53. #ifdef RT_USING_DEVICE
  54. /* init all device */
  55. rt_device_init_all();
  56. #endif
  57. /* init application */
  58. rt_application_init();
  59. /* init timer thread */
  60. rt_system_timer_thread_init();
  61. /* init idle thread */
  62. rt_thread_idle_init();
  63. /* start scheduler */
  64. rt_system_scheduler_start();
  65. /* never reach here */
  66. return ;
  67. }
  68. int main(void)
  69. {
  70. /* disable interrupt first */
  71. rt_hw_interrupt_disable();
  72. /* init system setting */
  73. SystemInit();
  74. /* startup RT-Thread RTOS */
  75. rtthread_startup();
  76. return 0;
  77. }
  78. /*@}*/