diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-27 01:17:51 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-27 01:17:51 -0700 |
commit | 0285696e5280fc64774b6c3a2fcdaa36bd36ae7c (patch) | |
tree | c7a98083107ef85061293baa9a7d457f11883350 | |
parent | 4847595e0383e5ff9c5a373f3c7f2af8c210c50a (diff) |
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 <keithp@keithp.com>
-rw-r--r-- | src/stm/ao_i2c_stm.c | 11 |
1 files changed, 10 insertions, 1 deletions
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 } - |