Add ICM-56686 IMU support - #12028
g945643frankie wants to merge 2 commits into
Conversation
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoAdd TDK ICM-56686 SPI IMU support
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Code Review by Qodo
1.
|
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12028 251 targets built. Find your board's
|
Add a driver for the TDK InvenSense ICM-56686 6-axis accel/gyro, ported from Betaflight's accgyro_spi_icm56686.c and adapted to INAV's busDevice/gyroDev_t/accDev_t abstractions. The port includes the init-order fix from betaflight/betaflight#15750: SREG_CTRL (16-bit LE), gyro/accel SRC, UI LPF and notch bypass, ODR/FSR and the INT1 pin configuration are all programmed while both sensors are powered off, then the sensors are switched to Low-Noise mode, and the DRDY interrupt source is enabled last, after the driver state has been set up. - new DEVHW_ICM56686 / GYRO_ICM56686 / ACC_ICM56686 (inserted before FAKE, as done for previous IMUs), acc_hardware table entry and CLI name - BUSDEV_REGISTER_SPI entry in common_hardware.c behind USE_IMU_ICM56686 (ICM56686_SPI_BUS / ICM56686_CS_PIN / IMU_ICM56686_ALIGN); not enabled on any target yet - docs/Settings.md regenerated Upstream: https://github.com/betaflight/betaflight/blob/master/src/main/drivers/accgyro/accgyro_spi_icm56686.c Fix: betaflight/betaflight#15750
Address review findings on the ICM-56686 driver: - Check the result of every required IREG operation (SREG_CTRL write and the SRC / UI LPF / notch read-modify-writes). They are now done in icm56686ConfigureIREG() while both sensors are still off; on any failure init stops before ODR/FSR, powering the sensors up or enabling DRDY and takes the FAILURE_GYRO_INIT_FAILED path used by other INAV gyro drivers. The betaflight#15750 ordering is unchanged. - icm56686ReadIREG() now propagates bus errors and the timeout of the final post-read IREG_DONE wait; icm56686ModifyIREG() no longer falls back to a blind write when the read fails; icm56686WriteIREG() checks the SPI burst result. - Move ACC_ICM56686 / GYRO_ICM56686 after ACC_FAKE / GYRO_FAKE so the persisted acc_hardware value of FAKE (13) does not change; ACC_MAX, the acc_hardware table, the CLI gyro name list and docs/Settings.md are updated to match.
eead383 to
b97d260
Compare
Summary
This adds a driver for the TDK InvenSense ICM-56686 6-axis IMU (accel + gyro, SPI). It is ported from Betaflight's driver and rewritten to use INAV's
busDevice_t/gyroDev_t/accDev_tcode.src/main/drivers/accgyro/accgyro_spi_icm56686.cThe ICM-56686 uses the same two-tier DREG/IREG layout as the ICM-456xx family, but its direct register map is different.
PWR_MGMT0,INT1_CONFIG0/2,ACCEL_CONFIG0,GYRO_CONFIG0and the IREG filter addresses all sit at other offsets, andWHO_AM_I=0x08. Because of that, this is a separate driver (accgyro_icm56686.c) and not a WHO_AM_I variant ofaccgyro_icm45686.c, the same split Betaflight uses.Init sequence (from betaflight#15750)
REG_MISC2, checkWHO_AM_I, leavePWR_MGMT0= off.SREG_CTRLfor 16-bit little-endian output (the reset default is 20-bit big-endian, and FS_SEL is only honoured in 16-bit mode)ACCEL_CONFIG0(±16 g, 1.6 kHz) andGYRO_CONFIG0(±2000 dps, 6.4 kHz)INT1_MODE/POLARITYcan only be changed while every source is disabled), then set push-pull, pulsed, active-highINT1_CONFIG0) last, once the driver state is set up.Why: according to the datasheet (DS-000563), SRC, UI LPF and notch fields may only be written while the sensor is off. Betaflight's earlier code wrote them after power-up. Betaflight also enabled DRDY before it had set the gyro state that its EXTI handler reads, so the handler could race against init. INAV's current gyro path does not use the EXTI data-ready handler (
dataReadyis never set by an ISR), so the race does not apply here today. The DRDY-last ordering is kept anyway so the behaviour matches upstream and stays safe if the INT pin is used later.IREG writes go out as one
busWriteBuf()burst (address MSB, address LSB, data) with CS held low. Betaflight found on hardware that separate register writes do not trigger the internal transfer on this part. BeforeIREG_DONEis polled, the driver waits the datasheet's minimum 4 µs gap.Changes
drivers/accgyro/accgyro_icm56686.{c,h}: new driver (detect, init, gyro/accel/temperature read)drivers/bus.h:DEVHW_ICM56686drivers/accgyro/accgyro_mpu.h:ICM56686_WHO_AM_I_CONSTsensors/gyro.{c,h},sensors/acceleration.{c,h}:GYRO_ICM56686/ACC_ICM56686and detection cases. The new enum values are appended afterFAKEso the persisted value ofFAKE(and existing saved configs) is unchanged; detection still tries ICM56686 before falling back to FAKE.fc/settings.yaml,fc/cli.c:ICM56686in theacc_hardwaretable and the gyro name listtarget/common_hardware.c:BUSDEV_REGISTER_SPIbehindUSE_IMU_ICM56686, usingICM56686_SPI_BUS,ICM56686_CS_PINandIMU_ICM56686_ALIGNCMakeLists.txt: add the new source filesdocs/Settings.md: regenerated withsrc/utils/update_cli_docs.pyThe driver is not enabled on any target in this PR. Board targets can opt in with
USE_IMU_ICM56686and the bus, CS and align defines.Testing
Build-tested only, with arm-none-eabi-gcc 13.2.rel1 (the version the cmake toolchain file downloads). Everything built with
-Werror, with no warnings apart from the usual LTO serial-compilation notices:MATEKF405(F4),BETAFPVF722(F7),IFLIGHT_2RAW_H743(H7): built withUSE_IMU_ICM56686added locally (not committed) on the existing IMU SPI bus/CS, to compile and link the driver.nmshows the driver symbols and thebusdev_icm56686registry entry in each ELF.MATEKF405andTBS_LUCID_H7(an ICM-45686 target) unmodified: build OKSITL: build OKNot tested on hardware. I have no ICM-56686 board, so detection, orientation, scaling and filter behaviour on real hardware still need checking. Hardware testing and feedback from anyone with an ICM-56686 board would be much appreciated.