From 786b296a8efbcdbe6714f2545e7a77f2f6f0ac94 Mon Sep 17 00:00:00 2001 From: lida Date: Tue, 18 Sep 2018 15:06:32 +0800 Subject: [PATCH] [bsp][stm32f40x]add main.c to file applications ,delete application.c and startup.c --- bsp/stm32f40x/applications/application.c | 59 ------------ bsp/stm32f40x/applications/main.c | 31 +++++++ bsp/stm32f40x/applications/startup.c | 111 ----------------------- bsp/stm32f40x/drivers/board.c | 4 + bsp/stm32f40x/drivers/board.h | 11 +++ bsp/stm32f40x/drivers/stm32f4xx_conf.h | 1 - 6 files changed, 46 insertions(+), 171 deletions(-) delete mode 100644 bsp/stm32f40x/applications/application.c create mode 100644 bsp/stm32f40x/applications/main.c delete mode 100644 bsp/stm32f40x/applications/startup.c diff --git a/bsp/stm32f40x/applications/application.c b/bsp/stm32f40x/applications/application.c deleted file mode 100644 index d0bffdc05e..0000000000 --- a/bsp/stm32f40x/applications/application.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - * File : application.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Development Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2009-01-05 Bernard the first version - * 2014-04-27 Bernard make code cleanup. - */ - -#include -#include - -#ifdef RT_USING_LWIP -#include -#include -#include -#include "stm32f4xx_eth.h" -#endif - -#ifdef RT_USING_FINSH -#include -#include -#endif - -#ifdef RT_USING_GDB -#include -#endif - -void rt_init_thread_entry(void* parameter) -{ - /* initialization RT-Thread Components */ - rt_components_init(); - - /* GDB STUB */ -#ifdef RT_USING_GDB - gdb_set_device("uart6"); - gdb_start(); -#endif -} - -int rt_application_init() -{ - rt_thread_t tid; - - tid = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 2048, RT_THREAD_PRIORITY_MAX/3, 20); - - if (tid != RT_NULL) - rt_thread_startup(tid); - - return 0; -} diff --git a/bsp/stm32f40x/applications/main.c b/bsp/stm32f40x/applications/main.c new file mode 100644 index 0000000000..9b756ac597 --- /dev/null +++ b/bsp/stm32f40x/applications/main.c @@ -0,0 +1,31 @@ +/* + * File : main.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2006, RT-Thread Develop Team + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://openlab.rt-thread.com/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2006-08-31 Bernard first implementation + * 2011-06-05 Bernard modify for STM32F107 version + */ + +#include +#include + +/** + * @addtogroup STM32 + */ + +/*@{*/ + +int main(void) +{ + /* user app entry */ + return 0; +} + +/*@}*/ diff --git a/bsp/stm32f40x/applications/startup.c b/bsp/stm32f40x/applications/startup.c deleted file mode 100644 index 6894d0f8ce..0000000000 --- a/bsp/stm32f40x/applications/startup.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * File : startup.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006, RT-Thread Develop Team - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://openlab.rt-thread.com/license/LICENSE - * - * Change Logs: - * Date Author Notes - * 2006-08-31 Bernard first implementation - * 2011-06-05 Bernard modify for STM32F107 version - */ - -#include -#include - -#include "stm32f4xx.h" -#include "board.h" - -/** - * @addtogroup STM32 - */ - -/*@{*/ - -extern int rt_application_init(void); - -#ifdef __CC_ARM -extern int Image$$RW_IRAM1$$ZI$$Limit; -#define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) -#elif __ICCARM__ -#pragma section="HEAP" -#define STM32_SRAM_BEGIN (__segment_end("HEAP")) -#else -extern int __bss_end; -#define STM32_SRAM_BEGIN (&__bss_end) -#endif - -/******************************************************************************* -* Function Name : assert_failed -* Description : Reports the name of the source file and the source line number -* where the assert error has occurred. -* Input : - file: pointer to the source file name -* - line: assert error line source number -* Output : None -* Return : None -*******************************************************************************/ -void assert_failed(u8* file, u32 line) -{ - rt_kprintf("\n\r Wrong parameter value detected on\r\n"); - rt_kprintf(" file %s\r\n", file); - rt_kprintf(" line %d\r\n", line); - - while (1) ; -} - -/** - * This function will startup RT-Thread RTOS. - */ -void rtthread_startup(void) -{ - /* init board */ - rt_hw_board_init(); - - /* show version */ - rt_show_version(); - - /* init tick */ - rt_system_tick_init(); - - /* init kernel object */ - rt_system_object_init(); - - /* init timer system */ - rt_system_timer_init(); - - rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); - - /* init scheduler system */ - rt_system_scheduler_init(); - - /* init application */ - rt_application_init(); - - /* init timer thread */ - rt_system_timer_thread_init(); - - /* init idle thread */ - rt_thread_idle_init(); - - /* start scheduler */ - rt_system_scheduler_start(); - - /* never reach here */ - return ; -} - -int main(void) -{ - /* disable interrupt first */ - rt_hw_interrupt_disable(); - - /* startup RT-Thread RTOS */ - rtthread_startup(); - - return 0; -} - -/*@}*/ diff --git a/bsp/stm32f40x/drivers/board.c b/bsp/stm32f40x/drivers/board.c index fe6742b70a..1b37d7e348 100644 --- a/bsp/stm32f40x/drivers/board.c +++ b/bsp/stm32f40x/drivers/board.c @@ -93,6 +93,10 @@ void rt_hw_board_init() /* Configure the SysTick */ SysTick_Configuration(); +#ifdef RT_USING_HEAP + rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END); +#endif + rt_components_board_init(); #ifdef RT_USING_CONSOLE diff --git a/bsp/stm32f40x/drivers/board.h b/bsp/stm32f40x/drivers/board.h index 4ca3cf41c6..22e6b21f9d 100644 --- a/bsp/stm32f40x/drivers/board.h +++ b/bsp/stm32f40x/drivers/board.h @@ -46,6 +46,17 @@ extern char __ICFEDIT_region_RAM_end__; #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) #endif +#ifdef __CC_ARM +extern int Image$$RW_IRAM1$$ZI$$Limit; +#define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ +#pragma section="HEAP" +#define STM32_SRAM_BEGIN (__segment_end("HEAP")) +#else +extern int __bss_end; +#define STM32_SRAM_BEGIN (&__bss_end) +#endif + void rt_hw_board_init(void); #endif diff --git a/bsp/stm32f40x/drivers/stm32f4xx_conf.h b/bsp/stm32f40x/drivers/stm32f4xx_conf.h index 065e72e94f..cc94ecdc12 100644 --- a/bsp/stm32f40x/drivers/stm32f4xx_conf.h +++ b/bsp/stm32f40x/drivers/stm32f4xx_conf.h @@ -69,7 +69,6 @@ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ -#define USE_FULL_ASSERT 1 /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT -- GitLab