Skip to content

Commit f1878d1

Browse files
committed
ism330dl: Use polling with timeout in _ensure_data().
1 parent 5ab56ef commit f1878d1

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

lib/ism330dl/ism330dl/device.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ def _ensure_data(self):
137137
if self._is_power_down():
138138
self.configure_accel(self._accel_odr, self._accel_scale)
139139
self.configure_gyro(self._gyro_odr, self._gyro_scale)
140-
sleep_ms(100)
140+
for _ in range(50):
141+
s = self._read_u8(REG_STATUS_REG)
142+
if s & STATUS_XLDA:
143+
return
144+
sleep_ms(10)
145+
raise OSError("ISM330DL data ready timeout")
141146

142147
# --------------------------------------------------
143148
# Raw readings

0 commit comments

Comments
 (0)