This is an automated email from the ASF dual-hosted git repository. simbit18 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 38f58d09af6afd477dde30420c80bbe68c14197d Author: raiden00pl <[email protected]> AuthorDate: Thu Nov 26 10:37:31 2026 +0100 boards/stm32n6570-dk: Add the camera module IMU. Register the ISM330DLC of the MB1854 module on I2C1 with the LSM6DS3TR-C driver, polled, as sensor_accel0 and sensor_gyro0. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: raiden00pl <[email protected]> --- .../arm/stm32n6/boards/stm32n6570-dk/index.rst | 4 +++ .../arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt | 10 ++++-- boards/arm/stm32n6/stm32n6570-dk/src/Make.defs | 8 +++-- .../arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c | 10 ++++++ .../arm/stm32n6/stm32n6570-dk/src/stm32_camera.c | 38 ++++++++++++++++++++++ .../arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h | 22 ++++++++++++- 6 files changed, 85 insertions(+), 7 deletions(-) diff --git a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst index 616a80ffee7..92484583f47 100644 --- a/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst +++ b/Documentation/platforms/arm/stm32n6/boards/stm32n6570-dk/index.rst @@ -192,6 +192,10 @@ exposure (``CONFIG_STM32_DCMIPP_AE``) and white balance (``CONFIG_STM32_DCMIPP_AWB``), switched off with ``V4L2_CID_EXPOSURE_AUTO`` and ``V4L2_CID_AUTO_WHITE_BALANCE``. The board registers ``/dev/video``. +The module's ISM330DLC IMU (I2C1, 0x6a) uses the LSM6DS3TR-C driver +(``CONFIG_SENSORS_LSM6DS3TRC``), polled, as ``/dev/uorb/sensor_accel0`` and +``/dev/uorb/sensor_gyro0``. + Time-of-flight sensor ===================== diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt index 083c3da7a22..7c8a289a4a3 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt +++ b/boards/arm/stm32n6/stm32n6570-dk/src/CMakeLists.txt @@ -40,12 +40,16 @@ if(CONFIG_STM32_LTDC) list(APPEND SRCS stm32_lcd.c) endif() -if(CONFIG_VIDEO_VL53L5CX) - list(APPEND SRCS stm32_camera.c stm32_tof.c) -elseif(CONFIG_STM32_DCMIPP) +if(CONFIG_STM32_DCMIPP + OR CONFIG_VIDEO_VL53L5CX + OR CONFIG_SENSORS_LSM6DS3TRC) list(APPEND SRCS stm32_camera.c) endif() +if(CONFIG_VIDEO_VL53L5CX) + list(APPEND SRCS stm32_tof.c) +endif() + if(CONFIG_STM32_SDMMC2) list(APPEND SRCS stm32_sdmmc.c) endif() diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs index f643bece32e..2ea7b6ad85f 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs +++ b/boards/arm/stm32n6/stm32n6570-dk/src/Make.defs @@ -43,12 +43,14 @@ ifeq ($(CONFIG_STM32_LTDC),y) CSRCS += stm32_lcd.c endif -ifeq ($(CONFIG_VIDEO_VL53L5CX),y) -CSRCS += stm32_camera.c stm32_tof.c -else ifeq ($(CONFIG_STM32_DCMIPP),y) +ifneq ($(CONFIG_STM32_DCMIPP)$(CONFIG_VIDEO_VL53L5CX)$(CONFIG_SENSORS_LSM6DS3TRC),) CSRCS += stm32_camera.c endif +ifeq ($(CONFIG_VIDEO_VL53L5CX),y) +CSRCS += stm32_tof.c +endif + ifeq ($(CONFIG_STM32_SDMMC2),y) CSRCS += stm32_sdmmc.c endif diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c index 01cce9b76d2..a5d6646eab7 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c +++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_bringup.c @@ -184,6 +184,16 @@ int stm32_bringup(void) } #endif +#ifdef CONFIG_SENSORS_LSM6DS3TRC + /* Register the camera module IMU */ + + ret = stm32_imu_initialize(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: stm32_imu_initialize() failed: %d\n", ret); + } +#endif + #ifdef CONFIG_VIDEO_VL53L5CX ret = stm32_tof_initialize(); if (ret < 0) diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_camera.c b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_camera.c index 3260541b6be..611dbccdfc3 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32_camera.c +++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32_camera.c @@ -38,6 +38,10 @@ # include <nuttx/video/v4l2_cap.h> #endif +#ifdef CONFIG_SENSORS_LSM6DS3TRC +# include <nuttx/sensors/lsm6ds3trc.h> +#endif + #include "stm32_gpio.h" #include "stm32_i2c.h" #include "stm32_dcmipp.h" @@ -195,3 +199,37 @@ int stm32_camera_initialize(void) } #endif /* HAVE_IMX335 */ + +#ifdef CONFIG_SENSORS_LSM6DS3TRC + +/**************************************************************************** + * Name: stm32_imu_initialize + * + * Description: + * Power the camera module and register its IMU, polled. + * + * Input Parameters: + * None. + * + * Returned Value: + * Zero (OK) on success; a negated errno value on failure. + * + ****************************************************************************/ + +int stm32_imu_initialize(void) +{ + static struct lsm6ds3trc_config_s config; + FAR struct i2c_master_s *i2c; + + stm32_camera_power(); + + i2c = stm32_i2cbus_initialize(CAMERA_I2C_BUS); + if (i2c == NULL) + { + return -ENODEV; + } + + return lsm6ds3trc_register(i2c, IMU_I2C_ADDR, 0, &config); +} + +#endif /* CONFIG_SENSORS_LSM6DS3TRC */ diff --git a/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h index 206c27d9744..8728e26e7a7 100644 --- a/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h +++ b/boards/arm/stm32n6/stm32n6570-dk/src/stm32n6570-dk.h @@ -96,6 +96,12 @@ GPIO_OUTPUT_CLEAR | GPIO_PORTD | GPIO_PIN2) #define CAMERA_I2C_BUS 1 +/* ISM330DLC IMU on the camera module, I2C1 (0x6a), polled. It is register + * compatible with the LSM6DS3TR-C and uses that driver. + */ + +#define IMU_I2C_ADDR 0x6a + /* VL53L5CX time-of-flight sensor on the camera module, I2C1 (0x29): * INT on PQ0 (open drain, active low, EXTI0 like the TAMP button) and LPn * on PQ5 (low disables the I2C interface). @@ -190,10 +196,24 @@ void stm32_spiregister(void); * ****************************************************************************/ -#if defined(CONFIG_VIDEO_VL53L5CX) || defined(CONFIG_STM32_DCMIPP) +#if defined(CONFIG_VIDEO_VL53L5CX) || defined(CONFIG_STM32_DCMIPP) || \ + defined(CONFIG_SENSORS_LSM6DS3TRC) void stm32_camera_power(void); #endif +/**************************************************************************** + * Name: stm32_imu_initialize + * + * Description: + * Power the camera module and register its IMU as + * /dev/uorb/sensor_accel0 and /dev/uorb/sensor_gyro0. + * + ****************************************************************************/ + +#ifdef CONFIG_SENSORS_LSM6DS3TRC +int stm32_imu_initialize(void); +#endif + /**************************************************************************** * Name: stm32_camera_initialize *
