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 15 #include <rthw.h> 16 #include <rtthread.h> 17 18 #include "board.h" 19 20 #ifdef RT_USING_LWIP 21 #include <lwip/sys.h> 22 #include <netif/ethernetif.h> 23 #endif 24 25 /** 26 * @addtogroup LM3S 27 */ 28 29 extern void rt_hw_serial_init(void); 30 31 /*@{*/ 32 #ifdef RT_USING_FINSH 33 extern int finsh_system_init(void); 34 extern void finsh_set_device(const char *device); 35 #endif 36 37 extern int rt_application_init(void); 38 extern void rt_hw_sdcard_init(void); 39 extern int rt_hw_luminaryif_init(void); 40 41 #ifdef __CC_ARM 42 extern int Image$$RW_IRAM1$$ZI$$Limit; 43 #elif __ICCARM__ 44 #pragma section="HEAP" 45 #else 46 extern int __bss_end; 47 #endif 48 49 #ifdef DEBUG 50 /******************************************************************************* 51 * Function Name : assert_failed 52 * Description : Reports the name of the source file and the source line number 53 * where the assert error has occurred. 54 * Input : - file: pointer to the source file name 55 * - line: assert error line source number 56 * Output : None 57 * Return : None 58 *******************************************************************************/ __error__(char * file,unsigned long line)59void __error__(char *file, unsigned long line) 60 { 61 rt_kprintf("\n\r Wrong parameter value detected on\r\n"); 62 rt_kprintf(" file %s\r\n", file); 63 rt_kprintf(" line %d\r\n", line); 64 65 while (1) ; 66 } 67 #endif 68 69 /** 70 * This function will startup RT-Thread RTOS. 71 */ rtthread_startup(void)72void rtthread_startup(void) 73 { 74 /* init board */ 75 rt_hw_board_init(); 76 77 /* show version */ 78 rt_show_version(); 79 80 /* init timer system */ 81 rt_system_timer_init(); 82 83 #ifdef RT_USING_HEAP 84 #if LM3S_EXT_SRAM == 1 85 /* init sdram */ 86 rt_system_heap_init((void *)LM3S_EXT_SRAM_BEGIN, (void *)LM3S_EXT_SRAM_END); 87 #else 88 #ifdef __CC_ARM 89 rt_system_heap_init((void *)&Image$$RW_IRAM1$$ZI$$Limit, (void *)LM3S_SRAM_END); 90 #elif __ICCARM__ 91 rt_system_heap_init(__segment_end("HEAP"), (void *)LM3S_SRAM_END); 92 #else 93 /* init memory system */ 94 rt_system_heap_init((void *)&__bss_end, (void *)LM3S_SRAM_END); 95 #endif 96 #endif 97 #endif 98 99 /* init scheduler system */ 100 rt_system_scheduler_init(); 101 102 #ifdef RT_USING_LWIP 103 eth_system_device_init(); 104 105 /* register ethernetif device */ 106 rt_hw_luminaryif_init(); 107 #endif 108 109 /* init hardware serial device */ 110 rt_hw_serial_init(); 111 #ifdef RT_USING_DFS 112 /* init sd card device */ 113 rt_hw_sdcard_init(); 114 #endif 115 116 /* init application */ 117 rt_application_init(); 118 119 #ifdef RT_USING_FINSH 120 /* init finsh */ 121 finsh_system_init(); 122 #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) 123 finsh_set_device("uart1"); 124 #endif 125 #endif 126 127 /* init idle thread */ 128 rt_thread_idle_init(); 129 130 /* start scheduler */ 131 rt_system_scheduler_start(); 132 133 /* never reach here */ 134 return ; 135 } 136 main(void)137int main(void) 138 { 139 /* disable interrupt first */ 140 rt_hw_interrupt_disable(); 141 142 rtthread_startup(); 143 144 return 0; 145 } 146 147 /*@}*/ 148