平台:platformio+stm32duino(arduino+stm32)

库:finani/ICM42688@^1.1.0

滤波库:paulstoffregen/Mahony@^1.2 (Mahony by Arduino)

1,关闭AFSR

库文件,cpp中加入如下

int ICM42688::disableAFSR() {
  uint8_t intfConfig1Value;
  if (readRegisters(ICM426XX_INTF_CONFIG1, 1, &intfConfig1Value) < 0) return -1;
  intfConfig1Value &= ~ICM426XX_INTF_CONFIG1_AFSR_MASK;
  intfConfig1Value |= ICM426XX_INTF_CONFIG1_AFSR_DISABLE;
  if (writeRegister(ICM426XX_INTF_CONFIG1, intfConfig1Value) < 0) return -2;
  return 1;
}

H文件public末尾中加入

  int disableAFSR();

registers.h文件加入

  static constexpr uint8_t  ICM426XX_INTF_CONFIG1 = 0x4D;
  static constexpr uint8_t  ICM426XX_INTF_CONFIG1_AFSR_MASK = 0xC0;
  static constexpr uint8_t  ICM426XX_INTF_CONFIG1_AFSR_DISABLE =0x40;

void setup()内,imu begin且判断成功后,加入

IMU.disableAFSR();