mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
fix: baro same driver multi-definition
This commit is contained in:
parent
e9f46b91cd
commit
95a6493cd0
@ -497,6 +497,21 @@ bool AP_Baro::_add_backend(AP_Baro_Backend *backend)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
wrapper around hal.i2c_mgr->get_device() that prevents duplicate devices being opened
|
||||||
|
*/
|
||||||
|
bool AP_Baro::_have_i2c_driver(uint8_t bus, uint8_t address) const
|
||||||
|
{
|
||||||
|
for (int i=0; i<_num_drivers; ++i) {
|
||||||
|
if (AP_HAL::Device::make_bus_id(AP_HAL::Device::BUS_TYPE_I2C, bus, address, 0) ==
|
||||||
|
AP_HAL::Device::change_bus_id(uint32_t(sensors[i].bus_id.get()), 0)) {
|
||||||
|
// device already has been defined.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
macro to add a backend with check for too many sensors
|
macro to add a backend with check for too many sensors
|
||||||
We don't try to start more than the maximum allowed
|
We don't try to start more than the maximum allowed
|
||||||
@ -542,7 +557,7 @@ void AP_Baro::init(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// macro for use by HAL_INS_PROBE_LIST
|
// macro for use by HAL_INS_PROBE_LIST
|
||||||
#define GET_I2C_DEVICE(bus, address) hal.i2c_mgr->get_device(bus, address)
|
#define GET_I2C_DEVICE(bus, address) _have_i2c_driver(bus, address)?nullptr:hal.i2c_mgr->get_device(bus, address)
|
||||||
|
|
||||||
#if defined(HAL_BARO_PROBE_LIST)
|
#if defined(HAL_BARO_PROBE_LIST)
|
||||||
// probe list from BARO lines in hwdef.dat
|
// probe list from BARO lines in hwdef.dat
|
||||||
|
@ -281,6 +281,8 @@ private:
|
|||||||
// when did we last notify the GCS of new pressure reference?
|
// when did we last notify the GCS of new pressure reference?
|
||||||
uint32_t _last_notify_ms;
|
uint32_t _last_notify_ms;
|
||||||
|
|
||||||
|
// see if we already have probed a i2c driver by bus number and address
|
||||||
|
bool _have_i2c_driver(uint8_t bus_num, uint8_t address) const;
|
||||||
bool _add_backend(AP_Baro_Backend *backend);
|
bool _add_backend(AP_Baro_Backend *backend);
|
||||||
void _probe_i2c_barometers(void);
|
void _probe_i2c_barometers(void);
|
||||||
AP_Int8 _filter_range; // valid value range from mean value
|
AP_Int8 _filter_range; // valid value range from mean value
|
||||||
|
@ -57,6 +57,9 @@ AP_Baro_Backend * AP_Baro_BMP085::probe(AP_Baro &baro, AP_HAL::OwnPtr<AP_HAL::De
|
|||||||
|
|
||||||
bool AP_Baro_BMP085::_init()
|
bool AP_Baro_BMP085::_init()
|
||||||
{
|
{
|
||||||
|
if (!_dev) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
union {
|
union {
|
||||||
uint8_t buff[22];
|
uint8_t buff[22];
|
||||||
uint16_t wb[11];
|
uint16_t wb[11];
|
||||||
|
Loading…
Reference in New Issue
Block a user