diff options
author | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:43:36 +1100 |
---|---|---|
committer | Andrew Tridgell <andrew@tridgell.net> | 2015-01-01 08:51:40 +1100 |
commit | 1bb3974c8429b2e680d258d37ad42790b608564b (patch) | |
tree | d42a7f2bfde2ff1a2f29bfe2bb4cc205fa4521b5 /src/drivers/l3gd20 | |
parent | 8db206615183a4bd8064734c78554fffab5c1c6d (diff) | |
download | px4-firmware-1bb3974c8429b2e680d258d37ad42790b608564b.tar.gz px4-firmware-1bb3974c8429b2e680d258d37ad42790b608564b.tar.bz2 px4-firmware-1bb3974c8429b2e680d258d37ad42790b608564b.zip |
l3gd20: check DRDY after check_registers() is called
this allows us to recover from an error that disables data ready
Diffstat (limited to 'src/drivers/l3gd20')
-rw-r--r-- | src/drivers/l3gd20/l3gd20.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/drivers/l3gd20/l3gd20.cpp b/src/drivers/l3gd20/l3gd20.cpp index 71a54c0f9..5c9235017 100644 --- a/src/drivers/l3gd20/l3gd20.cpp +++ b/src/drivers/l3gd20/l3gd20.cpp @@ -932,17 +932,6 @@ L3GD20::check_registers(void) void L3GD20::measure() { -#if L3GD20_USE_DRDY - // if the gyro 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 - if (_bus == PX4_SPI_BUS_SENSORS && stm32_gpioread(GPIO_EXTI_GYRO_DRDY) == 0) { - perf_count(_reschedules); - hrt_call_delay(&_call, 100); - return; - } -#endif - /* status register and data as read back from the device */ #pragma pack(push, 1) struct { @@ -962,6 +951,18 @@ L3GD20::measure() check_registers(); +#if L3GD20_USE_DRDY + // if the gyro 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 + if (_bus == PX4_SPI_BUS_SENSORS && stm32_gpioread(GPIO_EXTI_GYRO_DRDY) == 0) { + perf_count(_reschedules); + hrt_call_delay(&_call, 100); + perf_end(_sample_perf); + return; + } +#endif + /* fetch data from the sensor */ memset(&raw_report, 0, sizeof(raw_report)); raw_report.cmd = ADDR_OUT_TEMP | DIR_READ | ADDR_INCREMENT; |