This is a library for interfacing with the HID features of the MCP2221 USB to UART and I2C/SMBus serial converter from Microchip. The converter includes 4 GPIO pins, 3x 10-bit ADCs, 1x 5-bit DAC and more.
Microchip does provide a library for interfacing with the chip, however it is supplied as proprietary DLLs. This project aims to be an open-source and multi-platform alternative.
This library also makes use of HIDAPI.
Bits of info about the MCP2221
- Doesn’t use a crystal, only requires 1 small capacitor when powered with 3.3V or 2 capacitors when powered with 5V.
- Available in a hacker friendly DIP package.
- Has a remote wake function which when used in conjunction with the interrupt input can be used to wakeup the USB host (usually a PC), just like waking up from a keyboard or mouse press.
- The raw value of the I2C pins can also be read, allowing them to be used as an additional 2 general purpose input pins.
- Unfortunately there are no options for enabling any internal pull-up/down resistors.
- The MCP2221 seems to be a PIC16F1455. [Source]
- Current consumption @ 3.3V with USB disconnected can be anywhere between 20uA and 70uA, not sure what causes such a difference. Remote wakeup needs to be disabled (default) otherwise current consumption will be about 5mA.
- Kinda slow compared to other USB/UART converters. Even with the baud rate set to 1,000,000 its overall throughput is only about 250,000 bps. More about this below.
The usual way to deal with unconnected pins are to enable their internal pull-up/down resistors, but this chip doesn’t support them. Instead it’s probably best to set unconnected pins as output high or low.
The I2C pins are a little different since they can’t be set to outputs, though there’s still few options:
For more detail: MCP2221 HID Library