This repository contains an embedded C library for interfacing with the MCP2222 USB-to-I²C/SPI/UART converter device. The codebase provides easy-to-use APIs for sending and receiving vendor commands, as defined in the MCP2222 data sheet.
- Simple C APIs to interact with the MCP2222 device
- Platform agnostic USB communication
- Configure and read device settings:
- USB Descriptors
- Chip Access
- I/O, I²C/SMBus, SPI, UART
- Exchange data over I²C, SPI and UART using abstracted functions
- Error handling for device communication
- Example code and usage documentation
cmake/— CMake toolchain files (xc32/arm)src/— Embedded C source files (library implementation)include/— C header files, including the PAL interface (mcp2222_pal.h)examples/— Example and demonstration codedocs/— Data sheets, documentation and usage guidescmake_build.sh— CMake build scriptCMakeLists.txt— CMake configuration
- Clone this repository into your embedded C project.
- Implement the platform abstraction layer for your USB stack:
- Do not modify
include/mcp2222_pal.h. This header provides the required function declarations. - Use the provided
src/mcp2222_pal.csource file to implement the following required functions:int MCP2222_PAL_Write(...);int MCP2222_PAL_Read(...);
- Refer to the template and documentation in
include/mcp2222_pal.h
- Do not modify
- Include the library headers in your application.
- Use the high-level functions to communicate via I²C/SPI/UART or configure the device.
- CMake
- Make (MSYS2 on Windows) — required by the script’s Unix Makefiles generator
- Arm® GNU Toolchain
- MPLAB® XC32 Compiler
Note: Ensure
cmake,makeand the selected toolchain (arm-none-eabi-gccorxc32-gcc) are available on yourPATHfor the script to build successfully.
- Open a bash terminal in the same directory as the
cmake_build.shscript. - Run the
./cmake_build.sh --arm --cleanor./cmake_build.sh --xc32 --cleancommand to build the project using either XC32 or the Arm GNU Toolchain. - After the build is complete, the output library
.awill be stored in thebuildfolder.
See LICENSE for usage terms.