Skip to content

Commit

Permalink
Release I2C bus pins for bus reset
Browse files Browse the repository at this point in the history
  • Loading branch information
sebromero committed Oct 25, 2024
1 parent 8e73e05 commit b12726f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/modulino/modulino.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def reset_bus(i2c_bus):
# This is a workaround to get the SCL and SDA pins from a given bus object.
# Unfortunately the I2C class does not expose those attributes directly.
interface, scl_pin_number, sda_pin_number = I2CHelper.extract_i2c_info(i2c_bus)

scl_pin = Pin(scl_pin_number, Pin.IN) # Detach pin from I2C
sda_pin = Pin(sda_pin_number, Pin.IN) # Detach pin from I2C

scl_pin = Pin(scl_pin_number, Pin.OUT)
sda_pin = Pin(sda_pin_number, Pin.OUT)

Expand Down Expand Up @@ -243,7 +247,10 @@ def has_default_address(self):
@staticmethod
def available_devices():
"""
Finds all devices on the i2c bus and returns a list of Modulino objects.
Finds all devices on the i2c bus and returns them as a list of Modulino objects.
Returns:
list: A list of Modulino objects.
"""
bus = I2CHelper.get_interface()
device_addresses = bus.scan()
Expand All @@ -260,8 +267,7 @@ def reset_bus(i2c_bus):
The modulinos that are equipped with a micro controller use DMA operations.
If the host board does a reset during such operation it can make the bus get stuck.
Returns
----
Returns:
I2C: A new i2c bus object after resetting the bus.
"""
return I2CHelper.reset_bus(i2c_bus)

0 comments on commit b12726f

Please sign in to comment.