AP_Baro: create and use HAL_SIM_BARO_ENABLED
This commit is contained in:
parent
a53af5277c
commit
daedebce2e
@ -535,7 +535,17 @@ void AP_Baro::init(void)
|
|||||||
sensors[i].bus_id.set(0);
|
sensors[i].bus_id.set(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAL_ENABLE_LIBUAVCAN_DRIVERS
|
#if AP_SIM_BARO_ENABLED
|
||||||
|
SITL::SIM *sitl = AP::sitl();
|
||||||
|
if (sitl == nullptr) {
|
||||||
|
AP_HAL::panic("No SITL pointer");
|
||||||
|
}
|
||||||
|
for(uint8_t i = 0; i < sitl->baro_count; i++) {
|
||||||
|
ADD_BACKEND(new AP_Baro_SITL(*this));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAL_ENABLE_LIBUAVCAN_DRIVERS && !AP_SIM_BARO_ENABLED
|
||||||
// Detect UAVCAN Modules, try as many times as there are driver slots
|
// Detect UAVCAN Modules, try as many times as there are driver slots
|
||||||
for (uint8_t i = 0; i < BARO_MAX_DRIVERS; i++) {
|
for (uint8_t i = 0; i < BARO_MAX_DRIVERS; i++) {
|
||||||
ADD_BACKEND(AP_Baro_UAVCAN::probe(*this));
|
ADD_BACKEND(AP_Baro_UAVCAN::probe(*this));
|
||||||
@ -552,6 +562,15 @@ void AP_Baro::init(void)
|
|||||||
// 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) hal.i2c_mgr->get_device(bus, address)
|
||||||
|
|
||||||
|
#if AP_SIM_BARO_ENABLED
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
|
||||||
|
ADD_BACKEND(AP_Baro_MS56XX::probe(*this,
|
||||||
|
std::move(GET_I2C_DEVICE(_ext_bus, HAL_BARO_MS5611_I2C_ADDR))));
|
||||||
|
#endif
|
||||||
|
// do not probe for other drivers when using simulation:
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
#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
|
||||||
HAL_BARO_PROBE_LIST;
|
HAL_BARO_PROBE_LIST;
|
||||||
@ -630,14 +649,6 @@ void AP_Baro::init(void)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#elif AP_SIM_BARO_ENABLED
|
|
||||||
SITL::SIM *sitl = AP::sitl();
|
|
||||||
if (sitl == nullptr) {
|
|
||||||
AP_HAL::panic("No SITL pointer");
|
|
||||||
}
|
|
||||||
for(uint8_t i = 0; i < sitl->baro_count; i++) {
|
|
||||||
ADD_BACKEND(new AP_Baro_SITL(*this));
|
|
||||||
}
|
|
||||||
#elif HAL_BARO_DEFAULT == HAL_BARO_LPS25H_IMU_I2C
|
#elif HAL_BARO_DEFAULT == HAL_BARO_LPS25H_IMU_I2C
|
||||||
ADD_BACKEND(AP_Baro_LPS2XH::probe_InvensenseIMU(*this,
|
ADD_BACKEND(AP_Baro_LPS2XH::probe_InvensenseIMU(*this,
|
||||||
std::move(GET_I2C_DEVICE(HAL_BARO_LPS25H_I2C_BUS, HAL_BARO_LPS25H_I2C_ADDR)),
|
std::move(GET_I2C_DEVICE(HAL_BARO_LPS25H_I2C_BUS, HAL_BARO_LPS25H_I2C_ADDR)),
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <AP_ExternalAHRS/AP_ExternalAHRS.h>
|
#include <AP_ExternalAHRS/AP_ExternalAHRS.h>
|
||||||
|
|
||||||
#ifndef AP_SIM_BARO_ENABLED
|
#ifndef AP_SIM_BARO_ENABLED
|
||||||
#define AP_SIM_BARO_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
|
#define AP_SIM_BARO_ENABLED AP_SIM_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAL_MSP_BARO_ENABLED
|
#ifndef HAL_MSP_BARO_ENABLED
|
||||||
|
Loading…
Reference in New Issue
Block a user