summaryrefslogtreecommitdiff
path: root/src/stm/ao_arch_funcs.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-05-14 10:48:24 -0700
committerKeith Packard <keithp@keithp.com>2013-05-15 22:13:08 -0700
commit0571531066918fdefe9447f3b4192d0c6c477afa (patch)
tree56baba6c8640d7c243a9fb7bea8f73f57747b7b0 /src/stm/ao_arch_funcs.h
parent9beacd77b3e8106e036e50a67312dfee414fbc51 (diff)
altos: Grab SPI mutex until MPU6000 I2C mode is disabled
If other drivers use the SPI bus, the MPU6000 gets confused as its sitting on the bus looking for I2C messages. Just grab the mutex before the OS is running and hold onto it until the MPU6000 has been initialized. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/ao_arch_funcs.h')
-rw-r--r--src/stm/ao_arch_funcs.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h
index 1e78cabc..6fe86e62 100644
--- a/src/stm/ao_arch_funcs.h
+++ b/src/stm/ao_arch_funcs.h
@@ -87,13 +87,16 @@ extern uint16_t ao_spi_speed[STM_NUM_SPI];
void
ao_spi_init(void);
+#define ao_spi_set_cs(reg,mask) ((reg)->bsrr = ((uint32_t) (mask)) << 16)
+#define ao_spi_clr_cs(reg,mask) ((reg)->bsrr = (mask))
+
#define ao_spi_get_mask(reg,mask,bus, speed) do { \
ao_spi_get(bus, speed); \
- (reg)->bsrr = ((uint32_t) mask) << 16; \
+ ao_spi_set_cs(reg,mask); \
} while (0)
#define ao_spi_put_mask(reg,mask,bus) do { \
- (reg)->bsrr = mask; \
+ ao_spi_clr_cs(reg,mask); \
ao_spi_put(bus); \
} while (0)