Struct GPIO

Source
pub struct GPIO { /* private fields */ }
Expand description

A software representation for a GPIO pin of the raspberry pi.

Implementations§

Source§

impl GPIO

Source

pub fn gpio_number(&self) -> u8

Returns the configured pin of the GPIO struct.

Source

pub fn current_mode(&self) -> GPIOMode

Returns the configured mode of the GPIO struct.

Source

pub fn set_mode(&mut self, mode: GPIOMode) -> Result<&mut Self>

Changes the mode of the pin and writes the corresponding value to the fitting direction file

Source

pub fn new(gpio: u8, mode: GPIOMode) -> Result<Self>

Initializes the gpio. Exports the pin with the /sys/class/gpio/export file and calls the set_mode() function with the given mode. Returns an Error if the gpio was already exported earlier (inside or outside of the application)

Source

pub fn value(&self) -> Result<GPIOData>

Reads the current value of the pin in both Read and Write mode. Returns an Error if a value other than “1” or “0” is read

Source

pub fn set(&self, data: GPIOData) -> Result<()>

Sets the value of the gpio to HIGH or LOW Returns an Error if the GPIO::Mode is not Write

Trait Implementations§

Source§

impl Drop for GPIO

Closes the gpio and write its pin number into /sys/class/gpio/unexport

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for GPIO

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.