1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
 
   3 # SPDX-License-Identifier: MIT
 
   4 """I2C Class for MCP2221"""
 
   5 from .mcp2221 import mcp2221
 
   9     """Custom I2C Class for MCP2221"""
 
  11     def __init__(self, *, frequency=100000):
 
  12         self._mcp2221 = mcp2221
 
  13         self._mcp2221._i2c_configure(frequency)
 
  16         """Perform an I2C Device Scan"""
 
  17         return self._mcp2221.i2c_scan()
 
  19     # pylint: disable=unused-argument
 
  20     def writeto(self, address, buffer, *, start=0, end=None, stop=True):
 
  21         """Write data from the buffer to an address"""
 
  22         self._mcp2221.i2c_writeto(address, buffer, start=start, end=end)
 
  24     def readfrom_into(self, address, buffer, *, start=0, end=None, stop=True):
 
  25         """Read data from an address and into the buffer"""
 
  26         self._mcp2221.i2c_readfrom_into(address, buffer, start=start, end=end)
 
  28     def writeto_then_readfrom(
 
  40         """Write data from buffer_out to an address and then
 
  41         read data from an address and into buffer_in
 
  43         self._mcp2221.i2c_writeto_then_readfrom(
 
  53     # pylint: enable=unused-argument