startup.c 1.8 KB

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