X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/a168b41a338d78869ddd29e63f638de96bcb647b..373c160b4a588ff883285ba10dba94e918a2abbb:/src/adafruit_blinka/microcontroller/rp2040/i2c.py?ds=inline diff --git a/src/adafruit_blinka/microcontroller/rp2040/i2c.py b/src/adafruit_blinka/microcontroller/rp2040/i2c.py index 16ff2e3..2a6c6a0 100644 --- a/src/adafruit_blinka/microcontroller/rp2040/i2c.py +++ b/src/adafruit_blinka/microcontroller/rp2040/i2c.py @@ -28,14 +28,13 @@ class I2C: """Perform an I2C Device Scan""" return self._i2c.scan() - # pylint: disable=unused-argument def writeto(self, address, buffer, *, stop=True): "Write data to the address from the buffer" - return self._i2c.writeto(address, buffer) + return self._i2c.writeto(address, buffer, stop) def readfrom_into(self, address, buffer, *, stop=True): """Read data from an address and into the buffer""" - return self._i2c.readfrom_into(address, buffer) + return self._i2c.readfrom_into(address, buffer, stop) def writeto_then_readfrom( self, @@ -52,14 +51,12 @@ class I2C: """Write data from buffer_out to an address and then read data from an address and into buffer_in """ - self._i2c.writeto_then_readfrom( - address, - buffer_out, - buffer_in, - out_start=out_start, - out_end=out_end, - in_start=in_start, - in_end=in_end, - ) + if out_end: + self.writeto(address, buffer_out[out_start:out_end], stop=stop) + else: + self.writeto(address, buffer_out[out_start:], stop=stop) - # pylint: enable=unused-argument + if not in_end: + in_end = len(buffer_in) + read_buffer = memoryview(buffer_in)[in_start:in_end] + self.readfrom_into(address, read_buffer, stop=stop)