l3gd20: added retries to disable_i2c()

This commit is contained in:
Andrew Tridgell 2013-12-05 09:06:53 +11:00 committed by Lorenz Meier
parent 476070510e
commit 86ec1c37fa
1 changed files with 10 additions and 2 deletions

View File

@ -715,8 +715,16 @@ L3GD20::stop()
void void
L3GD20::disable_i2c(void) L3GD20::disable_i2c(void)
{ {
uint8_t a = read_reg(0x05); uint8_t retries = 10;
write_reg(0x05, (0x20 | a)); while (retries--) {
// add retries
uint8_t a = read_reg(0x05);
write_reg(0x05, (0x20 | a));
if (read_reg(0x05) == (a | 0x20)) {
return;
}
}
debug("FAILED TO DISABLE I2C");
} }
void void