AP_RangeFinder_PulsedLightLRF: Modified to do a 2 byte transfer for the distance read

This commit is contained in:
akdslr 2014-07-17 10:34:13 -04:00 committed by Andrew Tridgell
parent b08e3d0ee4
commit a1861125e6
2 changed files with 3 additions and 11 deletions

View File

@ -83,16 +83,9 @@ bool AP_RangeFinder_PulsedLightLRF::get_reading(uint16_t &reading_cm)
return false; return false;
} }
// read the high byte // read the high and low byte distance registers
if (hal.i2c->readRegisters(AP_RANGEFINDER_PULSEDLIGHTLRF_ADDR, if (hal.i2c->readRegisters(AP_RANGEFINDER_PULSEDLIGHTLRF_ADDR,
AP_RANGEFINDER_PULSEDLIGHTLRF_DISTHIGH_REG, 1, &buff[0]) != 0) { AP_RANGEFINDER_PULSEDLIGHTLRF_DISTHIGH_REG, 2, &buff[0]) != 0) {
i2c_sem->give();
return false;
}
hal.scheduler->delay_microseconds(200);
// read the low byte
if (hal.i2c->readRegisters(AP_RANGEFINDER_PULSEDLIGHTLRF_ADDR,
AP_RANGEFINDER_PULSEDLIGHTLRF_DISTLOW_REG, 1, &buff[1]) != 0) {
i2c_sem->give(); i2c_sem->give();
return false; return false;
} }

View File

@ -33,8 +33,7 @@
// registers // registers
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MEASURE_REG 0x00 #define AP_RANGEFINDER_PULSEDLIGHTLRF_MEASURE_REG 0x00
#define AP_RANGEFINDER_PULSEDLIGHTLRF_DISTHIGH_REG 0x0f // high byte of distance measurement #define AP_RANGEFINDER_PULSEDLIGHTLRF_DISTHIGH_REG 0x8f // high byte of distance measurement
#define AP_RANGEFINDER_PULSEDLIGHTLRF_DISTLOW_REG 0x10 // low byte of distance measurement
// command register values // command register values
#define AP_RANGEFINDER_PULSEDLIGHTLRF_MSRREG_ACQUIRE 0x04 // Varies based on sensor revision, 0x04 is newest, 0x61 is older #define AP_RANGEFINDER_PULSEDLIGHTLRF_MSRREG_ACQUIRE 0x04 // Varies based on sensor revision, 0x04 is newest, 0x61 is older