The Raspberry Pi C library provide you to access the GPIO (General Purpose Input Output) and other IO functions in the BROADCOM BCM2835 Integrated Circuit. These C library allowing you to access the GPIO pins on the 26 pin IDE plug on the Raspberry Pi board, giving you more freedom to control and interface with any supported external devices.
The BCM2835 C Library provides you to read the digital input outputs using SPI(Serial Peripheral Interface) and I2C(2 Wire) to access the system timers the pin event detection is supported by polling. Note this C library Interrupts are not supported.
It is C++ supported and it will install as a header file and non-shared library on any linux base distribution. This C library are based on the data in elinux.org LOW LEVEL Peripherals and Raspberry Pi BCM835 ARM Peripherals Documentation, you can find the latest & updated version http://www.airspayce.com/mikem/bcm2835
Read the GPIO Register Access Function Reference Here
http://www.airspayce.com/mikem/bcm2835/group__constants.html#ga63c029bd6500167152db4e57736d0939
How to install the BCM2835 C Library?
The library consist of a single non-shared header file, which will be installed in the common places by make install command.
Download the latest version here > http://www.airspayce.com/mikem/bcm2835/bcm2835-1.42.tar.gz
1 2 3 4 5 6 |
$ tar zxyf bcm2835-1.xx.tar.gz $ cd bcm2835-1.xx $ ./configure $ make $ sudo make check $ sudo make install |
Configure on Raspberry Pi 2
For Raspberry Pi 2 you must have the device tree support enabled in the kernel and you should ensure that you are using the latest version of Linux. This library is tested on Raspberry Pi 2 with 2015/02/06/Raspbian-Whezzy and Arch Linux ARM RPI 2 dated on 2015/03/29, when device tree is enabled, the file /proc/device-tree/soc/ranges will appear in the file system and the BCM2835 module relies on its presence to correctly running in Raspberry Pi 2 this is just an optional for Raspberry Pi 1. Without the device tree support enabled the presence of this file will not work on Raspberry Pi 2 below are the to enabling the device tree support.
To Enable the Device Tree Support in Raspberry Pi 2
1 2 3 |
$ sudo raspi-config // Under advanced Options select > enable the Device Tree support then $ sudo reboot |
See the Broadcom BCM 2835 GPIO functions here > http://elinux.org/RPi_BCM2835_GPIOs