Fix wrong QMC5883L mag detection

This commit is contained in:
MJ666 2018-06-14 20:03:13 +02:00
parent 9a06900c83
commit df60162b02
1 changed files with 6 additions and 0 deletions

View File

@ -135,6 +135,12 @@ bool qmc5883lDetect(magDev_t *magDev)
uint8_t sig = 0;
bool ack = busReadRegisterBuffer(busdev, QMC5883L_REG_ID, &sig, 1);
if (ack && sig == QMC5883_ID_VAL) {
// Should be in standby mode after soft reset and sensor is really present
// Reading ChipID of 0xFF alone is not sufficient to be sure the QMC is present
ack = busReadRegisterBuffer(busdev, QMC5883L_REG_CONF1, &sig, 1);
if (ack && sig != QMC5883L_MODE_STANDBY) {
return false;
}
magDev->init = qmc5883lInit;
magDev->read = qmc5883lRead;
return true;