drivers: minimize additional I2C retries

This commit is contained in:
Daniel Agar
2021-08-17 09:54:50 -04:00
parent 8a8171c7aa
commit cb610caf1e
18 changed files with 44 additions and 109 deletions
@@ -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();
}
}