def init(self, scl, sda, frequency): 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 self._i2c = I2C(frequency=frequency) return 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: 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()
def init(self, scl, sda, frequency): self.deinit() if detector.board.ftdi_ft232h: from adafruit_blinka.microcontroller.ft232h.i2c import I2C self._i2c = I2C() 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: if scl == portScl and sda == portSda: self._i2c = _I2C(portId, mode=_I2C.MASTER, baudrate=frequency) break else: raise NotImplementedError( "No Hardware I2C on (scl,sda)={}\nValid UART ports: {}".format((scl, sda), i2cPorts) )