I'd need the option of specifying my I2C bus on raspberry pi 4, as I need to use a different one for my IMU. Now I could use specific bus like 3 or 4, with minimal code changes.
below init changes would be needed in src/busio.py
Intention is to only have effect when "bus_id" is defined.
def __init__(self, scl, sda, frequency=400000, bus_id=None):
self.init(scl, sda, frequency, bus_id)
def init(self, scl, sda, frequency, bus_id):
self.deinit()
if detector.board.ftdi_ft232h:
from adafruit_blinka.microcontroller.ft232h.i2c import I2C
self._i2c = I2C(frequency=frequency)
return
elif detector.board.binho_nova:
from adafruit_blinka.microcontroller.nova.i2c import I2C
elif detector.board.microchip_mcp2221:
from adafruit_blinka.microcontroller.mcp2221.i2c import I2C
self._i2c = I2C(frequency=frequency)
return
elif detector.board.any_embedded_linux:
from adafruit_blinka.microcontroller.generic_linux.i2c import I2C as _I2C
else:
from machine import I2C as _I2C
from microcontroller.pin import i2cPorts
for portId, portScl, portSda in i2cPorts:
try:
if scl == portScl and sda == portSda:
if bus_id is not None:
portId = bus_id
self._i2c = _I2C(portId, mode=_I2C.MASTER, baudrate=frequency)
break
except RuntimeError:
pass
else:
raise ValueError(
"No Hardware I2C on (scl,sda)={}\nValid I2C ports: {}".format((scl, sda), i2cPorts)
)
self._lock = threading.RLock()
Hi,
I'd need the option of specifying my I2C bus on raspberry pi 4, as I need to use a different one for my IMU. Now I could use specific bus like 3 or 4, with minimal code changes.
below init changes would be needed in src/busio.py
Intention is to only have effect when "bus_id" is defined.