From: Melissa LeBlanc-Williams Date: Thu, 20 May 2021 20:41:28 +0000 (-0700) Subject: Added more to RP2040 I2C X-Git-Tag: 6.9.2^2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/78c42a3e0cd59116f8c8035fccd6b1b2460a62c1 Added more to RP2040 I2C --- diff --git a/src/adafruit_blinka/microcontroller/rp2040/i2c.py b/src/adafruit_blinka/microcontroller/rp2040/i2c.py index 16ff2e3..785769d 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,13 @@ 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, - ) - - # pylint: enable=unused-argument + if out_end: + self.writeto(address, buffer_out[out_start:out_end], stop=stop) + else: + self.writeto(address, buffer_out[out_start:], stop=stop) + read_buffer = buffer_in + self.readfrom_into(address, read_buffer, stop=stop) + if in_end: + buffer_in[in_start:in_end] = read_buffer[in_start:in_end] + else: + buffer_in[in_start:] = read_buffer[in_start:]