X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/82ff2f40b52f57e3d5ac746ca965fdc026f38d9e..d8e7e44560d6c002f7267eb8dba785d09bc1b47f:/src/adafruit_blinka/microcontroller/mcp2221/i2c.py diff --git a/src/adafruit_blinka/microcontroller/mcp2221/i2c.py b/src/adafruit_blinka/microcontroller/mcp2221/i2c.py index 9ebb5b6..df2642f 100644 --- a/src/adafruit_blinka/microcontroller/mcp2221/i2c.py +++ b/src/adafruit_blinka/microcontroller/mcp2221/i2c.py @@ -1,23 +1,50 @@ +"""I2C Class for MCP2221""" from .mcp2221 import mcp2221 + class I2C: + """Custom I2C Class for MCP2221""" def __init__(self, *, frequency=100000): self._mcp2221 = mcp2221 - self._mcp2221.i2c_configure(frequency) + self._mcp2221._i2c_configure(frequency) def scan(self): + """Perform an I2C Device Scan""" return self._mcp2221.i2c_scan() + # pylint: disable=unused-argument def writeto(self, address, buffer, *, start=0, end=None, stop=True): + """Write data from the buffer to an address""" self._mcp2221.i2c_writeto(address, buffer, start=start, end=end) def readfrom_into(self, address, buffer, *, start=0, end=None, stop=True): + """Read data from an address and into the buffer""" self._mcp2221.i2c_readfrom_into(address, buffer, start=start, end=end) - def writeto_then_readfrom(self, address, buffer_out, buffer_in, *, - out_start=0, out_end=None, - in_start=0, in_end=None, stop=False): - self._mcp2221.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) + def writeto_then_readfrom( + self, + address, + buffer_out, + buffer_in, + *, + out_start=0, + out_end=None, + in_start=0, + in_end=None, + stop=False + ): + """Write data from buffer_out to an address and then + read data from an address and into buffer_in + """ + self._mcp2221.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