1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
4 """Chip Definition for MCP2221"""
14 """MCP2221 Device Class Definition"""
17 pass # This is a "fake" implementation
20 """Close the hid device. Does nothing if the device is not open."""
24 # try to close the device before destroying the instance
27 def _hid_xfer(self, report, response=True):
28 """Perform HID Transfer"""
31 # ----------------------------------------------------------------
33 # ----------------------------------------------------------------
34 def gp_get_mode(self, pin):
35 """Get Current Pin Mode"""
38 def gp_set_mode(self, pin, mode):
39 """Set Current Pin Mode"""
42 def _pretty_report(self, register):
45 def _status_dump(self):
54 # ----------------------------------------------------------------
56 # ----------------------------------------------------------------
57 def gpio_set_direction(self, pin, mode):
58 """Set Current GPIO Pin Direction"""
61 def gpio_set_pin(self, pin, value):
62 """Set Current GPIO Pin Value"""
65 def gpio_get_pin(self, pin):
66 """Get Current GPIO Pin Value"""
69 # ----------------------------------------------------------------
71 # ----------------------------------------------------------------
72 def _i2c_status(self):
78 def _i2c_cancel(self):
81 # pylint: disable=too-many-arguments,too-many-branches
82 def _i2c_write(self, cmd, address, buffer, start=0, end=None):
85 def _i2c_read(self, cmd, address, buffer, start=0, end=None):
88 # pylint: enable=too-many-arguments
89 def _i2c_configure(self, baudrate=100000):
93 def i2c_writeto(self, address, buffer, *, start=0, end=None):
94 """Write data from the buffer to an address"""
97 def i2c_readfrom_into(self, address, buffer, *, start=0, end=None):
98 """Read data from an address and into the buffer"""
101 def i2c_writeto_then_readfrom(
112 """Write data from buffer_out to an address and then
113 read data from an address and into buffer_in
117 def i2c_scan(self, *, start=0, end=0x79):
118 """Perform an I2C Device Scan"""
121 # ----------------------------------------------------------------
123 # ----------------------------------------------------------------
124 def adc_configure(self, vref=0):
125 """Configure the Analog-to-Digital Converter"""
128 def adc_read(self, pin):
129 """Read from the Analog-to-Digital Converter"""
132 # ----------------------------------------------------------------
134 # ----------------------------------------------------------------
135 def dac_configure(self, vref=0):
136 """Configure the Digital-to-Analog Converter"""
139 # pylint: disable=unused-argument
140 def dac_write(self, pin, value):
141 """Write to the Digital-to-Analog Converter"""
144 # pylint: enable=unused-argument