From 0ad5c9585d7f0b2a14a8789cc14991c5d92a1da9 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Thu, 28 Dec 2023 01:09:02 +0800 Subject: [PATCH] [stm32][rt-spark] support nano version --- .../drivers/drv_flash/drv_flash_f0.c | 4 +- .../drivers/drv_flash/drv_flash_f1.c | 4 +- .../drivers/drv_flash/drv_flash_f2.c | 4 +- .../drivers/drv_flash/drv_flash_f4.c | 4 +- .../drivers/drv_flash/drv_flash_f7.c | 4 +- .../drivers/drv_flash/drv_flash_g0.c | 4 +- .../drivers/drv_flash/drv_flash_h7.c | 4 +- .../drivers/drv_flash/drv_flash_l4.c | 4 +- .../drivers/drv_flash/drv_flash_wb.c | 4 +- .../.ci/attachconfig/nano.attach | 1 + bsp/stm32/stm32f407-rt-spark/Kconfig | 18 ++- .../stm32f407-rt-spark/applications/main.c | 9 +- bsp/stm32/stm32f407-rt-spark/board/Kconfig | 110 +++++++----------- bsp/stm32/stm32f407-rt-spark/board/board.c | 1 + bsp/stm32/stm32f407-rt-spark/board/board.h | 3 - .../board/ports/drv_enc28j60.c | 7 +- .../board/ports/fal/fal_cfg.h | 3 +- .../board/ports/lcd/drv_lcd.c | 3 +- .../board/ports/led_matrix/drv_matrix_led.c | 8 +- .../board/ports/rs485/drv_rs485.c | 4 +- .../board/ports/soft_spi_flash_init.c | 4 +- .../board/ports/spi_flash_init.c | 3 +- 22 files changed, 112 insertions(+), 98 deletions(-) create mode 100644 bsp/stm32/stm32f407-rt-spark/.ci/attachconfig/nano.attach diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f0.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f0.c index c4d379a60e..4189a2fefa 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f0.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f0.c @@ -8,11 +8,13 @@ * 2018-12-22 zylx first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f1.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f1.c index fba79826cc..7672c9d575 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f1.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f1.c @@ -10,11 +10,13 @@ * */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f2.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f2.c index adf828169a..351505d6b2 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f2.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f2.c @@ -8,11 +8,13 @@ * 2018-12-5 SummerGift first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f4.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f4.c index 1c66263393..d219f8afcb 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f4.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f4.c @@ -8,11 +8,13 @@ * 2018-12-5 SummerGift first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f7.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f7.c index 27d8c93848..82fae794a5 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f7.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_f7.c @@ -11,11 +11,13 @@ * 2021-8-11 CX fix the sector calculation error bug */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_g0.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_g0.c index f15231893a..1733e5727a 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_g0.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_g0.c @@ -8,11 +8,13 @@ * 2020-06-27 NU-LL first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c index 76b8fded37..7690f97c15 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c @@ -12,11 +12,13 @@ * 2021-3-3 zhuyf233 fix some bugs */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_l4.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_l4.c index ef944eebf3..c12ecce871 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_l4.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_l4.c @@ -8,11 +8,13 @@ * 2018-12-5 SummerGift first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_wb.c b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_wb.c index 1d7243f179..e8924f494f 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_wb.c +++ b/bsp/stm32/libraries/HAL_Drivers/drivers/drv_flash/drv_flash_wb.c @@ -8,11 +8,13 @@ * 2020-10-14 Dozingfiretruck first version */ -#include "board.h" +#include +#include #ifdef BSP_USING_ON_CHIP_FLASH #include "drv_config.h" #include "drv_flash.h" +#include #if defined(RT_USING_FAL) #include "fal.h" diff --git a/bsp/stm32/stm32f407-rt-spark/.ci/attachconfig/nano.attach b/bsp/stm32/stm32f407-rt-spark/.ci/attachconfig/nano.attach new file mode 100644 index 0000000000..fb58d11a59 --- /dev/null +++ b/bsp/stm32/stm32f407-rt-spark/.ci/attachconfig/nano.attach @@ -0,0 +1 @@ +CONFIG_RT_USING_NANO=y diff --git a/bsp/stm32/stm32f407-rt-spark/Kconfig b/bsp/stm32/stm32f407-rt-spark/Kconfig index c737114605..60fa08a560 100644 --- a/bsp/stm32/stm32f407-rt-spark/Kconfig +++ b/bsp/stm32/stm32f407-rt-spark/Kconfig @@ -15,7 +15,21 @@ config PKGS_DIR option env="PKGS_ROOT" default "packages" +config SOC_STM32F407ZG + bool + select SOC_SERIES_STM32F4 + select RT_USING_COMPONENTS_INIT + select RT_USING_USER_MAIN + default y + +config BOARD_STM32F407_SPARK + bool + default y + source "$RTT_DIR/Kconfig" -source "../libraries/Kconfig" -source "board/Kconfig" source "$PKGS_DIR/Kconfig" +source "../libraries/Kconfig" + +if !RT_USING_NANO +source "board/Kconfig" +endif diff --git a/bsp/stm32/stm32f407-rt-spark/applications/main.c b/bsp/stm32/stm32f407-rt-spark/applications/main.c index 20a6f59b20..38757e1edd 100644 --- a/bsp/stm32/stm32f407-rt-spark/applications/main.c +++ b/bsp/stm32/stm32f407-rt-spark/applications/main.c @@ -6,12 +6,15 @@ * Change Logs: * Date Author Notes * 2023-07-06 Supperthomas first version + * 2023-12-03 Meco Man support nano version */ - -#include -#include #include +#include +#include +#ifndef RT_USING_NANO +#include +#endif /* RT_USING_NANO */ #define GPIO_LED_B GET_PIN(F, 11) #define GPIO_LED_R GET_PIN(F, 12) diff --git a/bsp/stm32/stm32f407-rt-spark/board/Kconfig b/bsp/stm32/stm32f407-rt-spark/board/Kconfig index ec6bc18c2e..b698018ea4 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/Kconfig +++ b/bsp/stm32/stm32f407-rt-spark/board/Kconfig @@ -1,16 +1,5 @@ menu "Hardware Drivers Config" -config SOC_STM32F407ZG - bool - select SOC_SERIES_STM32F4 - select RT_USING_COMPONENTS_INIT - select RT_USING_USER_MAIN - default y - -config BOARD_STM32F407_SPARK - bool - default y - menu "Onboard Peripheral Drivers" config BSP_USING_USB_TO_USART @@ -31,7 +20,7 @@ menu "Onboard Peripheral Drivers" select BSP_USING_UART select BSP_USING_UART3 default n - + menuconfig BSP_USING_RS485 bool "Enable RS485 (uart6)" select BSP_USING_UART @@ -69,7 +58,7 @@ menu "Onboard Peripheral Drivers" select BSP_USING_PWM14_CH1 endif - config BSP_USING_ONBOARD_LED_MATRIX + config BSP_USING_ONBOARD_LED_MATRIX bool "Enable Led MATRIX" default n select BSP_USING_PWM @@ -108,7 +97,7 @@ menu "Onboard Peripheral Drivers" select BSP_USING_I2C1 default n - config BSP_USING_ENC28j60 + config BSP_USING_ENC28j60 bool "Enable Ethernet 28j60" default n select BSP_USING_SPI @@ -127,45 +116,45 @@ menu "Onboard Peripheral Drivers" select BSP_USING_SDIO select RT_USING_DFS_ELMFAT default n - if BSP_USING_SDCARD_FATFS - menuconfig BSP_USING_FS_AUTO_MOUNT - bool "Enable filesystem auto mount" - default y - endif - - config BSP_USING_FLASH_FATFS - bool "Enable FAL filesystem partition base on W25Q64" - select BSP_USING_FAL - default n - if BSP_USING_FLASH_FATFS - menuconfig BSP_USING_FLASH_FS_AUTO_MOUNT - bool "Enable filesystem auto mount" - default y - endif + if BSP_USING_SDCARD_FATFS + menuconfig BSP_USING_FS_AUTO_MOUNT + bool "Enable filesystem auto mount" + default y + endif + + config BSP_USING_FLASH_FATFS + bool "Enable FAL filesystem partition base on W25Q64" + select BSP_USING_FAL + default n + if BSP_USING_FLASH_FATFS + menuconfig BSP_USING_FLASH_FS_AUTO_MOUNT + bool "Enable filesystem auto mount" + default y + endif endif config BSP_USING_FAL - bool "Enable FAL (enable on-chip flash and spi2 flash)" - select BSP_USING_SPI_FLASH - select RT_USING_FAL - select FAL_DEBUG_CONFIG - select FAL_PART_HAS_TABLE_CFG - select FAL_USING_SFUD_PORT + bool "Enable FAL (enable on-chip flash and spi2 flash)" + select BSP_USING_SPI_FLASH + select RT_USING_FAL + select FAL_DEBUG_CONFIG + select FAL_PART_HAS_TABLE_CFG + select FAL_USING_SFUD_PORT select BSP_USING_ON_CHIP_FLASH - - if BSP_USING_FAL - menuconfig BSP_USING_BOOTLOADER - bool "Enable bootloader partition table" - default n - endif - - - config BSP_USING_EASYFLASH + + if BSP_USING_FAL + menuconfig BSP_USING_BOOTLOADER + bool "Enable bootloader partition table" + default n + endif + + + config BSP_USING_EASYFLASH bool "Enable Easy Flash base on FAL" select BSP_USING_FAL select PKG_USING_EASYFLASH default n - + menuconfig BSP_USING_RW007_WLAN bool "Enable Rw007 Wlan Base on SPI2" default n @@ -192,9 +181,9 @@ menu "Onboard Peripheral Drivers" int "RW007 RESET pin index" default 111 endif - + config BSP_USING_AHT21 - bool "Enable AHT21(i2c3)" + bool "Enable AHT21(i2c3)" select BSP_USING_I2C select BSP_USING_I2C3 select PKG_USING_SENSORS_DRIVERS @@ -249,9 +238,9 @@ menu "Onboard Peripheral Drivers" config BSP_USING_AUDIO_RECORD bool "Enable Audio Record" default n - endif + endif + - endmenu menu "On-chip Peripheral Drivers" @@ -369,23 +358,6 @@ menu "On-chip Peripheral Drivers" default n endif - menuconfig BSP_USING_ONCHIP_RTC - bool "Enable RTC" - select RT_USING_RTC - default n - if BSP_USING_ONCHIP_RTC - choice - prompt "Select clock source" - default BSP_RTC_USING_LSE - - config BSP_RTC_USING_LSE - bool "RTC USING LSE" - - config BSP_RTC_USING_LSI - bool "RTC USING LSI" - endchoice - endif - menuconfig BSP_USING_PWM bool "Enable PWM" default n @@ -450,7 +422,7 @@ menu "On-chip Peripheral Drivers" range 1 176 default 91 endif - + menuconfig BSP_USING_SOFT_SPI2 bool "Enable soft SPI2 BUS (software simulation)" default n @@ -553,7 +525,7 @@ menu "On-chip Peripheral Drivers" range 0 143 default 80 endif - + menuconfig BSP_USING_I2C3 bool "Enable I2C3 BUS for AHT21 Onboard(software simulation)" default n @@ -577,7 +549,7 @@ menu "On-chip Peripheral Drivers" select RT_USING_PM select RT_USING_HOOK default n - + menuconfig BSP_USING_DAC bool "Enable DAC" default n diff --git a/bsp/stm32/stm32f407-rt-spark/board/board.c b/bsp/stm32/stm32f407-rt-spark/board/board.c index 4eb0ddd6e9..d49a591e48 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/board.c +++ b/bsp/stm32/stm32f407-rt-spark/board/board.c @@ -9,6 +9,7 @@ */ #include "board.h" +#include void SystemClock_Config(void) { diff --git a/bsp/stm32/stm32f407-rt-spark/board/board.h b/bsp/stm32/stm32f407-rt-spark/board/board.h index f92babcac4..a222417fe1 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/board.h +++ b/bsp/stm32/stm32f407-rt-spark/board/board.h @@ -12,10 +12,7 @@ #ifndef __BOARD_H__ #define __BOARD_H__ -#include #include -#include "drv_common.h" -#include "drv_gpio.h" #ifdef __cplusplus extern "C" { diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/drv_enc28j60.c b/bsp/stm32/stm32f407-rt-spark/board/ports/drv_enc28j60.c index 7afca5b175..1dacc9124d 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/drv_enc28j60.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/drv_enc28j60.c @@ -8,10 +8,11 @@ * 2018-08-27 ZYLX the first version */ -#include +#include #include -#include "drv_spi.h" -#include "board.h" +#include +#include +#include #define PIN_NRF_IRQ GET_PIN(E,2) #define PIN_SPI_CS GET_PIN(A,4) diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_cfg.h b/bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_cfg.h index e566857c93..aebe5552cb 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_cfg.h +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_cfg.h @@ -11,8 +11,9 @@ #ifndef _FAL_CFG_H_ #define _FAL_CFG_H_ -#include #include +#include + #define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024) #define FLASH_SIZE_GRANULARITY_64K (8 * 64 * 1024) #define FLASH_SIZE_GRANULARITY_128K (8 * 128 * 1024) diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/lcd/drv_lcd.c b/bsp/stm32/stm32f407-rt-spark/board/ports/lcd/drv_lcd.c index b088e3eb53..01b011dd9b 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/lcd/drv_lcd.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/lcd/drv_lcd.c @@ -13,7 +13,8 @@ #include #include -#include "string.h" +#include +#include #include "drv_lcd.h" #include "drv_lcd_font.h" diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/led_matrix/drv_matrix_led.c b/bsp/stm32/stm32f407-rt-spark/board/ports/led_matrix/drv_matrix_led.c index f95bc2f293..7659717dff 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/led_matrix/drv_matrix_led.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/led_matrix/drv_matrix_led.c @@ -21,19 +21,21 @@ * - logic 1 is: 900ns(H) + 400ns(L) */ +#include #include #include +#include +#include #ifndef LED_NUM - #define LED_NUM 19 // LED灯珠个数 +#define LED_NUM 19 // LED灯珠个数 #endif #define LED_MATRIX_EN_PIN GET_PIN(F, 2) TIM_HandleTypeDef htim3; DMA_HandleTypeDef hdma_tim3_ch2; -rt_align(4) -uint8_t led_buffer[LED_NUM * 24 * 2]; +rt_align(RT_ALIGN_SIZE) uint8_t led_buffer[LED_NUM * 24 * 2]; extern void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/rs485/drv_rs485.c b/bsp/stm32/stm32f407-rt-spark/board/ports/rs485/drv_rs485.c index a9fe78648d..b281e72836 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/rs485/drv_rs485.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/rs485/drv_rs485.c @@ -9,7 +9,9 @@ * 2023-05-05 yuanjie add test method */ +#include #include +#include #include "drv_rs485.h" #ifdef BSP_USING_RS485 @@ -134,4 +136,4 @@ void rs485_test(int argc, void **argv) } MSH_CMD_EXPORT(rs485_test, test rs485 transmission); -#endif /* bsp_using_RS485 */ +#endif /* BSP_USING_RS485 */ diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/soft_spi_flash_init.c b/bsp/stm32/stm32f407-rt-spark/board/ports/soft_spi_flash_init.c index 3221c84cc0..f1372de85a 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/soft_spi_flash_init.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/soft_spi_flash_init.c @@ -11,8 +11,8 @@ #include #include "spi_flash.h" #include "spi_flash_sfud.h" -#include "drv_spi.h" -#include "drv_soft_spi.h" +#include +#include #ifdef BSP_USING_SOFT_SPI_FLASH diff --git a/bsp/stm32/stm32f407-rt-spark/board/ports/spi_flash_init.c b/bsp/stm32/stm32f407-rt-spark/board/ports/spi_flash_init.c index 06d107c1ff..4b1f0f5f50 100644 --- a/bsp/stm32/stm32f407-rt-spark/board/ports/spi_flash_init.c +++ b/bsp/stm32/stm32f407-rt-spark/board/ports/spi_flash_init.c @@ -11,7 +11,8 @@ #include #include "spi_flash.h" #include "spi_flash_sfud.h" -#include "drv_spi.h" +#include +#include #if defined(BSP_USING_SPI_FLASH)