startup.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include <rthw.h>
  2. #include <rtthread.h>
  3. #include <sep4020.h>
  4. #include <board.h>
  5. #include <serial.h>
  6. #ifdef RT_USING_FINSH
  7. #include <finsh.h>
  8. #endif
  9. #ifdef RT_USING_LWIP
  10. #include <lwip/sys.h>
  11. #include <netif/ethernetif.h>
  12. #endif
  13. #define SDRAM_BASE 0x30000000
  14. #ifdef __CC_ARM
  15. extern int Image$$RW_RAM1$$ZI$$Limit;
  16. #endif
  17. extern void rt_application_init(void);
  18. extern void finsh_system_init(void);
  19. extern void sd_init(void);
  20. void rtthread_startup()
  21. {
  22. /* init hardware interrupt */
  23. rt_hw_interrupt_init();
  24. /* init board */
  25. rt_hw_board_init();
  26. /* show version */
  27. rt_show_version();
  28. /* init tick */
  29. rt_system_tick_init();
  30. /* init kernel object */
  31. rt_system_object_init();
  32. /* init timer system */
  33. rt_system_timer_init();
  34. /* init heap memory system */
  35. #ifdef __CC_ARM
  36. rt_system_heap_init((void*)&Image$$RW_RAM1$$ZI$$Limit, (void*)(SDRAM_BASE + 0x200000));
  37. #else
  38. rt_system_heap_init(&__bss_end, (void*)0x34000000);
  39. #endif
  40. /* init scheduler system */
  41. rt_system_scheduler_init();
  42. #ifdef RT_USING_DEVICE
  43. #ifdef RT_USING_DFS
  44. rt_hw_sdcard_init();
  45. #endif
  46. #ifdef RT_USING_LWIP
  47. eth_system_device_init();
  48. rt_hw_dm9161_init();
  49. #endif
  50. /*init all registed devices */
  51. rt_device_init_all();
  52. #endif
  53. /* init application */
  54. rt_application_init();
  55. #ifdef RT_USING_FINSH
  56. /* init finsh */
  57. finsh_system_init();
  58. #ifdef RT_USING_DEVICE
  59. finsh_set_device("uart0");
  60. #endif
  61. #endif
  62. /* init idle thread */
  63. rt_thread_idle_init();
  64. /* start scheduler */
  65. rt_system_scheduler_start();
  66. /* never reach here */
  67. return ;
  68. }
  69. int main()
  70. {
  71. rt_uint32_t UNUSED level;
  72. /* disable interrupt first */
  73. level = rt_hw_interrupt_disable();
  74. /* startup RT-Thread RTOS */
  75. rtthread_startup();
  76. return 0;
  77. }