altos: Add timeout for MS5607 ADC conversion samd21
authorKeith Packard <keithp@keithp.com>
Sun, 4 Dec 2022 22:17:58 +0000 (14:17 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 4 Dec 2022 22:19:52 +0000 (14:19 -0800)
The MS5607 should signal conversion done by pulling MISO low, but in
case it doesn't, add a 10ms timeout to wake up after the conversion
should be done.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_ms5607.c

index 1cddcaf570e540656a2e42b2550a299167c82422..895e1d3492173815ef2100e94a3be32cb5007795 100644 (file)
@@ -169,7 +169,10 @@ ao_ms5607_get_sample(uint8_t cmd) {
        ao_arch_block_interrupts();
        while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN) &&
               !ao_ms5607_done)
-               ao_sleep((void *) &ao_ms5607_done);
+       {
+               if (ao_sleep_for((void *) &ao_ms5607_done, AO_MS_TO_TICKS(10)))
+                       break;
+       }
        ao_arch_release_interrupts();
 #if AO_MS5607_PRIVATE_PINS
        ao_gpio_set(AO_MS5607_CS_PORT, AO_MS5607_CS_PIN, 1);