Struct rppal::gpio::GPIO
[−]
[src]
pub struct GPIO { /* fields omitted */ }
Provides access to the Raspberry Pi GPIO.
Methods
impl GPIO
[src]
fn new() -> Result<GPIO>
Constructs a new GPIO
.
fn set_clear_on_drop(&mut self, clear_on_drop: bool)
When enabled, resets all pins to their original state when GPIO
goes out of scope.
Drop methods aren't called when a program is abnormally terminated,
for instance when a user presses Ctrl-C, and the SIGINT signal isn't
caught. You'll either have to catch those using crates such as
simple_signal
, or manually call cleanup()
.
Enabled by default.
fn cleanup(&mut self)
Resets all pins to their original state.
Normally, this method is automatically called when GPIO
goes out of
scope, but you can manually call it to handle early/abnormal termination.
After calling this method, any future calls to other methods won't have any
result.
fn mode(&mut self, pin: u8) -> Result<Mode>
Reads the current GPIO pin mode.
fn set_mode(&mut self, pin: u8, mode: Mode)
Changes the GPIO pin mode to input, output or one of the alternative functions.
fn read(&mut self, pin: u8) -> Result<Level>
Reads the current GPIO pin logic level.
fn write(&self, pin: u8, level: Level)
Changes the GPIO pin logic level to high or low.
fn set_pullupdown(&mut self, pin: u8, pud: PullUpDown)
Enables/disables the built-in GPIO pull-up/pull-down resistors.