Struct rppal::gpio::Pin

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

Unconfigured GPIO pin.

Pins are constructed by retrieving them using Gpio::get.

An unconfigured Pin can be used to read the pin’s mode and logic level. Converting the Pin to an InputPin, OutputPin or IoPin through the various into_ methods available on Pin configures the appropriate mode, and provides access to additional methods relevant to the selected pin mode.

The embedded-hal trait implementations for Pin can be enabled by specifying the optional hal feature in the dependency declaration for the rppal crate.

Implementations§

source§

impl Pin

source

pub fn pin(&self) -> u8

Returns the GPIO pin number.

Pins are addressed by their BCM GPIO numbers, rather than their physical location.

source

pub fn mode(&self) -> Mode

Returns the pin’s mode.

source

pub fn read(&self) -> Level

Reads the pin’s logic level.

source

pub fn into_input(self) -> InputPin

Consumes the Pin and returns an InputPin. Sets the mode to Input and disables the pin’s built-in pull-up/pull-down resistors.

source

pub fn into_input_pulldown(self) -> InputPin

Consumes the Pin and returns an InputPin. Sets the mode to Input and enables the pin’s built-in pull-down resistor.

The pull-down resistor is disabled when InputPin goes out of scope if reset_on_drop is set to true (default).

source

pub fn into_input_pullup(self) -> InputPin

Consumes the Pin and returns an InputPin. Sets the mode to Input and enables the pin’s built-in pull-up resistor.

The pull-up resistor is disabled when InputPin goes out of scope if reset_on_drop is set to true (default).

source

pub fn into_output(self) -> OutputPin

Consumes the Pin and returns an OutputPin. Sets the mode to Mode::Output and leaves the logic level unchanged.

source

pub fn into_output_low(self) -> OutputPin

Consumes the Pin and returns an OutputPin. Changes the logic level to Level::Low and then sets the mode to Mode::Output.

source

pub fn into_output_high(self) -> OutputPin

Consumes the Pin and returns an OutputPin. Changes the logic level to Level::High and then sets the mode to Mode::Output.

source

pub fn into_io(self, mode: Mode) -> IoPin

Consumes the Pin and returns an IoPin. Sets the mode to the specified mode.

Trait Implementations§

source§

impl Debug for Pin

source§

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

Formats the value using the given formatter. Read more
source§

impl Drop for Pin

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl ErrorType for Pin

§

type Error = Infallible

Error type
source§

impl InputPin for Pin

§

type Error = Infallible

Error type
source§

fn is_high(&self) -> Result<bool, Self::Error>

Is the input pin high?
source§

fn is_low(&self) -> Result<bool, Self::Error>

Is the input pin low?
source§

impl InputPin for Pin

source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
source§

impl<'a> PartialEq<&'a Pin> for Pin

source§

fn eq(&self, other: &&'a Pin) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialEq<Pin> for &'a Pin

source§

fn eq(&self, other: &Pin) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Pin

source§

fn eq(&self, other: &Pin) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Pin

Auto Trait Implementations§

§

impl !RefUnwindSafe for Pin

§

impl Send for Pin

§

impl Sync for Pin

§

impl Unpin for Pin

§

impl !UnwindSafe for Pin

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, 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.