Browse Source

AP_Baro: added autodetection of popular baro types on external bus

master
night-ghost 7 years ago committed by Andrew Tridgell
parent
commit
33bdc9196c
  1. 22
      libraries/AP_Baro/AP_Baro.cpp

22
libraries/AP_Baro/AP_Baro.cpp

@ -563,6 +563,17 @@ void AP_Baro::init(void) @@ -563,6 +563,17 @@ void AP_Baro::init(void)
std::move(hal.spi->get_device(HAL_BARO_LPS22H_NAME))));
#endif
#if defined(BOARD_I2C_BUS_EXT) && CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT
ADD_BACKEND(AP_Baro_MS56XX::probe(*this,
std::move(hal.i2c_mgr->get_device(BOARD_I2C_BUS_EXT, HAL_BARO_MS5611_I2C_ADDR))));
ADD_BACKEND(AP_Baro_BMP280::probe(*this,
std::move(hal.i2c_mgr->get_device(BOARD_I2C_BUS_EXT, HAL_BARO_BMP280_I2C_ADDR))));
ADD_BACKEND(AP_Baro_BMP085::probe(*this,
std::move(hal.i2c_mgr->get_device(BOARD_I2C_BUS_EXT, HAL_BARO_BMP085_I2C_ADDR))));
#endif
// can optionally have baro on I2C too
if (_ext_bus >= 0) {
#if APM_BUILD_TYPE(APM_BUILD_ArduSub)
@ -574,12 +585,23 @@ void AP_Baro::init(void) @@ -574,12 +585,23 @@ void AP_Baro::init(void)
#else
ADD_BACKEND(AP_Baro_MS56XX::probe(*this,
std::move(hal.i2c_mgr->get_device(_ext_bus, HAL_BARO_MS5611_I2C_ADDR))));
#if CONFIG_HAL_BOARD == HAL_BOARD_F4LIGHT // we don't know which baro user will solder
ADD_BACKEND(AP_Baro_BMP280::probe(*this,
std::move(hal.i2c_mgr->get_device(_ext_bus, HAL_BARO_BMP280_I2C_ADDR))));
ADD_BACKEND(AP_Baro_BMP085::probe(*this,
std::move(hal.i2c_mgr->get_device(_ext_bus, HAL_BARO_BMP085_I2C_ADDR))));
#endif
#endif
}
#if CONFIG_HAL_BOARD != HAL_BOARD_F4LIGHT // most boards requires external baro
if (_num_drivers == 0 || _num_sensors == 0 || drivers[0] == nullptr) {
AP_BoardConfig::sensor_config_error("Baro: unable to initialise driver");
}
#endif
}

Loading…
Cancel
Save