startup.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-08-31 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #ifdef RT_USING_LWIP
  18. #include <lwip/sys.h>
  19. #include <netif/ethernetif.h>
  20. #endif
  21. /**
  22. * @addtogroup LM3S
  23. */
  24. extern void rt_hw_serial_init(void);
  25. /*@{*/
  26. #ifdef RT_USING_FINSH
  27. extern int finsh_system_init(void);
  28. extern void finsh_set_device(char* device);
  29. #endif
  30. extern int rt_application_init(void);
  31. extern void rt_hw_sdcard_init(void);
  32. extern int rt_hw_luminaryif_init(void);
  33. #ifdef __CC_ARM
  34. extern int Image$$RW_IRAM1$$ZI$$Limit;
  35. #elif __ICCARM__
  36. #pragma section="HEAP"
  37. #else
  38. extern int __bss_end;
  39. #endif
  40. #ifdef DEBUG
  41. /*******************************************************************************
  42. * Function Name : assert_failed
  43. * Description : Reports the name of the source file and the source line number
  44. * where the assert error has occurred.
  45. * Input : - file: pointer to the source file name
  46. * - line: assert error line source number
  47. * Output : None
  48. * Return : None
  49. *******************************************************************************/
  50. void assert_failed(u8* file, u32 line)
  51. {
  52. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  53. rt_kprintf(" file %s\r\n", file);
  54. rt_kprintf(" line %d\r\n", line);
  55. while (1) ;
  56. }
  57. #endif
  58. /**
  59. * This function will startup RT-Thread RTOS.
  60. */
  61. void rtthread_startup(void)
  62. {
  63. /* init board */
  64. rt_hw_board_init();
  65. /* show version */
  66. rt_show_version();
  67. /* init tick */
  68. rt_system_tick_init();
  69. /* init kernel object */
  70. rt_system_object_init();
  71. /* init timer system */
  72. rt_system_timer_init();
  73. #ifdef RT_USING_HEAP
  74. #ifdef __CC_ARM
  75. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)LM3S_SRAM_END);
  76. #elif __ICCARM__
  77. rt_system_heap_init(__segment_end("HEAP"), (void*)LM3S_SRAM_END);
  78. #else
  79. /* init memory system */
  80. rt_system_heap_init((void*)&__bss_end, (void*)LM3S_SRAM_END);
  81. #endif
  82. #endif
  83. #ifdef RT_USING_MODULE
  84. /* init module system */
  85. rt_system_module_init();
  86. #endif
  87. /* init scheduler system */
  88. rt_system_scheduler_init();
  89. #ifdef RT_USING_LWIP
  90. eth_system_device_init();
  91. /* register ethernetif device */
  92. rt_hw_luminaryif_init();
  93. #endif
  94. /* init hardware serial device */
  95. rt_hw_serial_init();
  96. #ifdef RT_USING_DFS
  97. /* init sd card device */
  98. rt_hw_sdcard_init();
  99. #endif
  100. /* init application */
  101. rt_application_init();
  102. #ifdef RT_USING_FINSH
  103. /* init finsh */
  104. finsh_system_init();
  105. #ifdef RT_USING_DEVICE
  106. finsh_set_device("uart1");
  107. #endif
  108. #endif
  109. /* init idle thread */
  110. rt_thread_idle_init();
  111. /* start scheduler */
  112. rt_system_scheduler_start();
  113. /* never reach here */
  114. return ;
  115. }
  116. int main(void)
  117. {
  118. /* disable interrupt first */
  119. rt_hw_interrupt_disable();
  120. rtthread_startup();
  121. return 0;
  122. }
  123. /*@}*/