summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-08-26 18:43:20 -0700
committerKeith Packard <keithp@keithp.com>2013-08-26 18:47:27 -0700
commit7e941695aa27e5eaf453ca1128b8d835472410a4 (patch)
treeba7c86e1d160824330cb584e4809ac828309e052
parent9b9acb88aa97e8565cdf9342fc59a5aee08e3d34 (diff)
altos: Check for MS5607 MISO low before sleeping
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>
-rw-r--r--src/attiny/ao_arch_funcs.h2
-rw-r--r--src/cc1111/ao_arch_funcs.h1
-rw-r--r--src/drivers/ao_ms5607.c3
-rw-r--r--src/telemini-v2.0/ao_pins.h1
4 files changed, 6 insertions, 1 deletions
diff --git a/src/attiny/ao_arch_funcs.h b/src/attiny/ao_arch_funcs.h
index 76dc7820..d4584a9f 100644
--- a/src/attiny/ao_arch_funcs.h
+++ b/src/attiny/ao_arch_funcs.h
@@ -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,
diff --git a/src/cc1111/ao_arch_funcs.h b/src/cc1111/ao_arch_funcs.h
index ae184108..ea340dfd 100644
--- a/src/cc1111/ao_arch_funcs.h
+++ b/src/cc1111/ao_arch_funcs.h
@@ -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)
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c
index 8b2b6333..58ab9197 100644
--- a/src/drivers/ao_ms5607.c
+++ b/src/drivers/ao_ms5607.c
@@ -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
diff --git a/src/telemini-v2.0/ao_pins.h b/src/telemini-v2.0/ao_pins.h
index c1a36f8c..264ad16d 100644
--- a/src/telemini-v2.0/ao_pins.h
+++ b/src/telemini-v2.0/ao_pins.h
@@ -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