Skip to content

Commit

Permalink
Disable ICM4268xx AFSR feature to prevent stalls (#13137)
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Oct 23, 2023
1 parent 0545087 commit 0d9ab29
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/drivers/accgyro/accgyro_spi_icm426xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
#define ICM426XX_BANK_SELECT3 0x03
#define ICM426XX_BANK_SELECT4 0x04

// Fix for stalls in gyro output. See https://github.com/ArduPilot/ardupilot/pull/25332
#define ICM426XX_INTF_CONFIG1 0x4D
#define ICM426XX_INTF_CONFIG1_AFSR_MASK 0xC0
#define ICM426XX_INTF_CONFIG1_AFSR_DISABLE 0x40

#define ICM426XX_RA_PWR_MGMT0 0x4E // User Bank 0
#define ICM426XX_PWR_MGMT0_ACCEL_MODE_LN (3 << 0)
#define ICM426XX_PWR_MGMT0_GYRO_MODE_LN (3 << 2)
Expand Down Expand Up @@ -274,6 +279,14 @@ void icm426xxGyroInit(gyroDev_t *gyro)

spiWriteReg(dev, ICM426XX_RA_INT_CONFIG1, intConfig1Value);

// Disable AFSR to prevent stalls in gyro output
// ICM426XX_INTF_CONFIG1 located in user bank 0
uint8_t intfConfig1Value = spiReadRegMsk(dev, ICM426XX_INTF_CONFIG1);

intfConfig1Value &= ~ICM426XX_INTF_CONFIG1_AFSR_MASK;
intfConfig1Value |= ICM426XX_INTF_CONFIG1_AFSR_DISABLE;
spiWriteReg(dev, ICM426XX_INTF_CONFIG1, intfConfig1Value);

// Turn on gyro and acc on again so ODR and FSR can be configured
turnGyroAccOn(dev);

Expand Down

0 comments on commit 0d9ab29

Please sign in to comment.