c-periphery logo

c-periphery

Free

A C library for peripheral I/O (GPIO, SPI, I2C, MMIO, Serial) in Linux.

FreeFree tier
Type
Open Source

About c-periphery

c-periphery is a small, re-entrant C library for userspace Linux that provides a simplified and consolidated interface for accessing common peripheral I/O interfaces, including GPIO, LED, PWM, SPI, I2C, MMIO, and Serial. It has no dependencies beyond the standard C library and Linux, compiles into a static library for easy integration, and is MIT licensed. Designed for embedded Linux environments such as Raspberry Pi and BeagleBone, it abstracts the native Linux APIs to make peripheral control straightforward.

Key Features

Support for GPIO, LED, PWM, SPI, I2C, MMIO, and Serial interfaces
Re-entrant and thread-safe design
No dependencies outside standard C library and Linux
Compiles into a static library for easy project integration
MIT licensed for permissive use
Simplifies and consolidates native Linux peripheral APIs

Pros & Cons

Pros
  • Lightweight and minimal dependencies
  • Re-entrant for use in multi-threaded applications
  • Compiles as a static library for easy project inclusion
  • MIT license allows commercial and open-source use
  • Consistent API across different peripheral types
  • Actively maintained on GitHub with documentation and examples
Cons
  • Limited to Linux userspace; not suitable for kernel-level or real-time control
  • No built-in support for other operating systems (Windows, macOS)
  • Requires knowledge of Linux device paths and permissions

Best For

Embedded Linux development on Raspberry Pi, BeagleBone, and similar platformsInterfacing with external sensors, actuators, displays, and communication modulesRapid prototyping of hardware control in userspace applicationsEducational projects for learning Linux peripheral I/O

FAQ

What interfaces does c-periphery support?
c-periphery supports GPIO, LED, PWM, SPI, I2C, MMIO, and Serial peripheral I/O interfaces.
What are the dependencies?
c-periphery has no dependencies outside the standard C library and Linux.
How is c-periphery built?
It compiles into a static library, making it easy to integrate into other projects.
What license does c-periphery use?
It is licensed under the MIT license.
Can I use c-periphery on Raspberry Pi or BeagleBone?
Yes, it is designed for embedded Linux environments including Raspberry Pi and BeagleBone.