This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit cb892dd434e0e693862a97010574fb2517add47f Author: Matteo Golin <[email protected]> AuthorDate: Sat Jun 20 13:24:32 2026 -0400 raspberrypi-4b/bmp280: Include optional registration of BMP280 driver This commit includes BMP280 driver registration on I2C1 in the RPi4B bringup logic _if_ the user selects the board-level configuration option (so as to not interfere with any user's custom implementation of interfacing with this sensor). A configuration is added with the BMP280 registration, example program and `uorb_listener` that is also documented. Signed-off-by: Matteo Golin <[email protected]> --- .../arm64/bcm2711/boards/raspberrypi-4b/index.rst | 8 ++++++++ boards/arm64/bcm2711/raspberrypi-4b/Kconfig | 8 ++++++++ .../configs/{i2c1 => bmp280}/defconfig | 8 ++++++++ .../bcm2711/raspberrypi-4b/configs/i2c1/defconfig | 8 ++++++++ .../bcm2711/raspberrypi-4b/src/rpi4b_bringup.c | 21 ++++++++++++++++++++- 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/Documentation/platforms/arm64/bcm2711/boards/raspberrypi-4b/index.rst b/Documentation/platforms/arm64/bcm2711/boards/raspberrypi-4b/index.rst index 8c8c2d3178b..cbe8c809155 100644 --- a/Documentation/platforms/arm64/bcm2711/boards/raspberrypi-4b/index.rst +++ b/Documentation/platforms/arm64/bcm2711/boards/raspberrypi-4b/index.rst @@ -230,6 +230,14 @@ for the Raspberry Pi 4B). It includes the :doc:`i2ctool that you will want to pass the `-b 1` flag to the tool the first time you use it, as the default bus is 0. +bmp280 +------ + +This configuration is the same as the I2C1 configuration, but it registers the +BMP280 device driver on I2C1. You can use the :doc:`bmp280 +</applications/examples/bmp280/index>` example program or the ``uorb_listener`` +program to interact with the sensor. + ostest ------ diff --git a/boards/arm64/bcm2711/raspberrypi-4b/Kconfig b/boards/arm64/bcm2711/raspberrypi-4b/Kconfig index a20867c9f7b..6628e835924 100644 --- a/boards/arm64/bcm2711/raspberrypi-4b/Kconfig +++ b/boards/arm64/bcm2711/raspberrypi-4b/Kconfig @@ -60,4 +60,12 @@ config RPI4B_FRAMEBUFFER ---help--- Registers a frame buffer character driver for graphical output. +config RPI4B_BMP280 + bool "BMP280 driver registration" + default n + depends on BCM2711_I2C1 + depends on SENSORS_BMP280 + ---help--- + Registers the driver for the BMP280 sensor on I2C1 for experimenting. + endif # ARCH_BOARD_RASPBERRYPI_4B diff --git a/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig b/boards/arm64/bcm2711/raspberrypi-4b/configs/bmp280/defconfig similarity index 90% copy from boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig copy to boards/arm64/bcm2711/raspberrypi-4b/configs/bmp280/defconfig index a60387663b2..62bbe39bc8d 100644 --- a/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig +++ b/boards/arm64/bcm2711/raspberrypi-4b/configs/bmp280/defconfig @@ -18,11 +18,13 @@ CONFIG_ARCH_IRQPRIO=y CONFIG_BCM2711_I2C1=y CONFIG_BCM2711_I2C=y CONFIG_BCM2711_I2C_DRIVER=y +CONFIG_BMP280_I2C_ADDR_77=y CONFIG_BOARD_LOOPSPERMSEC=132954 CONFIG_BUILTIN=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_EXAMPLES_BMP280=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y @@ -42,9 +44,12 @@ CONFIG_RAM_SIZE=4227858432 CONFIG_RAM_START=0x00000000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RPI4B_BMP280=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SENSORS=y +CONFIG_SENSORS_BMP280=y CONFIG_SPINLOCK=y CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=11 @@ -55,5 +60,8 @@ CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_SYSTEM=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y +CONFIG_UORB=y +CONFIG_UORB_LISTENER=y CONFIG_USEC_PER_TICK=1000 +CONFIG_USENSOR=y CONFIG_USERLED=y diff --git a/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig b/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig index a60387663b2..62bbe39bc8d 100644 --- a/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig +++ b/boards/arm64/bcm2711/raspberrypi-4b/configs/i2c1/defconfig @@ -18,11 +18,13 @@ CONFIG_ARCH_IRQPRIO=y CONFIG_BCM2711_I2C1=y CONFIG_BCM2711_I2C=y CONFIG_BCM2711_I2C_DRIVER=y +CONFIG_BMP280_I2C_ADDR_77=y CONFIG_BOARD_LOOPSPERMSEC=132954 CONFIG_BUILTIN=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y CONFIG_DEFAULT_TASK_STACKSIZE=8192 +CONFIG_EXAMPLES_BMP280=y CONFIG_EXAMPLES_HELLO=y CONFIG_EXPERIMENTAL=y CONFIG_FS_PROCFS=y @@ -42,9 +44,12 @@ CONFIG_RAM_SIZE=4227858432 CONFIG_RAM_START=0x00000000 CONFIG_RAW_BINARY=y CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RPI4B_BMP280=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_SENSORS=y +CONFIG_SENSORS_BMP280=y CONFIG_SPINLOCK=y CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=11 @@ -55,5 +60,8 @@ CONFIG_SYSTEM_NSH=y CONFIG_SYSTEM_SYSTEM=y CONFIG_TESTING_GETPRIME=y CONFIG_TESTING_OSTEST=y +CONFIG_UORB=y +CONFIG_UORB_LISTENER=y CONFIG_USEC_PER_TICK=1000 +CONFIG_USENSOR=y CONFIG_USERLED=y diff --git a/boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b_bringup.c b/boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b_bringup.c index 4f2299d2aed..98097cb031a 100644 --- a/boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b_bringup.c +++ b/boards/arm64/bcm2711/raspberrypi-4b/src/rpi4b_bringup.c @@ -45,6 +45,11 @@ #include <nuttx/video/fb.h> #endif +#ifdef CONFIG_RPI4B_BMP280 +#include <nuttx/sensors/bmp280.h> +#include "bcm2711_i2c.h" +#endif + #include "rpi4b.h" /**************************************************************************** @@ -71,7 +76,7 @@ int rpi4b_bringup(void) { syslog(LOG_ERR, "Failed to initialize GPIO driver: %d\n.", ret); } -#endif // defined(CONFIG_DEV_GPIO) +#endif /* defined(CONFIG_DEV_GPIO) */ /* Initialize I2C character drivers. */ @@ -155,5 +160,19 @@ int rpi4b_bringup(void) } #endif +#ifdef CONFIG_RPI4B_BMP280 + struct i2c_master_s *i2c1 = bcm2711_i2cbus_initialize(1); + if (i2c1 == NULL) + { + syslog(LOG_ERR, "Couldn't register I2C1.\n"); + } + + ret = bmp280_register(0, i2c1); /* Devno = 0 */ + if (ret < 0) + { + syslog(LOG_ERR, "Couldn't register BMP280: %d\n", ret); + } +#endif + return ret; }
