startup.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 void 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$$ER_ZI$$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 __error__(char* file, unsigned long 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. #if LM3S_EXT_SRAM == 1
  75. /* init sdram */
  76. rt_system_heap_init((void*)LM3S_EXT_SRAM_BEGIN, (void*)LM3S_EXT_SRAM_END);
  77. #else
  78. #ifdef __CC_ARM
  79. rt_system_heap_init((void*)&Image$$ER_ZI$$ZI$$Limit, (void*)LM3S_SRAM_END);
  80. #elif __ICCARM__
  81. rt_system_heap_init(__segment_end("HEAP"), (void*)LM3S_SRAM_END);
  82. #else
  83. /* init memory system */
  84. rt_system_heap_init((void*)&__bss_end, (void*)LM3S_SRAM_END);
  85. #endif
  86. #endif
  87. #endif
  88. /* init scheduler system */
  89. rt_system_scheduler_init();
  90. #ifdef RT_USING_LWIP
  91. eth_system_device_init();
  92. /* register ethernetif device */
  93. rt_hw_luminaryif_init();
  94. #endif
  95. /* init hardware serial device */
  96. rt_hw_serial_init();
  97. #ifdef RT_USING_DFS
  98. /* init sd card device */
  99. rt_hw_sdcard_init();
  100. #endif
  101. /* init application */
  102. rt_application_init();
  103. #ifdef RT_USING_FINSH
  104. /* init finsh */
  105. finsh_system_init();
  106. #ifdef RT_USING_DEVICE
  107. finsh_set_device("uart1");
  108. #endif
  109. #endif
  110. /* init idle thread */
  111. rt_thread_idle_init();
  112. /* start scheduler */
  113. rt_system_scheduler_start();
  114. /* never reach here */
  115. return ;
  116. }
  117. int main(void)
  118. {
  119. /* disable interrupt first */
  120. rt_hw_interrupt_disable();
  121. rtthread_startup();
  122. return 0;
  123. }
  124. /*@}*/