Skip to content

Commit d3d6bac

Browse files
committed
added check to correct i2C reading
Added wait for ONE_SHOT bit to be cleared by the hardware for correct read of measurement
1 parent 5c0ba35 commit d3d6bac

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/BARO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ float LPS22HBClass::readPressure(int units)
5757
// trigger one shot
5858
i2cWrite(LPS22HB_CTRL2_REG, 0x01);
5959

60-
// wait for completion
61-
while ((i2cRead(LPS22HB_STATUS_REG) & 0x02) == 0) {
60+
// wait for ONE_SHOT bit to be cleared by the hardware
61+
while ((i2cRead(LPS22HB_CTRL2_REG) & 0x01) != 0) {
6262
yield();
6363
}
6464

0 commit comments

Comments
 (0)