From fda55ff0f9a1077af8c1c2dc89f32463cfab968e Mon Sep 17 00:00:00 2001 From: zhongjiequan Date: Wed, 20 Sep 2017 16:16:37 +0800 Subject: [PATCH] modify bsp nv32f100x from startup/application to main style. --- bsp/nv32f100x/SConstruct | 2 +- bsp/nv32f100x/app/src/application.c | 69 ----------------- bsp/nv32f100x/app/src/main.c | 46 +++++++++++ bsp/nv32f100x/app/src/startup.c | 116 ---------------------------- bsp/nv32f100x/board/src/board.c | 36 +++++++++ bsp/nv32f100x/project.uvprojx | 9 +-- bsp/nv32f100x/rtconfig.h | 2 + bsp/nv32f100x/rtconfig.py | 12 ++- 8 files changed, 92 insertions(+), 200 deletions(-) delete mode 100644 bsp/nv32f100x/app/src/application.c create mode 100644 bsp/nv32f100x/app/src/main.c delete mode 100644 bsp/nv32f100x/app/src/startup.c diff --git a/bsp/nv32f100x/SConstruct b/bsp/nv32f100x/SConstruct index 5813f6442c..47ac06abf2 100644 --- a/bsp/nv32f100x/SConstruct +++ b/bsp/nv32f100x/SConstruct @@ -10,7 +10,7 @@ else: sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] from building import * -TARGET = 'rtthread-stm32f0xx.' + rtconfig.TARGET_EXT +TARGET = 'rtthread-nv32f100x.' + rtconfig.TARGET_EXT env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, diff --git a/bsp/nv32f100x/app/src/application.c b/bsp/nv32f100x/app/src/application.c deleted file mode 100644 index 31d3ba8559..0000000000 --- a/bsp/nv32f100x/app/src/application.c +++ /dev/null @@ -1,69 +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 - * 2013-11-15 bright add init thread and components initial - * 2017-09-19 Quintin.Z modify for nv32f100xxx version and components initial - */ - -/** - * @addtogroup STM32 - */ -/*@{*/ - -#include -#include -#include -#include "board.h" -#include -#ifdef RT_USING_COMPONENTS_INIT -#include -#endif /* RT_USING_COMPONENTS_INIT */ - -static void rt_init_thread_entry(void* parameter) -{ -extern void led_thread_entry(void* parameter); - rt_thread_t thread; - -/* Initialization RT-Thread Components */ -#ifdef RT_USING_COMPONENTS_INIT - rt_components_init(); -#endif - -/* Set finsh device */ -#ifdef RT_USING_FINSH - finsh_set_device(RT_CONSOLE_DEVICE_NAME); -#endif /* RT_USING_FINSH */ - - - /* Create led thread */ - thread = rt_thread_create("led", - led_thread_entry, RT_NULL, - 256, 20, 20); - if(thread != RT_NULL) - rt_thread_startup(thread); -} - -int rt_application_init() -{ - rt_thread_t init_thread; - init_thread = rt_thread_create("init", - rt_init_thread_entry, RT_NULL, - 512, 8, 20); - - if(init_thread != RT_NULL) - rt_thread_startup(init_thread); - - return 0; -} - - -/*@}*/ diff --git a/bsp/nv32f100x/app/src/main.c b/bsp/nv32f100x/app/src/main.c new file mode 100644 index 0000000000..b63fa2f4dc --- /dev/null +++ b/bsp/nv32f100x/app/src/main.c @@ -0,0 +1,46 @@ +/* + * File : _main.c + * This file is part of RT-Thread RTOS + * COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Change Logs: + * Date Author Notes + * 2015-11-19 Urey the first version + * 2017-09-20 Quintin.Z modify for nv32 + */ +#include "rtthread.h" +#include "finsh.h" + +extern void led_thread_entry(void* parameter); + +int main(void) +{ + rt_thread_t thread; + +#ifdef RT_USING_FINSH + finsh_set_device(RT_CONSOLE_DEVICE_NAME); +#endif + + /* Create led thread */ + thread = rt_thread_create("led", + led_thread_entry, RT_NULL, + 256, 20, 20); + if(thread != RT_NULL) + rt_thread_startup(thread); + + return 0; +} diff --git a/bsp/nv32f100x/app/src/startup.c b/bsp/nv32f100x/app/src/startup.c deleted file mode 100644 index d22e733b6a..0000000000 --- a/bsp/nv32f100x/app/src/startup.c +++ /dev/null @@ -1,116 +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 - * 2013-11-15 bright modify for stm32f0xx version and components initial - * 2017-09-19 Quintin.Z modify for nv32f100xxx version and components initial - */ - - -#include -#include - -#include "board.h" - - -extern int rt_application_init(void); -#ifdef RT_USING_FINSH -extern int finsh_system_init(void); -extern void finsh_set_device(const char* device); -#endif - -#ifdef __CC_ARM -extern int Image$$RW_IRAM1$$ZI$$Limit; -#define NV32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) -#elif __ICCARM__ -#pragma section="HEAP" -#define NV32_SRAM_BEGIN (__segment_end("HEAP")) -#else -extern int __bss_end; -#define NV32_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(uint8_t* file, uint32_t 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(); - -#ifdef RT_USING_HEAP - rt_system_heap_init((void*)NV32_SRAM_BEGIN, (void*)NV32_SRAM_END); -#endif - - /* 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/nv32f100x/board/src/board.c b/bsp/nv32f100x/board/src/board.c index df1e4e7287..23ec89f114 100644 --- a/bsp/nv32f100x/board/src/board.c +++ b/bsp/nv32f100x/board/src/board.c @@ -37,6 +37,34 @@ #define portNVIC_PENDSV_PRI ( portMIN_INTERRUPT_PRIORITY << 16UL ) #define portNVIC_SYSTICK_PRI ( portMIN_INTERRUPT_PRIORITY << 24UL ) +#ifdef __CC_ARM +extern int Image$$RW_IRAM1$$ZI$$Limit; +#define NV32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit) +#elif __ICCARM__ +#pragma section="HEAP" +#define NV32_SRAM_BEGIN (__segment_end("HEAP")) +#else +extern int __bss_end; +#define NV32_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(uint8_t* file, uint32_t 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 is the timer interrupt service routine. @@ -75,6 +103,14 @@ void rt_hw_board_init() rt_console_set_device(RT_CONSOLE_DEVICE_NAME); #endif + +#ifdef RT_USING_HEAP + rt_system_heap_init((void*)NV32_SRAM_BEGIN, (void*)NV32_SRAM_END); +#endif + + + + } long cmd_reset(int argc, char** argv) diff --git a/bsp/nv32f100x/project.uvprojx b/bsp/nv32f100x/project.uvprojx index 79db22132c..96d97f3ba2 100644 --- a/bsp/nv32f100x/project.uvprojx +++ b/bsp/nv32f100x/project.uvprojx @@ -378,20 +378,15 @@ Applications - application.c + main.c 1 - app\src\application.c + .\app\src\main.c ledapp.c 1 app\src\ledapp.c - - startup.c - 1 - app\src\startup.c - diff --git a/bsp/nv32f100x/rtconfig.h b/bsp/nv32f100x/rtconfig.h index 6e460432f4..0279e205ae 100644 --- a/bsp/nv32f100x/rtconfig.h +++ b/bsp/nv32f100x/rtconfig.h @@ -96,4 +96,6 @@ #define RT_USING_UART0 +#define RT_USING_USER_MAIN + #endif diff --git a/bsp/nv32f100x/rtconfig.py b/bsp/nv32f100x/rtconfig.py index a8f00d12da..6927eee3ab 100644 --- a/bsp/nv32f100x/rtconfig.py +++ b/bsp/nv32f100x/rtconfig.py @@ -29,7 +29,7 @@ if os.getenv('RTT_EXEC_PATH'): #BUILD = 'debug' BUILD = 'release' -STM32_TYPE = 'STM32L0XX' +NV32_TYPE = 'NV32F100X' if PLATFORM == 'gcc': # toolchains @@ -44,9 +44,9 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m0 -mthumb -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -DSTM32L072xx' + ' -DNULL=0' + CFLAGS = DEVICE + ' -DNV32F100X' + ' -DNULL=0' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' - LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-stm32.map,-cref,-u,Reset_Handler -T stm32_rom.ld' + LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-nv32.map,-cref,-u,Reset_Handler -T nv32_rom.ld' CPATH = '' LPATH = '' @@ -70,7 +70,7 @@ elif PLATFORM == 'armcc': DEVICE = ' --device DARMSTM' CFLAGS = DEVICE + ' --apcs=interwork' AFLAGS = DEVICE - LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-stm32.map --scatter stm32_rom.sct' + LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-nv32.map --scatter nv32_rom.sct' CFLAGS += ' -I./' @@ -92,8 +92,6 @@ elif PLATFORM == 'iar': LINK = 'ilinkarm' TARGET_EXT = 'out' - DEVICE = ' -D USE_STDPERIPH_DRIVER' + ' -D STM32F10X_HD' - CFLAGS = DEVICE CFLAGS += ' --diag_suppress Pa050' CFLAGS += ' --no_cse' @@ -119,7 +117,7 @@ elif PLATFORM == 'iar': AFLAGS += ' --cpu Cortex-M0' AFLAGS += ' --fpu None' - LFLAGS = ' --config stm32l0xx_flash.icf' + LFLAGS = ' --config nv32f100x_flash.icf' LFLAGS += ' --redirect _Printf=_PrintfTiny' LFLAGS += ' --redirect _Scanf=_ScanfSmall' LFLAGS += ' --entry __iar_program_start'