]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/microcontroller/fake_mcp2221/i2c.py
9b55c683923494f99b8a6fbcdd0e336f307e71d1
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / fake_mcp2221 / i2c.py
1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
2 #
3 # SPDX-License-Identifier: MIT
4 """I2C Class for MCP2221"""
5 from .fake_mcp2221 import mcp2221
6
7
8 class I2C:
9     """Custom I2C Class for MCP2221"""
10
11     def __init__(self, *, frequency=100000):
12         self._mcp2221 = mcp2221
13         # self._mcp2221._i2c_configure(frequency)
14
15     def scan(self):
16         """Perform an I2C Device Scan"""
17         # TODO: We need to fake an I2C scan here
18         return self._mcp2221.i2c_scan()
19
20     # pylint: disable=unused-argument
21     def writeto(self, address, buffer, *, start=0, end=None, stop=True):
22         """Write data from the buffer to an address"""
23         #self._mcp2221.i2c_writeto(address, buffer, start=start, end=end)
24
25     def readfrom_into(self, address, buffer, *, start=0, end=None, stop=True):
26         """Read data from an address and into the buffer"""
27         #self._mcp2221.i2c_readfrom_into(address, buffer, start=start, end=end)
28
29     def writeto_then_readfrom(
30         self,
31         address,
32         buffer_out,
33         buffer_in,
34         *,
35         out_start=0,
36         out_end=None,
37         in_start=0,
38         in_end=None,
39         stop=False,
40     ):
41         """Write data from buffer_out to an address and then
42         read data from an address and into buffer_in
43         """
44
45         """
46         self._mcp2221.i2c_writeto_then_readfrom(
47             address,
48             buffer_out,
49             buffer_in,
50             out_start=out_start,
51             out_end=out_end,
52             in_start=in_start,
53             in_end=in_end,
54         )
55         """
56
57     # pylint: enable=unused-argument