2016-09-22 15:12:26 +02:00
|
|
|
# pigpio
|
|
|
|
pigpio is a C library for the Raspberry which allows control of the
|
2017-01-11 11:59:38 +01:00
|
|
|
General Purpose Input Outputs (GPIO).
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
Features
|
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
sampling and time-stamping of GPIO 0-31 between 100,000 and 1,000,000 times per second.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
provision of PWM on any number of the user GPIO simultaneously.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
provision of servo pulses on any number of the user GPIO simultaneously.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
callbacks when any of GPIO 0-31 change state (callbacks receive the time of the event
|
2016-09-22 15:12:26 +02:00
|
|
|
accurate to a few microseconds).
|
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
notifications via pipe when any of GPIO 0-31 change state.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
callbacks at timed intervals.
|
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
reading/writing all of the GPIO in a bank (0-31, 32-53) as a single operation.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
individually setting GPIO modes, reading and writing.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
socket and pipe interfaces for the bulk of the functionality in addition to the
|
|
|
|
underlying C library calls.
|
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
the construction of arbitrary waveforms to give precise timing of output GPIO
|
2016-09-22 15:12:26 +02:00
|
|
|
level changes (accurate to a few microseconds).
|
|
|
|
|
2017-01-11 11:59:38 +01:00
|
|
|
software serial links, I2C, and SPI using any user GPIO.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
rudimentary permission control through the socket and pipe interfaces so users
|
2017-01-11 11:59:38 +01:00
|
|
|
can be prevented from "updating" inappropriate GPIO.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
creating and running scripts on the pigpio daemon.
|
|
|
|
|
|
|
|
Interfaces
|
|
|
|
|
|
|
|
The library provides a number of control interfaces
|
|
|
|
|
|
|
|
the C function interface
|
|
|
|
|
|
|
|
the /dev/pigpio pipe interface
|
|
|
|
|
|
|
|
the socket interface (used by the pigs utility and the Python module)
|
|
|
|
|
|
|
|
Utilities
|
|
|
|
|
|
|
|
A number of utility programs are provided
|
|
|
|
|
|
|
|
the pigpiod daemon.
|
|
|
|
the Python module.
|
2017-01-11 12:06:33 +01:00
|
|
|
the piscope digital waveform viewer.
|
2016-09-22 15:12:26 +02:00
|
|
|
the pigs command line utility.
|
|
|
|
the pig2vcd utility which converts notifications into the value change dump (VCD)
|
|
|
|
format (useful for viewing digital waveforms with GTKWave).
|
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
Example programs
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
See http://abyz.co.uk/rpi/pigpio/examples.html
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
GPIO
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
ALL GPIO are identified by their Broadcom number. See elinux.org
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
There are 54 GPIO in total, arranged in two banks.
|
|
|
|
|
|
|
|
Bank 1 contains GPIO 0-31. Bank 2 contains GPIO 32-54.
|
|
|
|
|
|
|
|
A user should only manipulate GPIO in bank 1.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
There are at least three types of board.
|
|
|
|
|
|
|
|
Type 1
|
|
|
|
|
|
|
|
26 pin header (P1).
|
|
|
|
|
|
|
|
Hardware revision numbers of 2 and 3.
|
|
|
|
|
2017-01-11 12:28:26 +01:00
|
|
|
User GPIO 0-1, 4, 7-11, 14-15, 17-18, 21-25.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
Type 2
|
|
|
|
|
|
|
|
26 pin header (P1) and an additional 8 pin header (P5).
|
|
|
|
|
|
|
|
Hardware revision numbers of 4, 5, 6, and 15.
|
|
|
|
|
2017-01-11 12:28:26 +01:00
|
|
|
User GPIO 2-4, 7-11, 14-15, 17-18, 22-25, 27-31.
|
2016-09-22 15:12:26 +02:00
|
|
|
|
|
|
|
Type 3
|
|
|
|
|
|
|
|
40 pin expansion header (J8).
|
|
|
|
|
|
|
|
Hardware revision numbers of 16 or greater.
|
|
|
|
|
2017-01-11 12:28:26 +01:00
|
|
|
User GPIO 2-27 (0 and 1 are reserved).
|
2016-09-22 15:12:26 +02:00
|
|
|
|
2017-01-11 12:06:33 +01:00
|
|
|
It is safe to read all the GPIO. If you try to write a system GPIO or change
|
2016-09-22 15:12:26 +02:00
|
|
|
its mode you can crash the Pi or corrupt the data on the SD card.
|