mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 14:38:30 -04:00
Fixed the QMC5883 identification,add check ID
This commit is contained in:
parent
4865aef9e4
commit
648871a388
@ -96,10 +96,7 @@ bool AP_Compass_QMC5883L::init()
|
||||
|
||||
_dev->set_retries(10);
|
||||
|
||||
uint8_t whoami;
|
||||
if (!_dev->read_registers(QMC5883L_REG_ID, &whoami,1)||
|
||||
whoami != QMC5883_ID_VAL){
|
||||
// not an QMC5883L
|
||||
if(!_check_whoami()){
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -143,6 +140,20 @@ bool AP_Compass_QMC5883L::init()
|
||||
_dev->get_semaphore()->give();
|
||||
return false;
|
||||
}
|
||||
bool AP_Compass_QMC5883L::_check_whoami()
|
||||
{
|
||||
uint8_t whoami;
|
||||
//After power on 0x21 == 0x03
|
||||
if (!_dev->read_registers(0x21, &whoami,1)||
|
||||
whoami != 0x03){
|
||||
return false;
|
||||
}
|
||||
if (!_dev->read_registers(QMC5883L_REG_ID, &whoami,1)||
|
||||
whoami != QMC5883_ID_VAL){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AP_Compass_QMC5883L::timer()
|
||||
{
|
||||
|
@ -46,6 +46,7 @@ private:
|
||||
bool force_external,
|
||||
enum Rotation rotation);
|
||||
|
||||
bool _check_whoami();
|
||||
void timer();
|
||||
bool init();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user