sensord: reset LSM (#35872)

* sensord: reset LSM

* they'll be ready in time

* switch to SW_RESET, BOOT not working for some reason
pull/35874/head
Adeeb Shihadeh 1 week ago committed by GitHub
parent f5991caf6f
commit b695715753
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      system/sensord/sensord.py
  2. 5
      system/sensord/sensors/i2c_sensor.py
  3. 4
      system/sensord/sensors/lsm6ds3_accel.py
  4. 4
      system/sensord/sensors/lsm6ds3_gyro.py

@ -98,6 +98,13 @@ def main() -> None:
(MMC5603NJ_Magn(I2C_BUS_IMU), "magnetometer", False), (MMC5603NJ_Magn(I2C_BUS_IMU), "magnetometer", False),
] ]
# Reset sensors
for sensor, _, _ in sensors_cfg:
try:
sensor.reset()
except Exception:
cloudlog.exception(f"Error initializing {sensor} sensor")
# Initialize sensors # Initialize sensors
exit_event = threading.Event() exit_event = threading.Event()
threads = [ threads = [

@ -40,6 +40,11 @@ class Sensor:
def device_address(self) -> int: def device_address(self) -> int:
raise NotImplementedError raise NotImplementedError
def reset(self) -> None:
# optional.
# not part of init due to shared registers
pass
def init(self) -> None: def init(self) -> None:
raise NotImplementedError raise NotImplementedError

@ -31,6 +31,10 @@ class LSM6DS3_Accel(Sensor):
def device_address(self) -> int: def device_address(self) -> int:
return 0x6A return 0x6A
def reset(self):
self.write(0x12, 0x1)
time.sleep(0.1)
def init(self): def init(self):
chip_id = self.verify_chip_id(0x0F, [0x69, 0x6A]) chip_id = self.verify_chip_id(0x0F, [0x69, 0x6A])
if chip_id == 0x6A: if chip_id == 0x6A:

@ -29,6 +29,10 @@ class LSM6DS3_Gyro(Sensor):
def device_address(self) -> int: def device_address(self) -> int:
return 0x6A return 0x6A
def reset(self):
self.write(0x12, 0x1)
time.sleep(0.1)
def init(self): def init(self):
chip_id = self.verify_chip_id(0x0F, [0x69, 0x6A]) chip_id = self.verify_chip_id(0x0F, [0x69, 0x6A])
if chip_id == 0x6A: if chip_id == 0x6A:

Loading…
Cancel
Save