esp_hal::gpio

Struct Flex

Source
pub struct Flex<'d, P = AnyPin> { /* private fields */ }
Expand description

Flexible pin driver.

This driver allows changing the pin mode between input and output.

Implementations§

Source§

impl<P> Flex<'_, P>
where P: InputPin,

Source

pub async fn wait_for_high(&mut self)

Wait until the pin is high. If it is already high, return immediately.

Source

pub async fn wait_for_low(&mut self)

Wait until the pin is low. If it is already low, return immediately.

Source

pub async fn wait_for_rising_edge(&mut self)

Wait for the pin to undergo a transition from low to high.

Source

pub async fn wait_for_falling_edge(&mut self)

Wait for the pin to undergo a transition from high to low.

Source

pub async fn wait_for_any_edge(&mut self)

Wait for the pin to undergo any transition, i.e low to high OR high to low.

Source§

impl<'d> Flex<'d>

Source

pub fn new(pin: impl Peripheral<P = impl Into<AnyPin>> + 'd) -> Self

Create flexible pin driver for a Pin. No mode change happens.

Source§

impl<'d, P> Flex<'d, P>
where P: Pin,

Source

pub fn new_typed(pin: impl Peripheral<P = P> + 'd) -> Self

Create flexible pin driver for a Pin. No mode change happens.

Source

pub fn peripheral_input(&self) -> InputSignal

Returns a peripheral input connected to this pin.

The input signal can be passed to peripherals in place of an input pin.

Source§

impl<P> Flex<'_, P>
where P: InputPin,

Source

pub fn set_as_input(&mut self, pull: Pull)

Set the GPIO to input mode.

Source

pub fn is_high(&self) -> bool

Get whether the pin input level is high.

Source

pub fn is_low(&self) -> bool

Get whether the pin input level is low.

Source

pub fn level(&self) -> Level

Get the current pin input level.

Source

pub fn listen(&mut self, event: Event)

Listen for interrupts

Source

pub fn unlisten(&mut self)

Stop listening for interrupts

Source

pub fn clear_interrupt(&mut self)

Clear the interrupt status bit for this Pin

Source

pub fn is_interrupt_set(&self) -> bool

Checks if the interrupt status bit for this Pin is set

Source

pub fn wakeup_enable(&mut self, enable: bool, event: WakeEvent)

Enable as a wake-up source.

This will unlisten for interrupts

Source§

impl<P> Flex<'_, P>
where P: OutputPin,

Source

pub fn set_as_output(&mut self)

Set the GPIO to output mode.

Source

pub fn set_high(&mut self)

Set the output as high.

Source

pub fn set_low(&mut self)

Set the output as low.

Source

pub fn set_level(&mut self, level: Level)

Set the output level.

Source

pub fn is_set_high(&self) -> bool

Is the output pin set as high?

Source

pub fn is_set_low(&self) -> bool

Is the output pin set as low?

Source

pub fn output_level(&self) -> Level

What level output is set to

Source

pub fn toggle(&mut self)

Toggle pin output

Source

pub fn set_drive_strength(&mut self, strength: DriveStrength)

Configure the DriveStrength of the pin

Source

pub fn set_as_open_drain(&mut self, pull: Pull)

Set the GPIO to open-drain mode.

Source

pub fn split(self) -> (InputSignal, OutputSignal)

Split the pin into an input and output signal.

Peripheral signals allow connecting peripherals together without using external hardware.

Source

pub fn into_peripheral_output(self) -> OutputSignal

Turns the pin object into a peripheral output.

The output signal can be passed to peripherals in place of an output pin.

Trait Implementations§

Source§

impl<P> ErrorType for Flex<'_, P>

Source§

type Error = Infallible

Error type
Source§

impl<P> From<Flex<'static, P>> for InputConnection
where P: InputPin,

Source§

fn from(pin: Flex<'static, P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Flex<'static, P>> for InputSignal
where P: InputPin,

Source§

fn from(input: Flex<'static, P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Flex<'static, P>> for OutputConnection
where P: OutputPin,

Source§

fn from(pin: Flex<'static, P>) -> Self

Converts to this type from the input type.
Source§

impl<P> From<Flex<'static, P>> for OutputSignal
where P: OutputPin,

Source§

fn from(input: Flex<'static, P>) -> Self

Converts to this type from the input type.
Source§

impl<P> InputPin for Flex<'_, P>
where P: InputPin + OutputPin,

Source§

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<P> InputPin for Flex<'_, P>
where P: InputPin,

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<P> OutputPin for Flex<'_, P>
where P: InputPin + OutputPin,

Source§

type Error = Infallible

Error type
Source§

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

Drives the pin high Read more
Source§

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

Drives the pin low Read more
Source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value Read more
Source§

impl<P> OutputPin for Flex<'_, P>
where P: OutputPin,

Source§

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

Drives the pin low. Read more
Source§

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

Drives the pin high. Read more
Source§

fn set_state(&mut self, state: PinState) -> Result<(), Self::Error>

Drives the pin high or low depending on the provided value. Read more
Source§

impl<P> Peripheral for Flex<'_, P>

Source§

type P = Flex<'_, P>

Peripheral singleton type
Source§

unsafe fn clone_unchecked(&self) -> Self::P

Unsafely clone (duplicate) a peripheral singleton. Read more
Source§

fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>
where Self: 'a,

Convert a value into a PeripheralRef. Read more
Source§

fn map_into<U>(self) -> U
where Self::P: Into<U>, U: Peripheral<P = U>,

Map the peripheral using Into. Read more
Source§

impl<P: Pin> Pin for Flex<'_, P>

Source§

fn number(&self) -> u8

GPIO number
Source§

fn degrade(self) -> AnyPin
where Self: Sized,

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

impl<P: RtcPin> RtcPin for Flex<'_, P>

Source§

fn rtc_set_config(&mut self, input_enable: bool, mux: bool, func: RtcFunction)

Configure the pin
Source§

fn rtcio_pad_hold(&mut self, enable: bool)

Enable or disable PAD_HOLD
Source§

unsafe fn apply_wakeup(&mut self, wakeup: bool, level: u8)

Safety Read more
Source§

impl<P: RtcPinWithResistors> RtcPinWithResistors for Flex<'_, P>

Source§

fn rtcio_pullup(&mut self, enable: bool)

Enable/disable the internal pull-up resistor
Source§

fn rtcio_pulldown(&mut self, enable: bool)

Enable/disable the internal pull-down resistor
Source§

impl<P> StatefulOutputPin for Flex<'_, P>
where P: InputPin + OutputPin,

Source§

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

Is the pin in drive high mode? Read more
Source§

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

Is the pin in drive low mode? Read more
Source§

impl<P> StatefulOutputPin for Flex<'_, P>
where P: OutputPin,

Source§

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

Is the pin in drive high mode? Read more
Source§

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

Is the pin in drive low mode? Read more
Source§

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

Toggle pin output.
Source§

impl<P> ToggleableOutputPin for Flex<'_, P>
where P: InputPin + OutputPin,

Source§

type Error = Infallible

Error type
Source§

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

Toggle pin output.
Source§

impl<P> Wait for Flex<'_, P>
where P: InputPin,

Source§

async fn wait_for_high(&mut self) -> Result<(), Self::Error>

Wait until the pin is high. If it is already high, return immediately. Read more
Source§

async fn wait_for_low(&mut self) -> Result<(), Self::Error>

Wait until the pin is low. If it is already low, return immediately. Read more
Source§

async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo a transition from low to high. Read more
Source§

async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo a transition from high to low. Read more
Source§

async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo any transition, i.e low to high OR high to low.
Source§

impl<P: InputPin> PeripheralInput for Flex<'static, P>

Source§

impl<P: OutputPin> PeripheralOutput for Flex<'static, P>

Auto Trait Implementations§

§

impl<'d, P> Freeze for Flex<'d, P>
where P: Freeze,

§

impl<'d, P> RefUnwindSafe for Flex<'d, P>
where P: RefUnwindSafe,

§

impl<'d, P> Send for Flex<'d, P>
where P: Send,

§

impl<'d, P> Sync for Flex<'d, P>
where P: Sync,

§

impl<'d, P> Unpin for Flex<'d, P>
where P: Unpin,

§

impl<'d, P = AnyPin> !UnwindSafe for Flex<'d, P>

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.