Revert "[driver/mpu6500] wait until coming out of sleep mode to read WHO_AM_I, directly taken from #2538"
This reverts commit52c104f4b8
. This reverts commit5572cb0575
.
This commit is contained in:
parent
52c104f4b8
commit
9776629f25
|
@ -37,8 +37,6 @@
|
||||||
#define DISABLE_MPU6500 IOHi(mpuSpi6500CsPin)
|
#define DISABLE_MPU6500 IOHi(mpuSpi6500CsPin)
|
||||||
#define ENABLE_MPU6500 IOLo(mpuSpi6500CsPin)
|
#define ENABLE_MPU6500 IOLo(mpuSpi6500CsPin)
|
||||||
|
|
||||||
#define BIT_SLEEP 0x40
|
|
||||||
|
|
||||||
static IO_t mpuSpi6500CsPin = IO_NONE;
|
static IO_t mpuSpi6500CsPin = IO_NONE;
|
||||||
|
|
||||||
bool mpu6500WriteRegister(uint8_t reg, uint8_t data)
|
bool mpu6500WriteRegister(uint8_t reg, uint8_t data)
|
||||||
|
@ -81,35 +79,28 @@ static void mpu6500SpiInit(void)
|
||||||
static uint8_t mpuDetected = MPU_NONE;
|
static uint8_t mpuDetected = MPU_NONE;
|
||||||
uint8_t mpu6500SpiDetect(void)
|
uint8_t mpu6500SpiDetect(void)
|
||||||
{
|
{
|
||||||
uint8_t tmp = 0, detectRetries = 0;
|
uint8_t tmp;
|
||||||
|
|
||||||
mpu6500SpiInit();
|
mpu6500SpiInit();
|
||||||
|
|
||||||
delayMicroseconds(15);
|
mpu6500ReadRegister(MPU_RA_WHO_AM_I, 1, &tmp);
|
||||||
do {
|
|
||||||
mpu6500ReadRegister(MPU_RA_PWR_MGMT_1, 1, &tmp);
|
|
||||||
detectRetries++;
|
|
||||||
} while (tmp != BIT_SLEEP && detectRetries < 30);
|
|
||||||
|
|
||||||
if (tmp == BIT_SLEEP) {
|
switch (tmp) {
|
||||||
mpu6500ReadRegister(MPU_RA_WHO_AM_I, 1, &tmp);
|
case MPU6500_WHO_AM_I_CONST:
|
||||||
delayMicroseconds(15);
|
mpuDetected = MPU_65xx_SPI;
|
||||||
switch (tmp) {
|
break;
|
||||||
case MPU6500_WHO_AM_I_CONST:
|
case MPU9250_WHO_AM_I_CONST:
|
||||||
mpuDetected = MPU_65xx_SPI;
|
case MPU9255_WHO_AM_I_CONST:
|
||||||
break;
|
mpuDetected = MPU_9250_SPI;
|
||||||
case MPU9250_WHO_AM_I_CONST:
|
break;
|
||||||
mpuDetected = MPU_9250_SPI;
|
case ICM20608G_WHO_AM_I_CONST:
|
||||||
break;
|
mpuDetected = ICM_20608_SPI;
|
||||||
case ICM20608G_WHO_AM_I_CONST:
|
break;
|
||||||
mpuDetected = ICM_20608_SPI;
|
case ICM20602_WHO_AM_I_CONST:
|
||||||
break;
|
mpuDetected = ICM_20602_SPI;
|
||||||
case ICM20602_WHO_AM_I_CONST:
|
break;
|
||||||
mpuDetected = ICM_20602_SPI;
|
default:
|
||||||
break;
|
mpuDetected = MPU_NONE;
|
||||||
default:
|
|
||||||
mpuDetected = MPU_NONE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return mpuDetected;
|
return mpuDetected;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue