From 90230309313719fc742773253eaead7602e752ac Mon Sep 17 00:00:00 2001 From: mcsauder Date: Wed, 18 Sep 2019 10:51:48 -0600 Subject: [PATCH] LidarLite driver minor comment updates/formatting and change instances of OK to PX4_OK. --- .../distance_sensor/ll40ls/LidarLiteI2C.cpp | 12 ++--- .../distance_sensor/ll40ls/LidarLiteI2C.h | 50 +++++++++---------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.cpp b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.cpp index 0300de0a9c..f083d2f972 100644 --- a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.cpp +++ b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.cpp @@ -201,13 +201,11 @@ LidarLiteI2C::measure() int LidarLiteI2C::reset_sensor() { - int ret; - px4_usleep(15000); - ret = write_reg(LL40LS_SIG_COUNT_VAL_REG, LL40LS_SIG_COUNT_VAL_MAX); + int ret = write_reg(LL40LS_SIG_COUNT_VAL_REG, LL40LS_SIG_COUNT_VAL_MAX); - if (ret != OK) { + if (ret != PX4_OK) { return ret; } @@ -215,13 +213,13 @@ LidarLiteI2C::reset_sensor() ret = write_reg(LL40LS_MEASURE_REG, LL40LS_MSRREG_RESET); - if (ret != OK) { + if (ret != PX4_OK) { uint8_t sig_cnt; px4_usleep(15000); ret = read_reg(LL40LS_SIG_COUNT_VAL_REG, sig_cnt); - if ((ret != OK) || (sig_cnt != LL40LS_SIG_COUNT_VAL_DEFAULT)) { + if ((ret != PX4_OK) || (sig_cnt != LL40LS_SIG_COUNT_VAL_DEFAULT)) { PX4_INFO("Error: ll40ls reset failure. Exiting!\n"); return ret; @@ -232,7 +230,7 @@ LidarLiteI2C::reset_sensor() px4_usleep(50000); ret = write_reg(LL40LS_SIG_COUNT_VAL_REG, LL40LS_SIG_COUNT_VAL_MAX); - if (ret != OK) { + if (ret != PX4_OK) { return ret; } diff --git a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h index d376280cf2..d4dfef014e 100644 --- a/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h +++ b/src/drivers/distance_sensor/ll40ls/LidarLiteI2C.h @@ -50,34 +50,32 @@ /* Configuration Constants */ -static constexpr uint8_t LL40LS_BASEADDR = 0x62; /* 7-bit address */ -static constexpr uint8_t LL40LS_BASEADDR_OLD = 0x42; /* previous 7-bit address */ -static constexpr uint8_t LL40LS_SIG_COUNT_VAL_DEFAULT = 0x80; /* Default maximum acquisition count */ +static constexpr uint8_t LL40LS_BASEADDR = 0x62; /* 7-bit address */ +static constexpr uint8_t LL40LS_BASEADDR_OLD = 0x42; /* previous 7-bit address */ +static constexpr uint8_t LL40LS_SIG_COUNT_VAL_DEFAULT = 0x80; /* Default maximum acquisition count */ /* LL40LS Registers addresses */ -static constexpr uint8_t LL40LS_MEASURE_REG = 0x00; /* Measure range register */ -static constexpr uint8_t LL40LS_MSRREG_RESET = 0x00; /* reset to power on defaults */ -static constexpr uint8_t LL40LS_MSRREG_ACQUIRE = - 0x04; /* Value to initiate a measurement, varies based on sensor revision */ -static constexpr uint8_t LL40LS_DISTHIGH_REG = 0x0F; /* High byte of distance register, auto increment */ -static constexpr uint8_t LL40LS_AUTO_INCREMENT = 0x80; -static constexpr uint8_t LL40LS_HW_VERSION = 0x41; -static constexpr uint8_t LL40LS_SW_VERSION = 0x4f; -static constexpr uint8_t LL40LS_SIGNAL_STRENGTH_REG = 0x0e; -static constexpr uint8_t LL40LS_PEAK_STRENGTH_REG = 0x0c; -static constexpr uint8_t LL40LS_UNIT_ID_HIGH = 0x16; -static constexpr uint8_t LL40LS_UNIT_ID_LOW = 0x17; - -static constexpr uint8_t LL40LS_SIG_COUNT_VAL_REG = 0x02; /* Maximum acquisition count register */ -static constexpr uint8_t LL40LS_SIG_COUNT_VAL_MAX = 0xFF; /* Maximum acquisition count max value */ - -static constexpr int LL40LS_SIGNAL_STRENGTH_MIN_V3HP = 70; /* Min signal strength for V3HP */ -static constexpr int LL40LS_SIGNAL_STRENGTH_MAX_V3HP = 255; /* Max signal strength for V3HP */ -static constexpr int LL40LS_SIGNAL_STRENGTH_LOW = - 24; /* Minimum (relative) signal strength value for accepting a measurement */ -static constexpr int LL40LS_PEAK_STRENGTH_LOW = - 135; /* Minimum peak strength raw value for accepting a measurement */ -static constexpr int LL40LS_PEAK_STRENGTH_HIGH = 234; /* Max peak strength raw value */ +static constexpr uint8_t LL40LS_MEASURE_REG = 0x00; /* Measure range register */ +static constexpr uint8_t LL40LS_MSRREG_RESET = 0x00; /* reset to power on defaults */ +static constexpr uint8_t LL40LS_MSRREG_ACQUIRE = 0x04; /* Value to acquire a measurement, version specific */ +static constexpr uint8_t LL40LS_DISTHIGH_REG = 0x0F; /* High byte of distance register, auto increment */ +static constexpr uint8_t LL40LS_AUTO_INCREMENT = 0x80; +static constexpr uint8_t LL40LS_HW_VERSION = 0x41; +static constexpr uint8_t LL40LS_SW_VERSION = 0x4f; +static constexpr uint8_t LL40LS_SIGNAL_STRENGTH_REG = 0x0e; +static constexpr uint8_t LL40LS_PEAK_STRENGTH_REG = 0x0c; +static constexpr uint8_t LL40LS_UNIT_ID_HIGH = 0x16; +static constexpr uint8_t LL40LS_UNIT_ID_LOW = 0x17; + +static constexpr uint8_t LL40LS_SIG_COUNT_VAL_REG = 0x02; /* Maximum acquisition count register */ +static constexpr uint8_t LL40LS_SIG_COUNT_VAL_MAX = 0xFF; /* Maximum acquisition count max value */ + +static constexpr int LL40LS_SIGNAL_STRENGTH_MIN_V3HP = 70; /* Min signal strength for V3HP */ +static constexpr int LL40LS_SIGNAL_STRENGTH_MAX_V3HP = 255; /* Max signal strength for V3HP */ + +static constexpr int LL40LS_SIGNAL_STRENGTH_LOW = 24; /* Minimum relative signal strength for a valid measurement */ +static constexpr int LL40LS_PEAK_STRENGTH_LOW = 135; /* Minimum peak strength raw value for accepting a measurement */ +static constexpr int LL40LS_PEAK_STRENGTH_HIGH = 234; /* Max peak strength raw value */ class LidarLiteI2C : public LidarLite, public device::I2C, public px4::ScheduledWorkItem