Struct AnyPin

Source
pub struct AnyPin<'lt> { /* private fields */ }
Expand description

Any GPIO pin.

Implementations§

Source§

impl<'lt> AnyPin<'lt>

Source

pub unsafe fn split(self) -> (InputSignal<'lt>, OutputSignal<'lt>)

Available on crate feature unstable only.

Split the pin into an input and output signal.

Peripheral signals allow connecting peripherals together without using external hardware.

Creating an input signal enables the pin’s input buffer.

§Safety

The caller must ensure that peripheral drivers don’t configure the same GPIO at the same time in multiple places. This includes clones of the InputSignal struct, as well as the OutputSignal struct.

§Panics

This function panics if the pin is not an output pin.

§Example
use esp_hal::gpio::{AnyPin, Pin};
let pin1 = peripherals.GPIO1.degrade();
let (input, output) = unsafe { pin1.split() };
§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub unsafe fn into_input_signal(self) -> InputSignal<'lt>

Available on crate feature unstable only.

Convert the pin into an input signal.

Peripheral signals allow connecting peripherals together without using external hardware.

Creating an input signal enables the pin’s input buffer.

§Safety

The caller must ensure that peripheral drivers don’t configure the same GPIO at the same time in multiple places. This includes clones of the InputSignal struct.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn into_output_signal(self) -> OutputSignal<'lt>

Available on crate feature unstable only.

Convert the pin into an output signal.

Peripheral signals allow connecting peripherals together without using external hardware.

§Panics

This function panics if the pin is not an output pin.

§Stability

This API is marked as unstable and is only available when the unstable crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source§

impl AnyPin<'_>

Source

pub fn downcast<P: Pin>(self) -> Result<P, Self>
where Self: TryInto<P, Error = Self>,

Attempts to downcast the pin into the underlying GPIO instance.

§Example
use esp_hal::{
    gpio::AnyPin,
    peripherals::{GPIO2, GPIO4},
};

let any_pin2 = AnyPin::from(peripherals.GPIO2);
let any_pin3 = AnyPin::from(peripherals.GPIO3);

let gpio2 = any_pin2
    .downcast::<GPIO2>()
    .expect("This downcast succeeds because AnyPin was created from GPIO2");
let gpio4 = any_pin3
    .downcast::<GPIO4>()
    .expect_err("This AnyPin was created from GPIO3, it cannot be downcast to GPIO4");
Source

pub unsafe fn steal(pin: u8) -> Self

Conjure a new GPIO pin out of thin air.

§Safety

The caller must ensure that only one instance of a pin is in use at one time.

§Panics

Panics if the pin with the given number does not exist.

§Example
use esp_hal::gpio::AnyPin;
let pin = unsafe { AnyPin::steal(1) };
Source

pub unsafe fn clone_unchecked(&self) -> Self

Unsafely clone the pin.

§Safety

Ensure that only one instance of a pin is in use at one time.

§Example
use esp_hal::gpio::{AnyPin, Pin};
let pin = peripherals.GPIO1.degrade();
let pin_cloned = unsafe { pin.clone_unchecked() };
Source

pub fn reborrow(&mut self) -> AnyPin<'_>

Create a new AnyPin object that is limited to the lifetime of the passed reference.

§Example
use esp_hal::gpio::{AnyPin, Pin};
let mut pin = peripherals.GPIO1.degrade();
let pin_reborrowed = pin.reborrow();

Trait Implementations§

Source§

impl<'lt> Debug for AnyPin<'lt>

Source§

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

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

impl<'lt> From<GPIO0<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO0<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO1<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO1<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO10<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO10<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO11<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO11<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO12<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO12<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO13<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO13<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO14<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO14<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO15<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO15<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO16<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO16<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO17<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO17<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO18<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO18<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO19<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO19<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO2<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO2<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO20<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO20<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO21<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO21<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO22<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO22<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO23<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO23<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO24<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO24<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO25<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO25<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO26<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO26<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO27<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO27<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO28<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO28<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO29<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO29<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO3<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO3<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO30<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO30<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO4<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO4<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO5<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO5<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO6<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO6<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO7<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO7<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO8<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO8<'lt>) -> Self

Converts to this type from the input type.
Source§

impl<'lt> From<GPIO9<'lt>> for AnyPin<'lt>

Source§

fn from(pin: GPIO9<'lt>) -> Self

Converts to this type from the input type.
Source§

impl Pin for AnyPin<'_>

Source§

fn number(&self) -> u8

GPIO number
Source§

fn degrade<'d>(self) -> AnyPin<'d>
where Self: Sized + 'd,

Type-erase this pin into an AnyPin. Read more
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO0<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO1<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO10<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO11<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO12<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO13<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO14<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO15<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO16<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO17<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO18<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO19<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO2<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO20<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO21<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO22<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO23<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO24<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO25<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO26<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO27<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO28<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO29<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO3<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO30<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO4<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO5<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO6<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO7<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO8<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'lt> TryFrom<AnyPin<'lt>> for GPIO9<'lt>

Source§

type Error = AnyPin<'lt>

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

fn try_from(any_pin: AnyPin<'lt>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl InputPin for AnyPin<'_>

Source§

impl OutputPin for AnyPin<'_>

Source§

impl RtcPin for AnyPin<'_>

Source§

impl RtcPinWithResistors for AnyPin<'_>

Auto Trait Implementations§

§

impl<'lt> Freeze for AnyPin<'lt>

§

impl<'lt> RefUnwindSafe for AnyPin<'lt>

§

impl<'lt> Send for AnyPin<'lt>

§

impl<'lt> Sync for AnyPin<'lt>

§

impl<'lt> Unpin for AnyPin<'lt>

§

impl<'lt> !UnwindSafe for AnyPin<'lt>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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<'d, P> PeripheralOutput<'d> for P
where P: OutputPin + 'd,

Source§

impl<'d, P> PeripheralSignal<'d> for P
where P: Pin + 'd,

Source§

fn connect_input_to_peripheral(&self, signal: InputSignal)

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

impl<'d, P> PeripheralInput<'d> for P
where P: InputPin + 'd,