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 * 2009-01-05 Bernard first implementation 9 * 2010-06-29 lgnq for V850 10 */ 11 12 #include <rthw.h> 13 #include <rtthread.h> 14 15 #include "board.h" 16 17 #include "CG_macrodriver.h" 18 #include "CG_system.h" 19 #include "CG_port.h" 20 #include "CG_timer.h" 21 /* Start user code for include. Do not edit comment generated here */ 22 /* End user code. Do not edit comment generated here */ 23 #include "CG_userdefine.h" 24 25 extern int rt_application_init(void); 26 27 #ifdef RT_USING_FINSH 28 extern int finsh_system_init(void); 29 extern void finsh_set_device(const char *device); 30 #endif 31 32 #ifdef RT_USING_HEAP 33 #ifdef __ICCV850__ 34 #pragma section="RT_HEAP" 35 #endif 36 #endif 37 38 /** 39 * This function will startup RT-Thread RTOS. 40 */ rtthread_startup(void)41void rtthread_startup(void) 42 { 43 /* init board */ 44 rt_hw_board_init(); 45 46 /* show version */ 47 rt_show_version(); 48 49 /* init timer system */ 50 rt_system_timer_init(); 51 52 #ifdef RT_USING_HEAP 53 #ifdef __ICCV850__ 54 rt_system_heap_init(__segment_begin("RT_HEAP"), __segment_end("RT_HEAP")); 55 #endif 56 #endif 57 58 /* init scheduler system */ 59 rt_system_scheduler_init(); 60 61 /* init application */ 62 rt_application_init(); 63 64 #ifdef RT_USING_FINSH 65 /* init finsh */ 66 finsh_system_init(); 67 #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) 68 finsh_set_device("uart0"); 69 #endif 70 #endif 71 72 /* init timer thread */ 73 rt_system_timer_thread_init(); 74 75 /* init idle thread */ 76 rt_thread_idle_init(); 77 78 /* start scheduler */ 79 rt_system_scheduler_start(); 80 81 /* never reach here */ 82 return ; 83 } 84 main(void)85int main(void) 86 { 87 /* disable interrupt first */ 88 rt_hw_interrupt_disable(); 89 90 /* init system setting */ 91 TAB0_Start(); 92 93 /* startup RT-Thread RTOS */ 94 rtthread_startup(); 95 96 return 0; 97 } 98