Thanks to visit codestin.com
Credit goes to github.com

Skip to content
/ pi-gpio Public
forked from Milliways2/pi-gpio

A dynamic C library to control Raspberry Pi GPIO channels

License

robpen/pi-gpio

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-gpio

A fast dynamic C library to control Raspberry Pi GPIO channels
Supports all production models available in September 2023 / all SOC
NOTE does not run on Pi5/BCM2712

This library has code to:-

Read Raspberry Pi Information

Perform basic GPIO functions
• Set gpio as input or output
• Read/Write gpio
• Set pullup/down of gpio
• Read the current gpio mode
• Read gpio pull/up down (Pi4/BCM2711 only)

Software PWM on all pins

Hardware PWM support

Read/Set PAD drive, hysteresis & slew settings

kernel PWM

I²C

SPI

Overlays

Includes python overlays with access to most functions
This is available with include pi_gpio or include kpwm for kernel PWM Socket access include pi_sock

Utilities

gpioStatus Display status of all GPIO
pi-gpiod A socket interface to pi_gpio

Documentation

To read documentation:-
C: man pi-gpio & man MCP23017
Python: python3 -m pydoc pi_gpio
Python: python3 -m pydoc kpwm

Extras

micros & millis timers

Extensions

GPIO access routines for MCP23017 16-Bit I/O Expander (requires MCP23017.h)

Dependencies

Most code uses direct hardware access to the SoC Peripheral and is independent of the kernel.

• Raspberry Pi Information is determined from a register on the SoC, which is available from device-tree.  
• kernel PWM, I²C & SPI use kernel drivers.

If run without root permision pi-gpio uses character device /dev/gpiomem to map the GPIO register page.
This allows GPIO access to members of the gpio group but does not provide access the PWM or clock hardware registers.

NOTE Users of pi-gpio or pi_gpio programs on Raspberry Pi OS should be members of group gpio (Ubuntu group dialout).
If error message "Pi Setup failure" the most likely cause is that user does not have access.

If run with root permission uses character device /dev/mem which allows full access but requires determining the address of the GPIO peripheral which varies depending on SoC.

The socket interface allows access without root permission.

About

A dynamic C library to control Raspberry Pi GPIO channels

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 59.3%
  • Python 20.4%
  • Roff 16.5%
  • Makefile 2.0%
  • Shell 1.8%