mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 08:53:34 +08:00
ll40ls: correct a write_reg issue (#12604)
* deprecate a goto statement * migrate to uniform initialization in LidarLite base class.
This commit is contained in:
@@ -137,7 +137,8 @@ LidarLiteI2C::probe()
|
||||
if (read_reg(LL40LS_UNIT_ID_HIGH, id_high) == OK &&
|
||||
read_reg(LL40LS_UNIT_ID_LOW, id_low) == OK) {
|
||||
_unit_id = (uint16_t)((id_high << 8) | id_low) & 0xFFFF;
|
||||
goto ok;
|
||||
_retries = 3;
|
||||
return reset_sensor();
|
||||
}
|
||||
|
||||
PX4_DEBUG("probe failed unit_id=0x%02x", (unsigned)_unit_id);
|
||||
@@ -149,22 +150,17 @@ LidarLiteI2C::probe()
|
||||
*/
|
||||
if (read_reg(LL40LS_HW_VERSION, _hw_version) == OK && _hw_version > 0 &&
|
||||
read_reg(LL40LS_SW_VERSION, _sw_version) == OK && _sw_version > 0) {
|
||||
|
||||
_px4_rangefinder.set_max_distance(LL40LS_MAX_DISTANCE_V1);
|
||||
goto ok;
|
||||
_retries = 3;
|
||||
return reset_sensor();
|
||||
}
|
||||
|
||||
PX4_DEBUG("probe failed hw_version=0x%02x sw_version=0x%02x", (unsigned)_hw_version, (unsigned)_sw_version);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// not found on any address
|
||||
return -EIO;
|
||||
|
||||
ok:
|
||||
_retries = 3;
|
||||
return reset_sensor();
|
||||
}
|
||||
|
||||
int
|
||||
@@ -180,8 +176,7 @@ LidarLiteI2C::measure()
|
||||
/*
|
||||
* Send the command to begin a measurement.
|
||||
*/
|
||||
const uint8_t cmd[2] = { LL40LS_MEASURE_REG, LL40LS_MSRREG_ACQUIRE };
|
||||
int ret = lidar_transfer(cmd, sizeof(cmd), nullptr, 0);
|
||||
int ret = write_reg(LL40LS_MEASURE_REG, LL40LS_MSRREG_ACQUIRE);
|
||||
|
||||
if (OK != ret) {
|
||||
perf_count(_comms_errors);
|
||||
|
||||
Reference in New Issue
Block a user