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