diff options
author | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:46:13 +1100 |
---|---|---|
committer | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:51:52 +1100 |
commit | 083d9e3e698e794640ac216959ba34157609e6e1 (patch) | |
tree | ae3a915bcd3eb7f79671fc4f2d572eb7bbe2f5de /src/drivers/lsm303d | |
parent | 1de7fab974b21afdc43caaeb6c8ecdf2ac88cc10 (diff) | |
download | px4-firmware-083d9e3e698e794640ac216959ba34157609e6e1.tar.gz px4-firmware-083d9e3e698e794640ac216959ba34157609e6e1.tar.bz2 px4-firmware-083d9e3e698e794640ac216959ba34157609e6e1.zip |
lsm303d: check DRDY after check_registers()
this allows recovery from a state where DRDY is not set
Diffstat (limited to 'src/drivers/lsm303d')
-rw-r--r-- | src/drivers/lsm303d/lsm303d.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/drivers/lsm303d/lsm303d.cpp b/src/drivers/lsm303d/lsm303d.cpp index 58dcdf410..3e5ff1f7c 100644 --- a/src/drivers/lsm303d/lsm303d.cpp +++ b/src/drivers/lsm303d/lsm303d.cpp @@ -1437,19 +1437,6 @@ LSM303D::check_registers(void) void LSM303D::measure() { - // if the accel doesn't have any data ready then re-schedule - // for 100 microseconds later. This ensures we don't double - // read a value and then miss the next value. - // Note that DRDY is not available when the lsm303d is - // connected on the external bus -#ifdef GPIO_EXTI_ACCEL_DRDY - if (_bus == PX4_SPI_BUS_SENSORS && stm32_gpioread(GPIO_EXTI_ACCEL_DRDY) == 0) { - perf_count(_accel_reschedules); - hrt_call_delay(&_accel_call, 100); - return; - } -#endif - /* status register and data as read back from the device */ #pragma pack(push, 1) @@ -1469,6 +1456,20 @@ LSM303D::measure() check_registers(); + // if the accel doesn't have any data ready then re-schedule + // for 100 microseconds later. This ensures we don't double + // read a value and then miss the next value. + // Note that DRDY is not available when the lsm303d is + // connected on the external bus +#ifdef GPIO_EXTI_ACCEL_DRDY + if (_bus == PX4_SPI_BUS_SENSORS && stm32_gpioread(GPIO_EXTI_ACCEL_DRDY) == 0) { + perf_count(_accel_reschedules); + hrt_call_delay(&_accel_call, 100); + perf_end(_accel_sample_perf); + return; + } +#endif + if (_register_wait != 0) { // we are waiting for some good transfers before using // the sensor again. |