mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
AP_RangeFinder: handle all I2C rangefinder types on PX4 in PX4Firmware
This commit is contained in:
parent
49fa887773
commit
70ca87c4e6
@ -206,14 +206,22 @@ void RangeFinder::update(void)
|
|||||||
*/
|
*/
|
||||||
void RangeFinder::detect_instance(uint8_t instance)
|
void RangeFinder::detect_instance(uint8_t instance)
|
||||||
{
|
{
|
||||||
if (_type[instance] == RangeFinder_TYPE_PLI2C) {
|
uint8_t type = _type[instance];
|
||||||
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||||
|
if (type == RangeFinder_TYPE_PLI2C ||
|
||||||
|
type == RangeFinder_TYPE_MBI2C) {
|
||||||
|
// I2C sensor types are handled by the PX4Firmware code
|
||||||
|
type = RangeFinder_TYPE_PX4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (type == RangeFinder_TYPE_PLI2C) {
|
||||||
if (AP_RangeFinder_PulsedLightLRF::detect(*this, instance)) {
|
if (AP_RangeFinder_PulsedLightLRF::detect(*this, instance)) {
|
||||||
state[instance].instance = instance;
|
state[instance].instance = instance;
|
||||||
drivers[instance] = new AP_RangeFinder_PulsedLightLRF(*this, instance, state[instance]);
|
drivers[instance] = new AP_RangeFinder_PulsedLightLRF(*this, instance, state[instance]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_type[instance] == RangeFinder_TYPE_MBI2C) {
|
if (type == RangeFinder_TYPE_MBI2C) {
|
||||||
if (AP_RangeFinder_MaxsonarI2CXL::detect(*this, instance)) {
|
if (AP_RangeFinder_MaxsonarI2CXL::detect(*this, instance)) {
|
||||||
state[instance].instance = instance;
|
state[instance].instance = instance;
|
||||||
drivers[instance] = new AP_RangeFinder_MaxsonarI2CXL(*this, instance, state[instance]);
|
drivers[instance] = new AP_RangeFinder_MaxsonarI2CXL(*this, instance, state[instance]);
|
||||||
@ -221,7 +229,7 @@ void RangeFinder::detect_instance(uint8_t instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
|
||||||
if (_type[instance] == RangeFinder_TYPE_PX4) {
|
if (type == RangeFinder_TYPE_PX4) {
|
||||||
if (AP_RangeFinder_PX4::detect(*this, instance)) {
|
if (AP_RangeFinder_PX4::detect(*this, instance)) {
|
||||||
state[instance].instance = instance;
|
state[instance].instance = instance;
|
||||||
drivers[instance] = new AP_RangeFinder_PX4(*this, instance, state[instance]);
|
drivers[instance] = new AP_RangeFinder_PX4(*this, instance, state[instance]);
|
||||||
@ -229,7 +237,7 @@ void RangeFinder::detect_instance(uint8_t instance)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (_type[instance] == RangeFinder_TYPE_ANALOG) {
|
if (type == RangeFinder_TYPE_ANALOG) {
|
||||||
// note that analog must be the last to be checked, as it will
|
// note that analog must be the last to be checked, as it will
|
||||||
// always come back as present if the pin is valid
|
// always come back as present if the pin is valid
|
||||||
if (AP_RangeFinder_analog::detect(*this, instance)) {
|
if (AP_RangeFinder_analog::detect(*this, instance)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user