From 938bbb030d5c94e845257e46e020d6bbab8b4fea Mon Sep 17 00:00:00 2001 From: SummerGift Date: Thu, 20 Dec 2018 14:53:46 +0800 Subject: [bsp][stm32] optimize main func --- bsp/stm32/libraries/templates/stm32f10x/applications/main.c | 11 ++++++++++- bsp/stm32/libraries/templates/stm32f10x/board/board.c | 9 --------- bsp/stm32/libraries/templates/stm32f10x/board/board.h | 6 ------ bsp/stm32/libraries/templates/stm32f4xx/applications/main.c | 11 ++++++++++- bsp/stm32/libraries/templates/stm32f4xx/board/board.c | 9 --------- bsp/stm32/libraries/templates/stm32f4xx/board/board.h | 6 ------ bsp/stm32/libraries/templates/stm32l4xx/applications/main.c | 11 ++++++++++- bsp/stm32/libraries/templates/stm32l4xx/board/board.c | 9 --------- bsp/stm32/libraries/templates/stm32l4xx/board/board.h | 6 ------ 9 files changed, 30 insertions(+), 48 deletions(-) (limited to 'bsp/stm32/libraries') diff --git a/bsp/stm32/libraries/templates/stm32f10x/applications/main.c b/bsp/stm32/libraries/templates/stm32f10x/applications/main.c index 87a07a6246..7c40c1518d 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/applications/main.c +++ b/bsp/stm32/libraries/templates/stm32f10x/applications/main.c @@ -11,14 +11,23 @@ #include #include #include +#include "drv_gpio.h" +/* defined the LED0 pin: PB1 */ +#define LED0_PIN GET_PIN(B, 1) int main(void) { int count = 1; + /* set LED0 pin mode to output */ + rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); + while (count++) { - // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN)); + rt_pin_write(LED0_PIN, PIN_HIGH); + rt_thread_mdelay(500); + rt_pin_write(LED0_PIN, PIN_LOW); rt_thread_mdelay(500); } + return RT_EOK; } diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/board.c b/bsp/stm32/libraries/templates/stm32f10x/board/board.c index ac55193461..36c127c5b7 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/board.c +++ b/bsp/stm32/libraries/templates/stm32f10x/board/board.c @@ -51,12 +51,3 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOA_CLK_ENABLE(); } - -#ifdef RT_USING_PIN -// int board_pin_init(void) -// { -// rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); -// return 0; -// } -// INIT_BOARD_EXPORT(board_pin_init); -#endif /* RT_USING_PIN */ diff --git a/bsp/stm32/libraries/templates/stm32f10x/board/board.h b/bsp/stm32/libraries/templates/stm32f10x/board/board.h index cc2079f0e7..1c00e71dca 100644 --- a/bsp/stm32/libraries/templates/stm32f10x/board/board.h +++ b/bsp/stm32/libraries/templates/stm32f10x/board/board.h @@ -15,12 +15,6 @@ #include #include "drv_common.h" -#ifdef BSP_USING_GPIO -#include "drv_gpio.h" -/* Board Pin definitions */ -// #define LED0_PIN GET_PIN(C, 0) -#endif - /* Internal SRAM memory size[Kbytes] <8-64>, Default: 64*/ #define STM32_SRAM_SIZE 20 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) diff --git a/bsp/stm32/libraries/templates/stm32f4xx/applications/main.c b/bsp/stm32/libraries/templates/stm32f4xx/applications/main.c index 87a07a6246..7c40c1518d 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/applications/main.c +++ b/bsp/stm32/libraries/templates/stm32f4xx/applications/main.c @@ -11,14 +11,23 @@ #include #include #include +#include "drv_gpio.h" +/* defined the LED0 pin: PB1 */ +#define LED0_PIN GET_PIN(B, 1) int main(void) { int count = 1; + /* set LED0 pin mode to output */ + rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); + while (count++) { - // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN)); + rt_pin_write(LED0_PIN, PIN_HIGH); + rt_thread_mdelay(500); + rt_pin_write(LED0_PIN, PIN_LOW); rt_thread_mdelay(500); } + return RT_EOK; } diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/board.c b/bsp/stm32/libraries/templates/stm32f4xx/board/board.c index 928bbdbbde..b3cf3b0754 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/board.c +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/board.c @@ -56,12 +56,3 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOA_CLK_ENABLE(); } - -#ifdef RT_USING_PIN -// int board_pin_init(void) -// { -// rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); -// return 0; -// } -// INIT_BOARD_EXPORT(board_pin_init); -#endif /* RT_USING_PIN */ diff --git a/bsp/stm32/libraries/templates/stm32f4xx/board/board.h b/bsp/stm32/libraries/templates/stm32f4xx/board/board.h index 8cb36267f7..f7944b4ed7 100644 --- a/bsp/stm32/libraries/templates/stm32f4xx/board/board.h +++ b/bsp/stm32/libraries/templates/stm32f4xx/board/board.h @@ -15,12 +15,6 @@ #include #include "drv_common.h" -#ifdef BSP_USING_GPIO -#include "drv_gpio.h" -/* Board Pin definitions */ -// #define LED0_PIN GET_PIN(C, 0) -#endif - #define STM32_SRAM_SIZE 128 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) diff --git a/bsp/stm32/libraries/templates/stm32l4xx/applications/main.c b/bsp/stm32/libraries/templates/stm32l4xx/applications/main.c index 87a07a6246..7c40c1518d 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/applications/main.c +++ b/bsp/stm32/libraries/templates/stm32l4xx/applications/main.c @@ -11,14 +11,23 @@ #include #include #include +#include "drv_gpio.h" +/* defined the LED0 pin: PB1 */ +#define LED0_PIN GET_PIN(B, 1) int main(void) { int count = 1; + /* set LED0 pin mode to output */ + rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); + while (count++) { - // rt_pin_write(LED0_PIN, !rt_pin_read(LED0_PIN)); + rt_pin_write(LED0_PIN, PIN_HIGH); + rt_thread_mdelay(500); + rt_pin_write(LED0_PIN, PIN_LOW); rt_thread_mdelay(500); } + return RT_EOK; } diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/board.c b/bsp/stm32/libraries/templates/stm32l4xx/board/board.c index d0e25eaf04..5f8113f4d7 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/board.c +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/board.c @@ -66,12 +66,3 @@ void MX_GPIO_Init(void) __HAL_RCC_GPIOA_CLK_ENABLE(); } - -#ifdef RT_USING_PIN -// int board_pin_init(void) -// { -// rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT); -// return 0; -// } -// INIT_BOARD_EXPORT(board_pin_init); -#endif /* RT_USING_PIN */ diff --git a/bsp/stm32/libraries/templates/stm32l4xx/board/board.h b/bsp/stm32/libraries/templates/stm32l4xx/board/board.h index 2b3e8b6cb1..29e1ba4267 100644 --- a/bsp/stm32/libraries/templates/stm32l4xx/board/board.h +++ b/bsp/stm32/libraries/templates/stm32l4xx/board/board.h @@ -15,12 +15,6 @@ #include #include "drv_common.h" -#ifdef BSP_USING_GPIO -#include "drv_gpio.h" -/* Board Pin definitions */ -// #define LED0_PIN GET_PIN(C, 0) -#endif - #define STM32_SRAM_SIZE 96 #define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024) -- cgit v1.3.1