1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
 
   3 # SPDX-License-Identifier: MIT
 
   4 """I2C Class for Generic MicroPython"""
 
   5 from machine import I2C as _I2C
 
   9     """I2C Class for Generic MicroPython"""
 
  13     # pylint: disable=unused-argument
 
  14     def __init__(self, portId, *, mode=MASTER, baudrate=100000):
 
  15         self._i2c = _I2C(portId, freq=baudrate)
 
  18         """Perform an I2C Device Scan"""
 
  19         return self._i2c.scan()
 
  21     def writeto(self, address, buffer, *, stop=True):
 
  22         """Write the data from the buffer to the address"""
 
  23         return self._i2c.writeto(address, buffer)
 
  25     def readfrom_into(self, address, buffer, *, stop=True):
 
  26         """Read data from an address and into the buffer"""
 
  27         return self._i2c.readfrom_into(address, buffer)
 
  29     def writeto_then_readfrom(
 
  41         """Write data from buffer_out to an address and then
 
  42         read data from an address and into buffer_in
 
  44         self._i2c.writeto_then_readfrom(
 
  54     # pylint: enable=unused-argument