1 /*
2  * Copyright (c) 2006-2021, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  * 2011-02-24     Bernard      first implementation
9  */
10 
11 #include <rthw.h>
12 #include <rtthread.h>
13 
14 #include "board.h"
15 
16 /**
17  * @addtogroup FM3
18  */
19 
20 /*@{*/
21 
22 extern int  rt_application_init(void);
23 
24 #ifdef __CC_ARM
25 extern int Image$$RW_IRAM1$$ZI$$Limit;
26 #elif __ICCARM__
27 #pragma section="HEAP"
28 #else
29 extern int __bss_end;
30 #endif
31 
32 /**
33  * This function will startup RT-Thread RTOS.
34  */
rtthread_startup(void)35 void rtthread_startup(void)
36 {
37     /* initialize board */
38     rt_hw_board_init();
39 
40     /* show version */
41     rt_show_version();
42 
43 #ifdef RT_USING_HEAP
44     #ifdef __CC_ARM
45         rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
46     #elif __ICCARM__
47         rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
48     #else
49         /* init memory system */
50         rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
51     #endif
52 #endif
53 
54     /* init scheduler system */
55     rt_system_scheduler_init();
56 
57 #ifdef RT_USING_DEVICE
58 #if defined(RT_USING_DFS) && defined(RT_USING_DFS_UFFS)
59     rt_hw_nand_init();
60 #endif
61 #endif
62 
63     /* initialize application */
64     rt_application_init();
65 
66     /* initialize timer */
67     rt_system_timer_init();
68 
69     /* initialize timer thread */
70     rt_system_timer_thread_init();
71 
72     /* initialize idle thread */
73     rt_thread_idle_init();
74 
75     /* start scheduler */
76     rt_system_scheduler_start();
77 
78     /* never reach here */
79     return ;
80 }
81 
main(void)82 int main(void)
83 {
84     /* disable interrupt first */
85     rt_hw_interrupt_disable();
86 
87     /* startup RT-Thread RTOS */
88     rtthread_startup();
89 
90     return 0;
91 }
92 
93 /*@}*/
94