altos: mpu6000 requires a delay during start
authorKeith Packard <keithp@keithp.com>
Wed, 27 Jun 2012 08:17:51 +0000 (01:17 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 27 Jun 2012 08:17:51 +0000 (01:17 -0700)
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>
src/stm/ao_i2c_stm.c

index c205706d37669390bfec37081031abfd6bd61b6f..12b9e8b46094cfc0a036819a249190b250467330 100644 (file)
@@ -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
 }
-