pub struct AnyPin<'lt> { /* private fields */ }Expand description
Any GPIO pin.
Implementations§
Source§impl<'lt> AnyPin<'lt>
impl<'lt> AnyPin<'lt>
Sourcepub unsafe fn split(self) -> (InputSignal<'lt>, OutputSignal<'lt>)
Available on crate feature unstable only.
pub unsafe fn split(self) -> (InputSignal<'lt>, OutputSignal<'lt>)
unstable only.Splits 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.
§Examples
use esp_hal::gpio::{AnyPin, Pin};
let pin1 = peripherals.GPIO1.degrade();
let (input, output) = unsafe { pin1.split() };§Panics
Panics if the pin is not an output pin.
§Safety
The caller must ensure that peripheral drivers do not configure the same
GPIO at the same time in multiple places. This includes clones of the
InputSignal struct, as well as the OutputSignal 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.
Sourcepub unsafe fn into_input_signal(self) -> InputSignal<'lt>
Available on crate feature unstable only.
pub unsafe fn into_input_signal(self) -> InputSignal<'lt>
unstable only.Converts 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 do not 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.
Sourcepub fn into_output_signal(self) -> OutputSignal<'lt>
Available on crate feature unstable only.
pub fn into_output_signal(self) -> OutputSignal<'lt>
unstable only.Converts the pin into an output signal.
Peripheral signals allow connecting peripherals together without using external hardware.
§Panics
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<'_>
impl AnyPin<'_>
Sourcepub fn downcast<P: Pin>(self) -> Result<P, Self>where
Self: TryInto<P, Error = Self>,
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.
§Examples
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");