forked from Archive/PX4-Autopilot
hmc5883: fixed use of onboard I2C compass
This commit is contained in:
parent
aa9275c29c
commit
d0122dccfc
|
@ -1225,19 +1225,25 @@ start()
|
||||||
|
|
||||||
/* create the driver, attempt expansion bus first */
|
/* create the driver, attempt expansion bus first */
|
||||||
g_dev = new HMC5883(PX4_I2C_BUS_EXPANSION);
|
g_dev = new HMC5883(PX4_I2C_BUS_EXPANSION);
|
||||||
|
if (g_dev != nullptr && OK != g_dev->init()) {
|
||||||
|
delete g_dev;
|
||||||
|
g_dev = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PX4_I2C_BUS_ONBOARD
|
#ifdef PX4_I2C_BUS_ONBOARD
|
||||||
/* if this failed, attempt onboard sensor */
|
/* if this failed, attempt onboard sensor */
|
||||||
if (g_dev == nullptr)
|
if (g_dev == nullptr) {
|
||||||
g_dev = new HMC5883(PX4_I2C_BUS_ONBOARD);
|
g_dev = new HMC5883(PX4_I2C_BUS_ONBOARD);
|
||||||
|
if (g_dev != nullptr && OK != g_dev->init()) {
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_dev == nullptr)
|
if (g_dev == nullptr)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (OK != g_dev->init())
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* set the poll rate to default, starts automatic data collection */
|
/* set the poll rate to default, starts automatic data collection */
|
||||||
fd = open(MAG_DEVICE_PATH, O_RDONLY);
|
fd = open(MAG_DEVICE_PATH, O_RDONLY);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue