mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 13:58:53 +08:00
drivers: minimize additional I2C retries
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user