startup.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2012, 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. /* initialize board */
  35. rt_hw_board_init();
  36. /* show version */
  37. rt_show_version();
  38. #ifdef RT_USING_HEAP
  39. #ifdef __CC_ARM
  40. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  41. #elif __ICCARM__
  42. rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  43. #else
  44. /* init memory system */
  45. rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  46. #endif
  47. #endif
  48. /* init scheduler system */
  49. rt_system_scheduler_init();
  50. #ifdef RT_USING_DEVICE
  51. #ifdef RT_USING_DFS
  52. #ifdef RT_USING_DFS_UFFS
  53. rt_hw_nand_init();
  54. #endif
  55. #endif
  56. /* initialize all device */
  57. rt_device_init_all();
  58. #endif
  59. /* initialize application */
  60. rt_application_init();
  61. /* initialize timer thread */
  62. rt_system_timer_thread_init();
  63. /* initialize idle thread */
  64. rt_thread_idle_init();
  65. /* start scheduler */
  66. rt_system_scheduler_start();
  67. /* never reach here */
  68. return ;
  69. }
  70. int main(void)
  71. {
  72. /* disable interrupt first */
  73. rt_hw_interrupt_disable();
  74. /* startup RT-Thread RTOS */
  75. rtthread_startup();
  76. return 0;
  77. }
  78. /*@}*/