diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-11-28 20:30:04 +1100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2013-12-10 12:00:02 +0100 |
commit | 7c9d92a5d64ee4b2282139a49e189df434ec00f1 (patch) | |
tree | abe56ab6499c688e6cf6b24420d94ef1c0a017bd | |
parent | 9a169d8ef453aea1729b76940b10733591c4c6d8 (diff) | |
download | px4-firmware-7c9d92a5d64ee4b2282139a49e189df434ec00f1.tar.gz px4-firmware-7c9d92a5d64ee4b2282139a49e189df434ec00f1.tar.bz2 px4-firmware-7c9d92a5d64ee4b2282139a49e189df434ec00f1.zip |
lsm303d: added I2C disable based on method from ST engineering support
-rw-r--r-- | src/drivers/lsm303d/lsm303d.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/drivers/lsm303d/lsm303d.cpp b/src/drivers/lsm303d/lsm303d.cpp index bfa129364..da981989c 100644 --- a/src/drivers/lsm303d/lsm303d.cpp +++ b/src/drivers/lsm303d/lsm303d.cpp @@ -323,6 +323,11 @@ private: void reset(); /** + * disable I2C on the chip + */ + void disable_i2c(); + + /** * Static trampoline from the hrt_call context; because we don't have a * generic hrt wrapper yet. * @@ -596,8 +601,24 @@ out: } void +LSM303D::disable_i2c(void) +{ + uint8_t a = read_reg(0x02); + write_reg(0x02, (0x10 | a)); + a = read_reg(0x02); + write_reg(0x02, (0xF7 & a)); + a = read_reg(0x15); + write_reg(0x15, (0x80 | a)); + a = read_reg(0x02); + write_reg(0x02, (0xE7 & a)); +} + +void LSM303D::reset() { + // ensure the chip doesn't interpret any other bus traffic as I2C + disable_i2c(); + /* enable accel*/ _reg1_expected = REG1_X_ENABLE_A | REG1_Y_ENABLE_A | REG1_Z_ENABLE_A | REG1_BDU_UPDATE | REG1_RATE_800HZ_A; write_reg(ADDR_CTRL_REG1, _reg1_expected); |