mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 16:38:53 +08:00
drivers: minimize additional I2C retries
This commit is contained in:
@@ -49,8 +49,6 @@ LidarLiteI2C::LidarLiteI2C(const I2CSPIDriverConfig &config) :
|
||||
_px4_rangefinder.set_min_distance(LL40LS_MIN_DISTANCE);
|
||||
_px4_rangefinder.set_max_distance(LL40LS_MAX_DISTANCE);
|
||||
_px4_rangefinder.set_fov(0.008); // Divergence 8 mRadian
|
||||
// up the retries since the device misses the first measure attempts
|
||||
_retries = 3;
|
||||
|
||||
_px4_rangefinder.set_device_type(DRV_DIST_DEVTYPE_LL40LS); /// TODO
|
||||
}
|
||||
@@ -126,9 +124,6 @@ LidarLiteI2C::probe()
|
||||
uint8_t id_high = 0;
|
||||
uint8_t id_low = 0;
|
||||
|
||||
// more retries for detection
|
||||
_retries = 10;
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(addresses); i++) {
|
||||
|
||||
set_device_address(addresses[i]);
|
||||
@@ -196,7 +191,7 @@ LidarLiteI2C::probe()
|
||||
}
|
||||
}
|
||||
|
||||
_retries = 3;
|
||||
_retries = 1;
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +78,6 @@ TERARANGER::TERARANGER(const I2CSPIDriverConfig &config) :
|
||||
I2CSPIDriver(config),
|
||||
_px4_rangefinder(get_device_id(), config.rotation)
|
||||
{
|
||||
// up the retries since the device misses the first measure attempts
|
||||
I2C::_retries = 3;
|
||||
|
||||
_px4_rangefinder.set_device_type(DRV_DIST_DEVTYPE_TERARANGER);
|
||||
_px4_rangefinder.set_rangefinder_type(distance_sensor_s::MAV_DISTANCE_SENSOR_LASER);
|
||||
}
|
||||
@@ -242,6 +239,7 @@ int TERARANGER::probe()
|
||||
// Can't use a single transfer as Teraranger needs a bit of time for internal processing.
|
||||
if (transfer(&cmd, 1, nullptr, 0) == OK) {
|
||||
if (transfer(nullptr, 0, &who_am_i, 1) == OK && who_am_i == TERARANGER_WHO_AM_I_REG_VAL) {
|
||||
_retries = 1;
|
||||
return measure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ VL53L0X::VL53L0X(const I2CSPIDriverConfig &config) :
|
||||
_px4_rangefinder.set_max_distance(2.f);
|
||||
_px4_rangefinder.set_fov(math::radians(25.f));
|
||||
|
||||
// Allow 3 retries as the device typically misses the first measure attempts.
|
||||
I2C::_retries = 3;
|
||||
// Allow retries as the device typically misses the first measure attempts.
|
||||
I2C::_retries = 1;
|
||||
|
||||
_px4_rangefinder.set_device_type(DRV_DIST_DEVTYPE_VL53L0X);
|
||||
}
|
||||
|
||||
@@ -150,9 +150,6 @@ VL53L1X::VL53L1X(const I2CSPIDriverConfig &config) :
|
||||
_px4_rangefinder.set_max_distance(2.f);
|
||||
_px4_rangefinder.set_fov(math::radians(25.f));
|
||||
|
||||
// Allow 3 retries as the device typically misses the first measure attempts.
|
||||
I2C::_retries = 3;
|
||||
|
||||
_px4_rangefinder.set_device_type(DRV_DIST_DEVTYPE_VL53L1X);
|
||||
}
|
||||
|
||||
@@ -215,6 +212,8 @@ int VL53L1X::probe()
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
_retries = 1;
|
||||
|
||||
return PX4_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user