Raspberry Pi GPIO Library  0.3
Library allowing for control of the Raspberry Pi's GPIO pins.
Raspberry Pi GPIO Library Documentation

The library provided here allows basic input / output control over the GPIO pins of a Raspberry Pi (rev1 and rev2) from C. The pins are accessed from memory mapped pointer to /dev/mem (see man mmap).

Getting Started

Building the library: librpigpio.a

To build the library file change directory to src (assuming you are at the top level directory of RaspberryPi-GPIO) type "make" in the terminal:

    cd src
    make

If this command was successful you should see a new directory called library now exists at the root level. librpigpio.a should be found in this directory; library/librpigpio.a.

Examples

There is example code provided in the directory examples. To compile this code change directory to examples and type "make".

    cd examples
    make

You should see a new folder - called output - is created in examples. The example binaries can be found within this folder - examples/output/.

To execute one of the examples you must first give it execute permissions.

    chmod +x output/<file_name>

The examples should be run as root.

    sudo ./output/<file_name>

Acknowledgements

Some of the code was based upon an example by Dom and Gert which was found at: http://elinux.org/RPi_Low-level_peripherals#Introduction. Thanks to github user sjaeckel for his large part in adding support for the rev2 PCB layout.

Copyright

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

References

elinux Wiki on Raspberry Pi GPIO: http://elinux.org/RPi_Low-level_peripherals#Introduction
Raspberry Pi blog post on GPIO: http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
Datasheet: http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf