ll40ls: [Wingtra docet] fix for properly resetting v3 and v3hp modules.

Signed-off-by: Claudio Micheli <claudio@auterion.com>
This commit is contained in:
Claudio Micheli 2019-08-20 11:14:27 +02:00 committed by Nuno Marques
parent 7799f4c68b
commit 5eefd9409b
2 changed files with 23 additions and 1 deletions

View File

@ -212,12 +212,33 @@ LidarLiteI2C::measure()
int
LidarLiteI2C::reset_sensor()
{
int ret = write_reg(LL40LS_MEASURE_REG, LL40LS_MSRREG_RESET);
int ret;
px4_usleep(15000);
ret = write_reg(LL40LS_SIG_COUNT_VAL_REG, LL40LS_SIG_COUNT_VAL_MAX);
if (ret != OK) {
return ret;
}
px4_usleep(15000);
ret = write_reg(LL40LS_MEASURE_REG, LL40LS_MSRREG_RESET);
if (ret != 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)) {
printf("Error: ll40ls reset failure. Exiting!\n");
return ret;
}
}
// wait for sensor reset to complete
px4_usleep(50000);
ret = write_reg(LL40LS_SIG_COUNT_VAL_REG, LL40LS_SIG_COUNT_VAL_MAX);

View File

@ -49,6 +49,7 @@
/* 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 */
/* LL40LS Registers addresses */
static constexpr uint8_t LL40LS_MEASURE_REG = 0x00; /* Measure range register */