From 0285696e5280fc64774b6c3a2fcdaa36bd36ae7c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 27 Jun 2012 01:17:51 -0700 Subject: [PATCH] altos: mpu6000 requires a delay during start I have no idea why this is required, but the mpu6000 will not come up and run if this isn't present. Signed-off-by: Keith Packard --- src/stm/ao_i2c_stm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stm/ao_i2c_stm.c b/src/stm/ao_i2c_stm.c index c205706d..12b9e8b4 100644 --- a/src/stm/ao_i2c_stm.c +++ b/src/stm/ao_i2c_stm.c @@ -136,6 +136,15 @@ ao_i2c_put(uint8_t index) ao_mutex_put(&ao_i2c_mutex[index]); } +static inline void +ao_i2c_delay(void) +{ + uint8_t i; + + for (i = 0; i < 10; i++) + ao_arch_nop(); +} + #define I2C_DEBUG 0 #if I2C_DEBUG #define DBG(x...) printf(x) @@ -194,6 +203,7 @@ ao_i2c_start(uint8_t index, uint16_t addr) out_cr2("start", stm_i2c, AO_STM_I2C_CR2); out_cr1("start", stm_i2c, AO_STM_I2C_CR1 | (1 << STM_I2C_CR1_START)); + ao_i2c_delay(); out_cr2("start", stm_i2c, AO_STM_I2C_CR2 | (1 << STM_I2C_CR2_ITEVTEN) | (1 << STM_I2C_CR2_ITERREN)); ao_alarm(1); @@ -429,4 +439,3 @@ ao_i2c_init(void) stm_nvic_set_priority(STM_ISR_I2C2_ER_POS, 3); #endif } - -- 2.30.2