Skip to content

Commit b12726f

Browse files
committed
Release I2C bus pins for bus reset
1 parent 8e73e05 commit b12726f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/modulino/modulino.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ def reset_bus(i2c_bus):
5555
# This is a workaround to get the SCL and SDA pins from a given bus object.
5656
# Unfortunately the I2C class does not expose those attributes directly.
5757
interface, scl_pin_number, sda_pin_number = I2CHelper.extract_i2c_info(i2c_bus)
58+
59+
scl_pin = Pin(scl_pin_number, Pin.IN) # Detach pin from I2C
60+
sda_pin = Pin(sda_pin_number, Pin.IN) # Detach pin from I2C
61+
5862
scl_pin = Pin(scl_pin_number, Pin.OUT)
5963
sda_pin = Pin(sda_pin_number, Pin.OUT)
6064

@@ -243,7 +247,10 @@ def has_default_address(self):
243247
@staticmethod
244248
def available_devices():
245249
"""
246-
Finds all devices on the i2c bus and returns a list of Modulino objects.
250+
Finds all devices on the i2c bus and returns them as a list of Modulino objects.
251+
252+
Returns:
253+
list: A list of Modulino objects.
247254
"""
248255
bus = I2CHelper.get_interface()
249256
device_addresses = bus.scan()
@@ -260,8 +267,7 @@ def reset_bus(i2c_bus):
260267
The modulinos that are equipped with a micro controller use DMA operations.
261268
If the host board does a reset during such operation it can make the bus get stuck.
262269
263-
Returns
264-
----
270+
Returns:
265271
I2C: A new i2c bus object after resetting the bus.
266272
"""
267273
return I2CHelper.reset_bus(i2c_bus)

0 commit comments

Comments
 (0)