Struct rppal::gpio::Gpio

source ·
pub struct Gpio { /* private fields */ }
Expand description

Provides access to the Raspberry Pi’s GPIO peripheral.

Implementations§

source§

impl Gpio

source

pub fn new() -> Result<Gpio>

Constructs a new Gpio.

source

pub fn get(&self, pin: u8) -> Result<Pin>

Returns a Pin for the specified BCM GPIO number.

Retrieving a GPIO pin grants access to the pin through an owned Pin instance. If the pin is already in use, get returns Err(Error::PinUsed). After a Pin (or a derived InputPin, OutputPin or IoPin) goes out of scope, it can be retrieved again through another get call.

source

pub fn poll_interrupts<'a>( &self, pins: &[&'a InputPin], reset: bool, timeout: Option<Duration> ) -> Result<Option<(&'a InputPin, Level)>>

Blocks until an interrupt is triggered on any of the specified pins, or until a timeout occurs.

Only pins that have been previously configured for synchronous interrupts using InputPin::set_interrupt can be polled. Asynchronous interrupt triggers are automatically polled on a separate thread.

Calling poll_interrupts blocks any other calls to poll_interrupts or InputPin::poll_interrupt until it returns. If you need to poll multiple pins simultaneously on different threads, consider using asynchronous interrupts with InputPin::set_async_interrupt instead.

Setting reset to false returns any cached interrupt trigger events if available. Setting reset to true clears all cached events before polling for new events.

The timeout duration indicates how long the call to poll_interrupts will block while waiting for interrupt trigger events, after which an Ok(None) is returned. timeout can be set to None to wait indefinitely.

When an interrupt event is triggered, poll_interrupts returns Ok((&InputPin, Level)) containing the corresponding pin and logic level. If multiple events trigger at the same time, only the first one is returned. The remaining events are cached and will be returned the next time InputPin::poll_interrupt or poll_interrupts is called.

Trait Implementations§

source§

impl Clone for Gpio

source§

fn clone(&self) -> Gpio

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Gpio

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Gpio

§

impl Send for Gpio

§

impl Sync for Gpio

§

impl Unpin for Gpio

§

impl !UnwindSafe for Gpio

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.