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"""
14 # pylint: disable=unused-argument
15 def __init__(self, portId, *, mode=MASTER, baudrate=100000):
16 self._i2c = _I2C(portId, freq=baudrate)
19 """Perform an I2C Device Scan"""
20 return self._i2c.scan()
22 def writeto(self, address, buffer, *, stop=True):
23 """Write the data from the buffer to the address"""
24 return self._i2c.writeto(address, buffer)
26 def readfrom_into(self, address, buffer, *, stop=True):
27 """Read data from an address and into the buffer"""
28 return self._i2c.readfrom_into(address, buffer)
30 def writeto_then_readfrom(
42 """Write data from buffer_out to an address and then
43 read data from an address and into buffer_in
45 self._i2c.writeto_then_readfrom(
55 # pylint: enable=unused-argument