1 /* 2 * Copyright (c) 2006-2022, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 9 */ 10 11 #include <rthw.h> 12 #include <rtthread.h> 13 14 #include <board.h> 15 16 /** 17 * @addtogroup k64 18 */ 19 20 /*@{*/ 21 22 extern int rt_application_init(void); 23 #ifdef RT_USING_FINSH 24 extern int finsh_system_init(void); 25 extern void finsh_set_device(const char* device); 26 #endif 27 28 #ifdef __CC_ARM 29 extern int Image$$RW_IRAM2$$ZI$$Limit; 30 #define K64_SRAM_BEGIN (&Image$$RW_IRAM2$$ZI$$Limit) 31 #elif __ICCARM__ 32 #pragma section="HEAP" 33 #define K64_SRAM_BEGIN (__segment_end("HEAP")) 34 #else 35 extern int __bss_end; 36 #define K64_SRAM_BEGIN (&__bss_end) 37 #endif 38 39 /******************************************************************************* 40 * Function Name : assert_failed 41 * Description : Reports the name of the source file and the source line number 42 * where the assert error has occurred. 43 * Input : - file: pointer to the source file name 44 * - line: assert error line source number 45 * Output : None 46 * Return : None 47 *******************************************************************************/ assert_failed(rt_uint8_t * file,rt_uint32_t line)48void assert_failed(rt_uint8_t* file, rt_uint32_t line) 49 { 50 rt_kprintf("\n\r Wrong parameter value detected on\r\n"); 51 rt_kprintf(" file %s\r\n", file); 52 rt_kprintf(" line %d\r\n", line); 53 54 while (1) ; 55 } 56 57 /** 58 * This function will startup RT-Thread RTOS. 59 */ rtthread_startup(void)60void rtthread_startup(void) 61 { 62 /* init board */ 63 rt_hw_board_init(); 64 65 /* show version */ 66 rt_show_version(); 67 68 /* init timer system */ 69 rt_system_timer_init(); 70 71 rt_system_heap_init((void*)K64_SRAM_BEGIN, (void*)K64_SRAM_END); 72 73 /* init scheduler system */ 74 rt_system_scheduler_init(); 75 76 /* init application */ 77 rt_application_init(); 78 79 #ifdef RT_USING_FINSH 80 /* init finsh */ 81 finsh_system_init(); 82 #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE) 83 finsh_set_device(FINSH_DEVICE_NAME); 84 #endif 85 #endif 86 87 /* init timer thread */ 88 rt_system_timer_thread_init(); 89 90 /* init idle thread */ 91 rt_thread_idle_init(); 92 93 /* start scheduler */ 94 rt_system_scheduler_start(); 95 96 /* never reach here */ 97 return ; 98 } 99 main(void)100int main(void) 101 { 102 /* disable interrupt first */ 103 rt_hw_interrupt_disable(); 104 105 /* startup RT-Thread RTOS */ 106 rtthread_startup(); 107 108 return 0; 109 } 110 111 /*@}*/ 112