From: Keith Packard Date: Sun, 4 Dec 2022 22:17:58 +0000 (-0800) Subject: altos: Add timeout for MS5607 ADC conversion X-Git-Tag: 1.9.13~1^2~24 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=da253f1ee9510fba93ddf5c1895570eb5081af46 altos: Add timeout for MS5607 ADC conversion 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 --- diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 1cddcaf5..895e1d34 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -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);