aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/mpu6000
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-12-16 22:16:51 +1100
committerLorenz Meier <lm@inf.ethz.ch>2013-12-16 15:06:45 +0100
commitbccf65cc28edb8e68b38765c895e9f74604df92e (patch)
tree6df9d2c04b3a953bc8e69d4231af1a58073b3163 /src/drivers/mpu6000
parentd53b00283e4b57611cc7e8c85a4dd1f18629aab0 (diff)
downloadpx4-firmware-bccf65cc28edb8e68b38765c895e9f74604df92e.tar.gz
px4-firmware-bccf65cc28edb8e68b38765c895e9f74604df92e.tar.bz2
px4-firmware-bccf65cc28edb8e68b38765c895e9f74604df92e.zip
mpu6000: disable interrupts during initial reset
this seems to avoid a problem where the mpu6000 doesn't startup correctly if other devices are transferring at the same time.
Diffstat (limited to 'src/drivers/mpu6000')
-rw-r--r--src/drivers/mpu6000/mpu6000.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp
index be4e422b0..bbc595af4 100644
--- a/src/drivers/mpu6000/mpu6000.cpp
+++ b/src/drivers/mpu6000/mpu6000.cpp
@@ -505,17 +505,26 @@ out:
void MPU6000::reset()
{
+ // if the mpu6000 is initialised after the l3gd20 and lsm303d
+ // then if we don't do an irqsave/irqrestore here the mpu6000
+ // frequenctly comes up in a bad state where all transfers
+ // come as zero
+ irqstate_t state;
+ state = irqsave();
- // Chip reset
write_reg(MPUREG_PWR_MGMT_1, BIT_H_RESET);
up_udelay(10000);
- // Wake up device and select GyroZ clock (better performance)
+ // Wake up device and select GyroZ clock. Note that the
+ // MPU6000 starts up in sleep mode, and it can take some time
+ // for it to come out of sleep
write_reg(MPUREG_PWR_MGMT_1, MPU_CLK_SEL_PLLGYROZ);
up_udelay(1000);
// Disable I2C bus (recommended on datasheet)
write_reg(MPUREG_USER_CTRL, BIT_I2C_IF_DIS);
+ irqrestore(state);
+
up_udelay(1000);
// SAMPLE RATE