Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

USB Embedded Host Library in C Language for MCP2222

ℹ️ What Is This Library?

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.

✨ Features

  • 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

📦 Directory Structure

  • 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 code
  • docs/ — Data sheets, documentation and usage guides
  • cmake_build.sh — CMake build script
  • CMakeLists.txt — CMake configuration

⚙️ How to Use

  1. Clone this repository into your embedded C project.
  2. 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.c source 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
  3. Include the library headers in your application.
  4. Use the high-level functions to communicate via I²C/SPI/UART or configure the device.

⚙️ How to Build With CMake

Prerequisites

Note: Ensure cmake, make and the selected toolchain (arm-none-eabi-gcc or xc32-gcc) are available on your PATH for the script to build successfully.

Build

  1. Open a bash terminal in the same directory as the cmake_build.sh script.
  2. Run the ./cmake_build.sh --arm --clean or ./cmake_build.sh --xc32 --clean command to build the project using either XC32 or the Arm GNU Toolchain.
  3. After the build is complete, the output library .a will be stored in the build folder.

📝 References

🔗 License

See LICENSE for usage terms.

About

This repository contains an embedded C library for interfacing with the MCP2222 USB-to-I2C/SPI/UART converter device. The codebase provides easy-to-use APIs for sending and receiving vendor commands as defined in the MCP2222 datasheet.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages