RPPAL - Raspberry Pi Peripheral Access Library
RPPAL is a Rust library that provides access to the Raspberry Pi's GPIO peripheral. Support for additional peripherals will be added in future updates. The library is compatible with the Raspberry Pi A, A+, B, B+, 2B, 3B, 3B+, Compute, Compute 3, Zero and Zero W.
Backwards compatibility for minor revisions isn't guaranteed until the library reaches v1.0.0.
Supported peripherals
GPIO
For performance reasons, the library accesses the GPIO peripheral mainly through either /dev/gpiomem
or /dev/mem
. GPIO pin interrupts are controlled using the sysfs interface.
Features:
- Get/set pin mode.
- Read/write pin level.
- Set built-in pull-up/pull-down resistors.
- Set synchronous and asynchronous interrupts.
Documentation
Documentation for the latest release can be found at docs.golemparts.com/rppal. Documentation for earlier releases is stored at docs.rs/rppal.
Usage
Add a dependency for rppal
to your Cargo.toml
.
[]
= "0.5"
Link and import rppal
from your crate root.
extern crate rppal;
Call Gpio::new()
to create a new Gpio instance with the default settings. In production code, you'll want to parse the result rather than unwrap it.
use Gpio;
let mut gpio = new.unwrap;
Example
extern crate rppal;
use thread;
use Duration;
use ;
use DeviceInfo;
// The GPIO module uses BCM pin numbering. BCM 18 equates to physical pin 12.
const GPIO_LED: u8 = 18;
Caution
Always be careful when working with the Raspberry Pi's peripherals, especially if you attach any external components to the GPIO pins. Improper use can lead to permanent damage.
Cross compilation
If you're not working directly on a Raspberry Pi, you'll likely need to cross compile your code for the appropriate ARM architecture. Check out this guide for more information, or try the cross project for "zero setup" cross compilation.
Copyright and license
Copyright (c) 2017-2018 Rene van der Meer. Released under the MIT license.