aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/l3gd20
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/l3gd20')
-rw-r--r--src/drivers/l3gd20/l3gd20.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/drivers/l3gd20/l3gd20.cpp b/src/drivers/l3gd20/l3gd20.cpp
index e6d765e13..970e8cf4b 100644
--- a/src/drivers/l3gd20/l3gd20.cpp
+++ b/src/drivers/l3gd20/l3gd20.cpp
@@ -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;
}