Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MPU6000 reset #12371

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/drivers/accgyro/accgyro_mpu.c
Expand Up @@ -339,6 +339,9 @@ bool mpuGyroReadSPI(gyroDev_t *gyro)
typedef uint8_t (*gyroSpiDetectFn_t)(const extDevice_t *dev);

static gyroSpiDetectFn_t gyroSpiDetectFnTable[] = {
#ifdef USE_GYRO_SPI_ICM20689
icm20689SpiDetect, // icm20689SpiDetect detects ICM20602 and ICM20689
#endif
#ifdef USE_GYRO_SPI_MPU6000
mpu6000SpiDetect,
#endif
Expand All @@ -348,9 +351,6 @@ static gyroSpiDetectFn_t gyroSpiDetectFnTable[] = {
#ifdef USE_GYRO_SPI_MPU9250
mpu9250SpiDetect,
#endif
#ifdef USE_GYRO_SPI_ICM20689
icm20689SpiDetect, // icm20689SpiDetect detects ICM20602 and ICM20689
#endif
#ifdef USE_ACCGYRO_LSM6DSO
lsm6dsoDetect,
#endif
Expand Down
7 changes: 3 additions & 4 deletions src/main/drivers/accgyro/accgyro_spi_mpu6000.c
Expand Up @@ -132,6 +132,9 @@ uint8_t mpu6000SpiDetect(const extDevice_t *dev)
// reset the device configuration
spiWriteReg(dev, MPU_RA_PWR_MGMT_1, BIT_H_RESET);
delay(100); // datasheet specifies a 100ms delay after reset
// reset the device signal paths
spiWriteReg(dev, MPU_RA_SIGNAL_PATH_RESET, BIT_GYRO | BIT_ACC | BIT_TEMP);
delay(100); // datasheet specifies a 100ms delay after signal path reset

const uint8_t whoAmI = spiReadRegMsk(dev, MPU_RA_WHO_AM_I);
delayMicroseconds(1); // Ensure CS high time is met which is violated on H7 without this delay
Expand All @@ -158,10 +161,6 @@ uint8_t mpu6000SpiDetect(const extDevice_t *dev)
case MPU6000_REV_D10:
detectedSensor = MPU_60x0_SPI;
}

// reset the device signal paths
spiWriteReg(dev, MPU_RA_SIGNAL_PATH_RESET, BIT_GYRO | BIT_ACC | BIT_TEMP);
delay(100); // datasheet specifies a 100ms delay after signal path reset
}

return detectedSensor;
Expand Down