|
|
|
@ -294,6 +294,36 @@ AP_Airspeed::AP_Airspeed()
@@ -294,6 +294,36 @@ AP_Airspeed::AP_Airspeed()
|
|
|
|
|
_singleton = this; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// macro for use by HAL_INS_PROBE_LIST
|
|
|
|
|
#define GET_I2C_DEVICE(bus, address) hal.i2c_mgr->get_device(bus, address) |
|
|
|
|
|
|
|
|
|
bool AP_Airspeed::add_backend(AP_Airspeed_Backend *backend) |
|
|
|
|
{ |
|
|
|
|
if (!backend) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (num_sensors >= AIRSPEED_MAX_SENSORS) { |
|
|
|
|
AP_HAL::panic("Too many airspeed drivers"); |
|
|
|
|
} |
|
|
|
|
const uint8_t i = num_sensors; |
|
|
|
|
sensor[num_sensors++] = backend; |
|
|
|
|
if (!sensor[i]->init()) { |
|
|
|
|
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Airspeed %u init failed", i+1); |
|
|
|
|
delete sensor[i]; |
|
|
|
|
sensor[i] = nullptr; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
macro to add a backend with check for too many sensors |
|
|
|
|
We don't try to start more than the maximum allowed |
|
|
|
|
*/ |
|
|
|
|
#define ADD_BACKEND(backend) \ |
|
|
|
|
do { add_backend(backend); \
|
|
|
|
|
if (num_sensors == AIRSPEED_MAX_SENSORS) { return; } \
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
void AP_Airspeed::init() |
|
|
|
|
{
|
|
|
|
|
if (sensor[0] != nullptr) { |
|
|
|
@ -318,6 +348,11 @@ void AP_Airspeed::init()
@@ -318,6 +348,11 @@ void AP_Airspeed::init()
|
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifdef HAL_AIRSPEED_PROBE_LIST |
|
|
|
|
// load sensors via a list from hwdef.dat
|
|
|
|
|
HAL_AIRSPEED_PROBE_LIST; |
|
|
|
|
#else |
|
|
|
|
// look for sensors based on type parameters
|
|
|
|
|
for (uint8_t i=0; i<AIRSPEED_MAX_SENSORS; i++) { |
|
|
|
|
#if AP_AIRSPEED_AUTOCAL_ENABLE |
|
|
|
|
state[i].calibration.init(param[i].ratio); |
|
|
|
@ -404,6 +439,7 @@ void AP_Airspeed::init()
@@ -404,6 +439,7 @@ void AP_Airspeed::init()
|
|
|
|
|
num_sensors = i+1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif // HAL_AIRSPEED_PROBE_LIST
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// read the airspeed sensor
|
|
|
|
|