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
10 changes: 2 additions & 8 deletions lib/lis2mdl/lis2mdl/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,10 +554,7 @@ def soft_reset(self, wait_ms: int = 10):
r = self.read_reg(LIS2MDL_CFG_REG_A)
r |= 1 << 5 # SOFT_RST
self.setReg(r, LIS2MDL_CFG_REG_A)
try:
sleep_ms(wait_ms)
except:
pass
sleep_ms(wait_ms)

def reboot(self, wait_ms: int = 10):
"""
Expand All @@ -567,10 +564,7 @@ def reboot(self, wait_ms: int = 10):
r = self.read_reg(LIS2MDL_CFG_REG_A)
r |= 1 << 6 # REBOOT
self.setReg(r, LIS2MDL_CFG_REG_A)
try:
sleep_ms(wait_ms)
except Exception:
pass
sleep_ms(wait_ms)

def is_idle(self) -> bool:
"""True if the sensor is in IDLE mode (MD1..0 == 11)."""
Expand Down
16 changes: 16 additions & 0 deletions tests/scenarios/lis2mdl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,22 @@ tests:
expect_range: [-10.0, 60.0]
mode: [hardware]

- name: "Soft reset then WHO_AM_I"
action: hardware_script
script: |
dev.soft_reset()
result = dev.read_who_am_i()
expect: 0x40
mode: [hardware]

- name: "Reboot then WHO_AM_I"
action: hardware_script
script: |
dev.reboot()
result = dev.read_who_am_i()
expect: 0x40
mode: [hardware]

- name: "Magnetic field values feel correct"
action: manual
display:
Expand Down
Loading