This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch releases/13.0 in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8fb455c85e6ffff14b3c377b2440d2210ca73590 Author: raiden00pl <[email protected]> AuthorDate: Sun May 31 17:01:08 2026 +0200 boards/arm/stm32f7: switch board common to boards/arm/common/stm32 switch stm32f7 board common to boards/arm/common/stm32. Move the STM32F7-only board-common features into the shared directory so they are available to every STM32 family: - bmi270, cs4344, can_setup, cansock_setup, reset, romfs_initialize and spitest - the duplicate stm32_bh1750 is removed (already present in common). Signed-off-by: raiden00pl <[email protected]> --- boards/Kconfig | 5 +- boards/arm/common/stm32/Kconfig | 176 ++++++++++++++++++++ .../common => common/stm32}/include/stm32_bmi270.h | 8 +- .../stm32}/include/stm32_can_setup.h | 8 +- .../stm32}/include/stm32_cansock_setup.h | 8 +- .../common => common/stm32}/include/stm32_cs4344.h | 8 +- .../common => common/stm32}/include/stm32_romfs.h | 8 +- .../stm32}/include/stm32_spitest.h | 8 +- boards/arm/common/stm32/src/CMakeLists.txt | 29 ++++ boards/arm/common/stm32/src/Make.defs | 29 ++++ .../common => common/stm32}/src/stm32_bmi270.c | 2 +- .../common => common/stm32}/src/stm32_can_setup.c | 25 +-- .../stm32}/src/stm32_cansock_setup.c | 2 +- .../common => common/stm32}/src/stm32_cs4344.c | 2 +- .../common => common/stm32}/src/stm32_reset.c | 2 +- .../stm32}/src/stm32_romfs_initialize.c | 2 +- .../common => common/stm32}/src/stm32_spitest.c | 2 +- boards/arm/stm32f7/common/CMakeLists.txt | 5 +- boards/arm/stm32f7/common/Kconfig | 180 --------------------- boards/arm/stm32f7/common/Makefile | 8 +- boards/arm/stm32f7/common/include/stm32_bh1750.h | 82 ---------- boards/arm/stm32f7/common/src/CMakeLists.txt | 58 ------- boards/arm/stm32f7/common/src/Make.defs | 62 ------- boards/arm/stm32f7/common/src/stm32_bh1750.c | 89 ---------- 24 files changed, 280 insertions(+), 528 deletions(-) diff --git a/boards/Kconfig b/boards/Kconfig index 7dfa36fc3c3..4cad0f77ae8 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -5206,10 +5206,7 @@ endif if ARCH_CHIP_SAMV7 source "boards/arm/samv7/common/Kconfig" endif -if ARCH_CHIP_STM32F7 -source "boards/arm/stm32f7/common/Kconfig" -endif -if ARCH_CHIP_STM32C0 || ARCH_CHIP_STM32F0 || ARCH_CHIP_STM32F1 || ARCH_CHIP_STM32F2 || ARCH_CHIP_STM32F3 || ARCH_CHIP_STM32F4 || ARCH_CHIP_STM32G0 || ARCH_CHIP_STM32G4 || ARCH_CHIP_STM32L0 || ARCH_CHIP_STM32L1 +if ARCH_CHIP_STM32C0 || ARCH_CHIP_STM32F0 || ARCH_CHIP_STM32F1 || ARCH_CHIP_STM32F2 || ARCH_CHIP_STM32F3 || ARCH_CHIP_STM32F4 || ARCH_CHIP_STM32F7 || ARCH_CHIP_STM32G0 || ARCH_CHIP_STM32G4 || ARCH_CHIP_STM32L0 || ARCH_CHIP_STM32L1 source "boards/arm/common/stm32/Kconfig" endif if ARCH_CHIP_RP2040 diff --git a/boards/arm/common/stm32/Kconfig b/boards/arm/common/stm32/Kconfig index 3e611724880..1c025f51839 100644 --- a/boards/arm/common/stm32/Kconfig +++ b/boards/arm/common/stm32/Kconfig @@ -69,3 +69,179 @@ config BOARD_STM32_HALL3PHASE_SAMPLES default 10 endif # SENSORS_HALL3PHASE + +config STM32_ROMFS + bool "Automount baked-in ROMFS image" + default n + depends on FS_ROMFS + ---help--- + Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT + +config STM32_ROMFS_DEV_MINOR + int "Minor for the block device backing the data" + depends on STM32_ROMFS + default 64 + +config STM32_ROMFS_MOUNTPOINT + string "Mountpoint of the custom romfs image" + depends on STM32_ROMFS + default "/rom" + +config STM32_ROMFS_IMAGEFILE + string "ROMFS image file to include into build" + depends on STM32_ROMFS + default "../../../rom.img" + +config STM32_SPI_TEST + bool "Enable SPI test" + default n + ---help--- + Enable Spi test - initialize and configure SPI to send + STM32_SPI_TEST_MESSAGE text. The text is sent on the + selected SPI Buses with the configured parameters. + Note the CS lines will not be asserted. + +if STM32_SPI_TEST + +config STM32_SPI_TEST_MESSAGE + string "Text to Send on SPI Bus(es)" + default "Hello World" + depends on STM32_SPI_TEST + ---help--- + Text to sent on SPI bus(es) + +config STM32_SPI1_TEST + bool "Test SPI bus 1" + default n + depends on STM32_SPI_TEST + ---help--- + Enable Spi test - on SPI BUS 1 + +if STM32_SPI1_TEST + +config STM32_SPI1_TEST_FREQ + int "SPI 1 Clock Freq in Hz" + default 1000000 + depends on STM32_SPI1_TEST + ---help--- + Sets SPI 1 Clock Freq + +config STM32_SPI1_TEST_BITS + int "SPI 1 number of bits" + default 8 + depends on STM32_SPI1_TEST + ---help--- + Sets SPI 1 bit length + +choice + prompt "SPI BUS 1 Clock Mode" + default STM32_SPI1_TEST_MODE3 + ---help--- + Sets SPI 1 clock mode + +config STM32_SPI1_TEST_MODE0 + bool "CPOL=0 CPHA=0" + +config STM32_SPI1_TEST_MODE1 + bool "CPOL=0 CPHA=1" + +config STM32_SPI1_TEST_MODE2 + bool "CPOL=1 CPHA=0" + +config STM32_SPI1_TEST_MODE3 + bool "CPOL=1 CPHA=1" + +endchoice # "SPI BUS 1 Clock Mode" + +endif # STM32_SPI1_TEST + +config STM32_SPI2_TEST + bool "Test SPI bus 2" + default n + depends on STM32_SPI_TEST + ---help--- + Enable Spi test - on SPI BUS 2 + +if STM32_SPI2_TEST + +config STM32_SPI2_TEST_FREQ + int "SPI 2 Clock Freq in Hz" + default 12000000 + depends on STM32_SPI2_TEST + ---help--- + Sets SPI 2 Clock Freq + +config STM32_SPI2_TEST_BITS + int "SPI 2 number of bits" + default 8 + depends on STM32_SPI2_TEST + ---help--- + Sets SPI 2 bit length + +choice + prompt "SPI BUS 2 Clock Mode" + default STM32_SPI2_TEST_MODE3 + ---help--- + Sets SPI 2 clock mode + +config STM32_SPI2_TEST_MODE0 + bool "CPOL=0 CPHA=0" + +config STM32_SPI2_TEST_MODE1 + bool "CPOL=0 CPHA=1" + +config STM32_SPI2_TEST_MODE2 + bool "CPOL=1 CPHA=0" + +config STM32_SPI2_TEST_MODE3 + bool "CPOL=1 CPHA=1" + +endchoice # "SPI BUS 2 Clock Mode" + +endif # STM32_SPI2_TEST + +config STM32_SPI3_TEST + bool "Test SPI bus 3" + default n + depends on STM32_SPI_TEST + ---help--- + Enable Spi test - on SPI BUS 3 + +if STM32_SPI3_TEST + +config STM32_SPI3_TEST_FREQ + int "SPI 3 Clock Freq in Hz" + default 40000000 + depends on STM32_SPI3_TEST + ---help--- + Sets SPI 3 Clock Freq + +config STM32_SPI3_TEST_BITS + int "SPI 3 number of bits" + default 8 + depends on STM32_SPI3_TEST + ---help--- + Sets SPI 3 bit length + +choice + prompt "SPI BUS 3 Clock Mode" + default STM32_SPI3_TEST_MODE3 + ---help--- + Sets SPI 3 clock mode + +config STM32_SPI3_TEST_MODE0 + bool "CPOL=0 CPHA=0" + +config STM32_SPI3_TEST_MODE1 + bool "CPOL=0 CPHA=1" + +config STM32_SPI3_TEST_MODE2 + bool "CPOL=1 CPHA=0" + +config STM32_SPI3_TEST_MODE3 + bool "CPOL=1 CPHA=1" + +endchoice # "SPI BUS 3 Clock Mode" + +endif # STM32_SPI3_TEST +endif # STM32_SPI_TEST diff --git a/boards/arm/stm32f7/common/include/stm32_bmi270.h b/boards/arm/common/stm32/include/stm32_bmi270.h similarity index 92% rename from boards/arm/stm32f7/common/include/stm32_bmi270.h rename to boards/arm/common/stm32/include/stm32_bmi270.h index 50d4be70ae7..8b3d23c9a06 100644 --- a/boards/arm/stm32f7/common/include/stm32_bmi270.h +++ b/boards/arm/common/stm32/include/stm32_bmi270.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_bmi270.h + * boards/arm/common/stm32/include/stm32_bmi270.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BMI270_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BMI270_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_BMI270_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_BMI270_H /**************************************************************************** * Included Files @@ -79,4 +79,4 @@ int board_bmi270_initialize(int devno, int busno); } #endif -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BMI270_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_BMI270_H */ diff --git a/boards/arm/stm32f7/common/include/stm32_can_setup.h b/boards/arm/common/stm32/include/stm32_can_setup.h similarity index 91% rename from boards/arm/stm32f7/common/include/stm32_can_setup.h rename to boards/arm/common/stm32/include/stm32_can_setup.h index d0632d611df..9cd211d05b9 100644 --- a/boards/arm/stm32f7/common/include/stm32_can_setup.h +++ b/boards/arm/common/stm32/include/stm32_can_setup.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_can_setup.h + * boards/arm/common/stm32/include/stm32_can_setup.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CAN_SETUP_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CAN_SETUP_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CAN_SETUP_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CAN_SETUP_H /**************************************************************************** * Included Files @@ -70,4 +70,4 @@ int stm32_can_setup(void); } #endif -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CAN_SETUP_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CAN_SETUP_H */ diff --git a/boards/arm/stm32f7/common/include/stm32_cansock_setup.h b/boards/arm/common/stm32/include/stm32_cansock_setup.h similarity index 90% rename from boards/arm/stm32f7/common/include/stm32_cansock_setup.h rename to boards/arm/common/stm32/include/stm32_cansock_setup.h index 5dcab9fd7b5..77a41b66574 100644 --- a/boards/arm/stm32f7/common/include/stm32_cansock_setup.h +++ b/boards/arm/common/stm32/include/stm32_cansock_setup.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_cansock_setup.h + * boards/arm/common/stm32/include/stm32_cansock_setup.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CANSOCK_SETUP_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CANSOCK_SETUP_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CANSOCK_SETUP_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CANSOCK_SETUP_H /**************************************************************************** * Included Files @@ -70,4 +70,4 @@ int stm32_cansock_setup(void); } #endif -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CANSOCK_SETUP_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CANSOCK_SETUP_H */ diff --git a/boards/arm/stm32f7/common/include/stm32_cs4344.h b/boards/arm/common/stm32/include/stm32_cs4344.h similarity index 92% rename from boards/arm/stm32f7/common/include/stm32_cs4344.h rename to boards/arm/common/stm32/include/stm32_cs4344.h index 5050fb7345f..eb84188d038 100644 --- a/boards/arm/stm32f7/common/include/stm32_cs4344.h +++ b/boards/arm/common/stm32/include/stm32_cs4344.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_cs4344.h + * boards/arm/common/stm32/include/stm32_cs4344.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CS4344_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CS4344_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CS4344_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CS4344_H /**************************************************************************** * Included Files @@ -81,4 +81,4 @@ int board_cs4344_initialize(int devno, int port); } #endif -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_CS4344_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_CS4344_H */ diff --git a/boards/arm/stm32f7/common/include/stm32_romfs.h b/boards/arm/common/stm32/include/stm32_romfs.h similarity index 93% rename from boards/arm/stm32f7/common/include/stm32_romfs.h rename to boards/arm/common/stm32/include/stm32_romfs.h index 577b3a7f4ff..cbb982ebb5c 100644 --- a/boards/arm/stm32f7/common/include/stm32_romfs.h +++ b/boards/arm/common/stm32/include/stm32_romfs.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_romfs.h + * boards/arm/common/stm32/include/stm32_romfs.h * * SPDX-License-Identifier: BSD-3-Clause * SPDX-FileCopyrightText: 2017 Tomasz Wozniak. All rights reserved. @@ -34,8 +34,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_ROMFS_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_ROMFS_H /**************************************************************************** * Included Files @@ -74,4 +74,4 @@ int stm32_romfs_initialize(void); #endif /* CONFIG_STM32_ROMFS */ -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_ROMFS_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_ROMFS_H */ diff --git a/boards/arm/stm32f7/common/include/stm32_spitest.h b/boards/arm/common/stm32/include/stm32_spitest.h similarity index 91% rename from boards/arm/stm32f7/common/include/stm32_spitest.h rename to boards/arm/common/stm32/include/stm32_spitest.h index 860042f9469..29efe4880af 100644 --- a/boards/arm/stm32f7/common/include/stm32_spitest.h +++ b/boards/arm/common/stm32/include/stm32_spitest.h @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_spitest.h + * boards/arm/common/stm32/include/stm32_spitest.h * * SPDX-License-Identifier: Apache-2.0 * @@ -20,8 +20,8 @@ * ****************************************************************************/ -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_SPITEST_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_SPITEST_H +#ifndef __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_SPITEST_H +#define __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_SPITEST_H /**************************************************************************** * Included Files @@ -73,4 +73,4 @@ int stm32_spidev_bus_test(void); } #endif -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_SPITEST_H */ +#endif /* __BOARDS_ARM_COMMON_STM32_INCLUDE_STM32_SPITEST_H */ diff --git a/boards/arm/common/stm32/src/CMakeLists.txt b/boards/arm/common/stm32/src/CMakeLists.txt index 1f9b3837368..7f557894370 100644 --- a/boards/arm/common/stm32/src/CMakeLists.txt +++ b/boards/arm/common/stm32/src/CMakeLists.txt @@ -180,4 +180,33 @@ if(CONFIG_INPUT_MPR121_KEYPAD) list(APPEND SRCS stm32_mpr121.c) endif() +if(CONFIG_SENSORS_BMI270_I2C) + list(APPEND SRCS stm32_bmi270.c) +endif() + +if(CONFIG_AUDIO_CS4344) + list(APPEND SRCS stm32_cs4344.c) +endif() + +if(CONFIG_STM32_CAN) + if(CONFIG_STM32_CAN_CHARDRIVER) + list(APPEND SRCS stm32_can_setup.c) + endif() + if(CONFIG_STM32_CAN_SOCKET) + list(APPEND SRCS stm32_cansock_setup.c) + endif() +endif() + +if(CONFIG_BOARDCTL_RESET) + list(APPEND SRCS stm32_reset.c) +endif() + +if(CONFIG_STM32_ROMFS) + list(APPEND SRCS stm32_romfs_initialize.c) +endif() + +if(CONFIG_STM32_SPI_TEST) + list(APPEND SRCS stm32_spitest.c) +endif() + target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm/common/stm32/src/Make.defs b/boards/arm/common/stm32/src/Make.defs index 9470fe63aac..95482c11489 100644 --- a/boards/arm/common/stm32/src/Make.defs +++ b/boards/arm/common/stm32/src/Make.defs @@ -192,6 +192,35 @@ ifeq ($(CONFIG_INPUT_KMATRIX_I2C),y) CSRCS += stm32_kmatrix_i2c.c endif +ifeq ($(CONFIG_SENSORS_BMI270_I2C),y) + CSRCS += stm32_bmi270.c +endif + +ifeq ($(CONFIG_AUDIO_CS4344),y) + CSRCS += stm32_cs4344.c +endif + +ifeq ($(CONFIG_STM32_CAN),y) + ifeq ($(CONFIG_STM32_CAN_CHARDRIVER),y) + CSRCS += stm32_can_setup.c + endif + ifeq ($(CONFIG_STM32_CAN_SOCKET),y) + CSRCS += stm32_cansock_setup.c + endif +endif + +ifeq ($(CONFIG_BOARDCTL_RESET),y) + CSRCS += stm32_reset.c +endif + +ifeq ($(CONFIG_STM32_ROMFS),y) + CSRCS += stm32_romfs_initialize.c +endif + +ifeq ($(CONFIG_STM32_SPI_TEST),y) + CSRCS += stm32_spitest.c +endif + DEPPATH += --dep-path $(STM32_BOARD_COMMON_DIR)$(DELIM)src VPATH += :$(STM32_BOARD_COMMON_DIR)$(DELIM)src CFLAGS += ${INCDIR_PREFIX}$(STM32_BOARD_COMMON_DIR)$(DELIM)include diff --git a/boards/arm/stm32f7/common/src/stm32_bmi270.c b/boards/arm/common/stm32/src/stm32_bmi270.c similarity index 98% rename from boards/arm/stm32f7/common/src/stm32_bmi270.c rename to boards/arm/common/stm32/src/stm32_bmi270.c index 8ebe848cb39..8c0ac8fcdc0 100644 --- a/boards/arm/stm32f7/common/src/stm32_bmi270.c +++ b/boards/arm/common/stm32/src/stm32_bmi270.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_bmi270.c + * boards/arm/common/stm32/src/stm32_bmi270.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32f7/common/src/stm32_can_setup.c b/boards/arm/common/stm32/src/stm32_can_setup.c similarity index 84% rename from boards/arm/stm32f7/common/src/stm32_can_setup.c rename to boards/arm/common/stm32/src/stm32_can_setup.c index 2eedf06992e..2b3e3c476ee 100644 --- a/boards/arm/stm32f7/common/src/stm32_can_setup.c +++ b/boards/arm/common/stm32/src/stm32_can_setup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_can_setup.c + * boards/arm/common/stm32/src/stm32_can_setup.c * * SPDX-License-Identifier: Apache-2.0 * @@ -60,11 +60,10 @@ int stm32_can_setup(void) { -#if defined(CONFIG_STM32_CAN1) struct can_dev_s *can; int ret; - /* Call stm32f7can_initialize() to get an instance of the CAN interface */ + /* Register the first enabled CAN interface at "/dev/can0" */ can = stm32_caninitialize(CAN_PORT); if (can == NULL) @@ -73,8 +72,6 @@ int stm32_can_setup(void) return -ENODEV; } - /* Register the CAN driver at "/dev/can0" */ - ret = can_register("/dev/can0", can); if (ret < 0) { @@ -82,35 +79,25 @@ int stm32_can_setup(void) return ret; } - return OK; -#endif - -#if defined(CONFIG_STM32_CAN2) - struct can_dev_s *can; - int ret; - - /* Call stm32f7can_initialize() to get an instance of the CAN interface */ +#if defined(CONFIG_STM32_CAN1) && defined(CONFIG_STM32_CAN2) + /* Both CAN1 and CAN2 are enabled: register CAN2 at "/dev/can1" */ - can = stm32_caninitialize(CAN_PORT); + can = stm32_caninitialize(2); if (can == NULL) { canerr("ERROR: Failed to get CAN interface\n"); return -ENODEV; } - /* Register the CAN driver at "/dev/can1" */ - ret = can_register("/dev/can1", can); if (ret < 0) { canerr("ERROR: can_register failed: %d\n", ret); return ret; } +#endif return OK; -#else - return -ENODEV; -#endif } #endif /* CONFIG_CAN */ diff --git a/boards/arm/stm32f7/common/src/stm32_cansock_setup.c b/boards/arm/common/stm32/src/stm32_cansock_setup.c similarity index 97% rename from boards/arm/stm32f7/common/src/stm32_cansock_setup.c rename to boards/arm/common/stm32/src/stm32_cansock_setup.c index 58dbf738cfe..aad7a7df26d 100644 --- a/boards/arm/stm32f7/common/src/stm32_cansock_setup.c +++ b/boards/arm/common/stm32/src/stm32_cansock_setup.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_cansock_setup.c + * boards/arm/common/stm32/src/stm32_cansock_setup.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32f7/common/src/stm32_cs4344.c b/boards/arm/common/stm32/src/stm32_cs4344.c similarity index 99% rename from boards/arm/stm32f7/common/src/stm32_cs4344.c rename to boards/arm/common/stm32/src/stm32_cs4344.c index 88debb7a9c5..64f8ee946a8 100644 --- a/boards/arm/stm32f7/common/src/stm32_cs4344.c +++ b/boards/arm/common/stm32/src/stm32_cs4344.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_cs4344.c + * boards/arm/common/stm32/src/stm32_cs4344.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32f7/common/src/stm32_reset.c b/boards/arm/common/stm32/src/stm32_reset.c similarity index 98% rename from boards/arm/stm32f7/common/src/stm32_reset.c rename to boards/arm/common/stm32/src/stm32_reset.c index 1eaa28fe9c7..ea664e88615 100644 --- a/boards/arm/stm32f7/common/src/stm32_reset.c +++ b/boards/arm/common/stm32/src/stm32_reset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_reset.c + * boards/arm/common/stm32/src/stm32_reset.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32f7/common/src/stm32_romfs_initialize.c b/boards/arm/common/stm32/src/stm32_romfs_initialize.c similarity index 98% rename from boards/arm/stm32f7/common/src/stm32_romfs_initialize.c rename to boards/arm/common/stm32/src/stm32_romfs_initialize.c index 1d105e29b0e..37690d7c9c7 100644 --- a/boards/arm/stm32f7/common/src/stm32_romfs_initialize.c +++ b/boards/arm/common/stm32/src/stm32_romfs_initialize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_romfs_initialize.c + * boards/arm/common/stm32/src/stm32_romfs_initialize.c * * SPDX-License-Identifier: BSD-3-Clause * SPDX-FileCopyrightText: Tomasz Wozniak. All rights reserved. diff --git a/boards/arm/stm32f7/common/src/stm32_spitest.c b/boards/arm/common/stm32/src/stm32_spitest.c similarity index 99% rename from boards/arm/stm32f7/common/src/stm32_spitest.c rename to boards/arm/common/stm32/src/stm32_spitest.c index 5ae8b71833a..d1e048bb7ca 100644 --- a/boards/arm/stm32f7/common/src/stm32_spitest.c +++ b/boards/arm/common/stm32/src/stm32_spitest.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_spitest.c + * boards/arm/common/stm32/src/stm32_spitest.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/boards/arm/stm32f7/common/CMakeLists.txt b/boards/arm/stm32f7/common/CMakeLists.txt index 91bb41fe7fe..35eb394831f 100644 --- a/boards/arm/stm32f7/common/CMakeLists.txt +++ b/boards/arm/stm32f7/common/CMakeLists.txt @@ -20,5 +20,6 @@ # # ############################################################################## -add_subdirectory(src) -target_include_directories(board PRIVATE include) +if(CONFIG_ARCH_BOARD_COMMON) + add_subdirectory(${NUTTX_DIR}/boards/arm/common/stm32 stm32_common) +endif() diff --git a/boards/arm/stm32f7/common/Kconfig b/boards/arm/stm32f7/common/Kconfig deleted file mode 100644 index 8be75fe6173..00000000000 --- a/boards/arm/stm32f7/common/Kconfig +++ /dev/null @@ -1,180 +0,0 @@ -# -# For a description of the syntax of this configuration file, -# see the file kconfig-language.txt in the NuttX tools repository. -# - -config STM32_ROMFS - bool "Automount baked-in ROMFS image" - default n - depends on FS_ROMFS - ---help--- - Select STM32_ROMFS_IMAGEFILE, STM32_ROMFS_DEV_MINOR, STM32_ROMFS_MOUNTPOINT - -config STM32_ROMFS_DEV_MINOR - int "Minor for the block device backing the data" - depends on STM32_ROMFS - default 64 - -config STM32_ROMFS_MOUNTPOINT - string "Mountpoint of the custom romfs image" - depends on STM32_ROMFS - default "/rom" - -config STM32_ROMFS_IMAGEFILE - string "ROMFS image file to include into build" - depends on STM32_ROMFS - default "../../../rom.img" - -config STM32_SPI_TEST - bool "Enable SPI test" - default n - ---help--- - Enable Spi test - initialize and configure SPI to send - STM32_SPI_TEST_MESSAGE text. The text is sent on the - selected SPI Buses with the configured parameters. - Note the CS lines will not be asserted. - -if STM32_SPI_TEST - -config STM32_SPI_TEST_MESSAGE - string "Text to Send on SPI Bus(es)" - default "Hello World" - depends on STM32_SPI_TEST - ---help--- - Text to sent on SPI bus(es) - -config STM32_SPI1_TEST - bool "Test SPI bus 1" - default n - depends on STM32_SPI_TEST - ---help--- - Enable Spi test - on SPI BUS 1 - -if STM32_SPI1_TEST - -config STM32_SPI1_TEST_FREQ - int "SPI 1 Clock Freq in Hz" - default 1000000 - depends on STM32_SPI1_TEST - ---help--- - Sets SPI 1 Clock Freq - -config STM32_SPI1_TEST_BITS - int "SPI 1 number of bits" - default 8 - depends on STM32_SPI1_TEST - ---help--- - Sets SPI 1 bit length - -choice - prompt "SPI BUS 1 Clock Mode" - default STM32_SPI1_TEST_MODE3 - ---help--- - Sets SPI 1 clock mode - -config STM32_SPI1_TEST_MODE0 - bool "CPOL=0 CPHA=0" - -config STM32_SPI1_TEST_MODE1 - bool "CPOL=0 CPHA=1" - -config STM32_SPI1_TEST_MODE2 - bool "CPOL=1 CPHA=0" - -config STM32_SPI1_TEST_MODE3 - bool "CPOL=1 CPHA=1" - -endchoice # "SPI BUS 1 Clock Mode" - -endif # STM32_SPI1_TEST - -config STM32_SPI2_TEST - bool "Test SPI bus 2" - default n - depends on STM32_SPI_TEST - ---help--- - Enable Spi test - on SPI BUS 2 - -if STM32_SPI2_TEST - -config STM32_SPI2_TEST_FREQ - int "SPI 2 Clock Freq in Hz" - default 12000000 - depends on STM32_SPI2_TEST - ---help--- - Sets SPI 2 Clock Freq - -config STM32_SPI2_TEST_BITS - int "SPI 2 number of bits" - default 8 - depends on STM32_SPI2_TEST - ---help--- - Sets SPI 2 bit length - -choice - prompt "SPI BUS 2 Clock Mode" - default STM32_SPI2_TEST_MODE3 - ---help--- - Sets SPI 2 clock mode - -config STM32_SPI2_TEST_MODE0 - bool "CPOL=0 CPHA=0" - -config STM32_SPI2_TEST_MODE1 - bool "CPOL=0 CPHA=1" - -config STM32_SPI2_TEST_MODE2 - bool "CPOL=1 CPHA=0" - -config STM32_SPI2_TEST_MODE3 - bool "CPOL=1 CPHA=1" - -endchoice # "SPI BUS 2 Clock Mode" - -endif # STM32_SPI2_TEST - -config STM32_SPI3_TEST - bool "Test SPI bus 3" - default n - depends on STM32_SPI_TEST - ---help--- - Enable Spi test - on SPI BUS 3 - -if STM32_SPI3_TEST - -config STM32_SPI3_TEST_FREQ - int "SPI 3 Clock Freq in Hz" - default 40000000 - depends on STM32_SPI3_TEST - ---help--- - Sets SPI 3 Clock Freq - -config STM32_SPI3_TEST_BITS - int "SPI 3 number of bits" - default 8 - depends on STM32_SPI3_TEST - ---help--- - Sets SPI 3 bit length - -choice - prompt "SPI BUS 3 Clock Mode" - default STM32_SPI3_TEST_MODE3 - ---help--- - Sets SPI 3 clock mode - -config STM32_SPI3_TEST_MODE0 - bool "CPOL=0 CPHA=0" - -config STM32_SPI3_TEST_MODE1 - bool "CPOL=0 CPHA=1" - -config STM32_SPI3_TEST_MODE2 - bool "CPOL=1 CPHA=0" - -config STM32_SPI3_TEST_MODE3 - bool "CPOL=1 CPHA=1" - -endchoice # "SPI BUS 3 Clock Mode" - -endif # STM32_SPI3_TEST -endif # STM32_SPI_TEST diff --git a/boards/arm/stm32f7/common/Makefile b/boards/arm/stm32f7/common/Makefile index 7e0b3fe6cf5..76614a94d52 100644 --- a/boards/arm/stm32f7/common/Makefile +++ b/boards/arm/stm32f7/common/Makefile @@ -22,14 +22,18 @@ include $(TOPDIR)/Make.defs +STM32_BOARD_COMMON_DIR := $(TOPDIR)$(DELIM)boards$(DELIM)arm$(DELIM)common$(DELIM)stm32 +STM32_COMMON_SRCDIR := $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)common$(DELIM)stm32 + include board/Make.defs -include src/Make.defs +include $(STM32_BOARD_COMMON_DIR)$(DELIM)src$(DELIM)Make.defs DEPPATH += --dep-path board -DEPPATH += --dep-path src include $(TOPDIR)/boards/Board.mk ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src BOARDDIR = $(ARCHSRCDIR)$(DELIM)board CFLAGS += ${INCDIR_PREFIX}$(BOARDDIR)$(DELIM)include + +CFLAGS += ${INCDIR_PREFIX}$(STM32_COMMON_SRCDIR) diff --git a/boards/arm/stm32f7/common/include/stm32_bh1750.h b/boards/arm/stm32f7/common/include/stm32_bh1750.h deleted file mode 100644 index 0b2dd373d22..00000000000 --- a/boards/arm/stm32f7/common/include/stm32_bh1750.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/common/include/stm32_bh1750.h - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -#ifndef __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BH1750_H -#define __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BH1750_H - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Types - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ - -#ifdef __cplusplus -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Name: board_bh1750_initialize - * - * Description: - * Initialize and register the BH1750FVI Ambient Light driver. - * - * Input Parameters: - * devno - The device number, used to build the device path as /dev/lightN - * busno - The I2C bus number - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -int board_bh1750_initialize(int devno, int busno); - -#undef EXTERN -#ifdef __cplusplus -} -#endif - -#endif /* __BOARDS_ARM_STM32F7_COMMON_INCLUDE_STM32_BH1750_H */ diff --git a/boards/arm/stm32f7/common/src/CMakeLists.txt b/boards/arm/stm32f7/common/src/CMakeLists.txt deleted file mode 100644 index d4b612a0f4b..00000000000 --- a/boards/arm/stm32f7/common/src/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -# ############################################################################## -# boards/arm/stm32f7/common/src/CMakeLists.txt -# -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed to the Apache Software Foundation (ASF) under one or more contributor -# license agreements. See the NOTICE file distributed with this work for -# additional information regarding copyright ownership. The ASF licenses this -# file to you under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -# -# ############################################################################## - -set(SRCS) - -if(CONFIG_SENSORS_BH1750FVI) - list(APPEND SRCS stm32_bh1750.c) -endif() - -if(CONFIG_SENSORS_BMI270_I2C) - list(APPEND SRCS stm32_bmi270.c) -endif() - -if(CONFIG_AUDIO_CS4344) - list(APPEND SRCS stm32_cs4344.c) -endif() - -if(CONFIG_STM32_CAN) - if(CONFIG_STM32_CAN_CHARDRIVER) - list(APPEND SRCS stm32_can_setup.c) - endif() - if(CONFIG_STM32_CAN_SOCKET) - list(APPEND SRCS stm32_cansock_setup.c) - endif() -endif() - -if(CONFIG_STM32_ROMFS) - list(APPEND SRCS stm32_romfs_initialize.c) -endif() - -if(CONFIG_BOARDCTL_RESET) - list(APPEND SRCS stm32_reset.c) -endif() - -if(CONFIG_STM32_SPI_TEST) - list(APPEND SRCS stm32_spitest.c) -endif() - -target_sources(board PRIVATE ${SRCS}) diff --git a/boards/arm/stm32f7/common/src/Make.defs b/boards/arm/stm32f7/common/src/Make.defs deleted file mode 100644 index 0a4f96c20c4..00000000000 --- a/boards/arm/stm32f7/common/src/Make.defs +++ /dev/null @@ -1,62 +0,0 @@ -############################################################################# -# boards/arm/stm32f7/common/src/Make.defs -# -# SPDX-License-Identifier: Apache-2.0 -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -############################################################################# - -ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) - -ifeq ($(CONFIG_SENSORS_BH1750FVI),y) - CSRCS += stm32_bh1750.c -endif - -ifeq ($(CONFIG_SENSORS_BMI270_I2C),y) - CSRCS += stm32_bmi270.c -endif - -ifeq ($(CONFIG_AUDIO_CS4344),y) - CSRCS += stm32_cs4344.c -endif - -ifeq ($(CONFIG_STM32_CAN),y) -ifeq ($(CONFIG_STM32_CAN_CHARDRIVER),y) -CSRCS += stm32_can_setup.c -endif -ifeq ($(CONFIG_STM32_CAN_SOCKET),y) -CSRCS += stm32_cansock_setup.c -endif -endif - -ifeq ($(CONFIG_STM32_ROMFS),y) -CSRCS += stm32_romfs_initialize.c -endif - -ifeq ($(CONFIG_BOARDCTL_RESET),y) -CSRCS += stm32_reset.c -endif - -ifeq ($(CONFIG_STM32_SPI_TEST),y) -CSRCS += stm32_spitest.c -endif - -DEPPATH += --dep-path src -VPATH += :src -CFLAGS += ${INCDIR_PREFIX}$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src - -endif diff --git a/boards/arm/stm32f7/common/src/stm32_bh1750.c b/boards/arm/stm32f7/common/src/stm32_bh1750.c deleted file mode 100644 index 7267173ec41..00000000000 --- a/boards/arm/stm32f7/common/src/stm32_bh1750.c +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * boards/arm/stm32f7/common/src/stm32_bh1750.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <errno.h> -#include <nuttx/debug.h> -#include <stdio.h> - -#include <nuttx/spi/spi.h> -#include <arch/board/board.h> -#include <nuttx/sensors/bh1750fvi.h> - -#include "stm32_i2c.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: stm32_bh1750initialize - * - * Description: - * Initialize and register the BH1750FVI Ambient Light driver. - * - * Input Parameters: - * devno - The device number, used to build the device path as /dev/lightN - * busno - The I2C bus number - * - * Returned Value: - * Zero (OK) on success; a negated errno value on failure. - * - ****************************************************************************/ - -int board_bh1750_initialize(int devno, int busno) -{ - struct i2c_master_s *i2c; - char devpath[16]; - int ret; - - sninfo("Initializing BH1750FVI!\n"); - - /* Initialize I2C */ - - i2c = stm32_i2cbus_initialize(busno); - if (!i2c) - { - return -ENODEV; - } - - /* Then register the ambient light sensor */ - - snprintf(devpath, sizeof(devpath), "/dev/light%d", devno); - ret = bh1750fvi_register(devpath, i2c, BH1750FVI_I2C_ADDR); - if (ret < 0) - { - snerr("ERROR: Error registering BH1750FVI\n"); - } - - return ret; -} -
