altos: Check for MS5607 MISO low before sleeping
authorKeith Packard <keithp@keithp.com>
Tue, 27 Aug 2013 01:43:20 +0000 (18:43 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 27 Aug 2013 01:47:27 +0000 (18:47 -0700)
If the MISO line goes low before we manage to configure the
interrupts, we'll miss it entirely unless we check the pin explicitly.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/attiny/ao_arch_funcs.h
src/cc1111/ao_arch_funcs.h
src/drivers/ao_ms5607.c
src/telemini-v2.0/ao_pins.h

index 76dc7820a0d2460d583b74696a28d993bd1e8079..d4584a9fc1eeeb2dd028948ce3d78e427acd57ee 100644 (file)
@@ -41,6 +41,8 @@
                        PORTB &= ~(1 << bit);   \
        } while (0)
 
+#define ao_gpio_get(port, bit, pin)    ((PORTB >> (bit)) & 1)
+
 /*
  * The SPI mutex must be held to call either of these
  * functions -- this mutex covers the entire SPI operation,
index ae1841089c0a59383b6919c7fcd424a5c9bfd7e6..ea340dfd56901194b9534a600fb146fbbdef1be4 100644 (file)
@@ -145,4 +145,5 @@ ao_spi_init(void);
 
 #define ao_enable_output(port,bit,pin,v) cc1111_enable_output(port,token_evaluator(port,DIR), token_evaluator(port,SEL), pin, bit, v)
 #define ao_gpio_set(port, bit, pin, v) ((pin) = (v))
+#define ao_gpio_get(port, bit, pin) (pin)
 
index 8b2b633310619ef6d5017718f6ff5c9accf51a2b..58ab91973ce0b63b5a51c0e6b053a1b903d10fa8 100644 (file)
@@ -140,7 +140,8 @@ ao_ms5607_get_sample(uint8_t cmd) {
        ao_spi_put(AO_MS5607_SPI_INDEX);
 #endif
        ao_arch_block_interrupts();
-       while (!ao_ms5607_done)
+       while (!ao_gpio_get(AO_MS5607_MISO_PORT, AO_MS5607_MISO_PIN, AO_MS5607_MISO) &&
+              !ao_ms5607_done)
                ao_sleep((void *) &ao_ms5607_done);
        ao_arch_release_interrupts();
 #if AO_MS5607_PRIVATE_PINS
index c1a36f8c0c0bd4852fec2351722468f87f5a6607..264ad16d9154172d65d544f5cf0e71da7d134d33 100644 (file)
@@ -74,6 +74,7 @@
 #define AO_MS5607_CS_MASK      (1 << AO_MS5607_CS_PIN)
 #define AO_MS5607_MISO_PORT    P0
 #define AO_MS5607_MISO_PIN     2
+#define AO_MS5607_MISO         P0_2
 #define AO_MS5607_MISO_MASK    (1 << AO_MS5607_MISO_PIN)
 #define AO_MS5607_SPI_INDEX    0
 #define HAS_EXTI_0             1