Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/ism330dl/ism330dl/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ def _ensure_data(self):
if self._is_power_down():
self.configure_accel(self._accel_odr, self._accel_scale)
self.configure_gyro(self._gyro_odr, self._gyro_scale)
sleep_ms(100)
ready_mask = STATUS_XLDA | STATUS_GDA | STATUS_TDA
for _ in range(50):
if (self._read_u8(REG_STATUS_REG) & ready_mask) == ready_mask:
return
sleep_ms(10)
Comment thread
nedseb marked this conversation as resolved.
raise OSError("ISM330DL data ready timeout")
Comment thread
nedseb marked this conversation as resolved.

# --------------------------------------------------
# Raw readings
Expand Down
14 changes: 14 additions & 0 deletions tests/scenarios/ism330dl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,20 @@ tests:
expect_true: true
mode: [mock]

- name: "Timeout raises OSError when data never ready"
action: script
script: |
dev.power_down()
i2c._registers[0x1E] = bytes([0x00])
try:
dev.acceleration_raw()
result = False
except OSError:
result = True
i2c._registers[0x1E] = bytes([0x07])
expect_true: true
mode: [mock]

- name: "Fresh acceleration after power down"
action: script
script: |
Expand Down
Loading