Guard probe / reset against other SPI drivers

This commit is contained in:
Lorenz Meier
2013-09-11 22:16:29 +02:00
parent 8755d76d1b
commit 3a326cb467
2 changed files with 26 additions and 6 deletions
+11 -2
View File
@@ -377,9 +377,12 @@ out:
int
L3GD20::probe()
{
irqstate_t flags = irqsave();
/* read dummy value to void to clear SPI statemachine on sensor */
(void)read_reg(ADDR_WHO_AM_I);
bool success = false;
/* verify that the device is attached and functioning, accept L3GD20 and L3GD20H */
if (read_reg(ADDR_WHO_AM_I) == WHO_I_AM) {
@@ -390,15 +393,21 @@ L3GD20::probe()
#else
#error This driver needs a board selection, either CONFIG_ARCH_BOARD_PX4FMU_V1 or CONFIG_ARCH_BOARD_PX4FMU_V2
#endif
return OK;
success = true;
}
if (read_reg(ADDR_WHO_AM_I) == WHO_I_AM_H) {
_orientation = SENSOR_BOARD_ROTATION_180_DEG;
return OK;
success = true;
}
irqrestore(flags);
if (success)
return OK;
return -EIO;
}