embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

Flex

Struct Flex 

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

A flexible pin that can be configured as input or output.

Implementations§

Source§

impl<'d> Flex<'d>

Source

pub fn new(pin: Peri<'d, impl GpioPin>) -> Self

Wrap the pin in a Flex.

The pin remains unmodified. The initial output level is unspecified, but can be changed before the pin is put into output mode.

Source

pub fn set_as_input(&mut self)

Put the pin into input mode.

Source

pub fn set_as_output(&mut self)

Put the pin into output mode.

Source

pub fn set_high(&mut self)

Set output level to High.

Source

pub fn set_low(&mut self)

Set output level to Low.

Source

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

Set output level to the given Level.

Source

pub fn toggle(&mut self)

Toggle output level.

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 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 set_pull(&mut self, pull_select: Pull)

Configure the pin pull up/down level.

Source

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

Configure the pin drive strength.

Source

pub fn set_slew_rate(&mut self, slew_rate: SlewRate)

Configure the pin slew rate.

Source

pub fn set_enable_input_buffer(&mut self)

Enable input buffer for the pin.

Source

pub fn get_level(&self) -> Level

Get pin level.

Source§

impl<'d> Flex<'d>

Async methods

Source

pub fn wait_for_high(&mut self) -> impl Future<Output = ()> + use<'_, 'd>

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

Source

pub fn wait_for_low(&mut self) -> impl Future<Output = ()> + use<'_, 'd>

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

Source

pub fn wait_for_rising_edge(&mut self) -> impl Future<Output = ()> + use<'_, 'd>

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

Source

pub fn wait_for_falling_edge( &mut self, ) -> impl Future<Output = ()> + use<'_, 'd>

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

Source

pub fn wait_for_any_edge(&mut self) -> impl Future<Output = ()> + use<'_, 'd>

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

Trait Implementations§

Source§

impl ErrorType for Flex<'_>

Source§

type Error = Infallible

Error type
Source§

impl InputPin for Flex<'_>

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 OutputPin for Flex<'_>

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 OutputPin for Flex<'_>

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 StatefulOutputPin for Flex<'_>

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 StatefulOutputPin for Flex<'_>

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 ToggleableOutputPin for Flex<'_>

Source§

type Error = Infallible

Error type
Source§

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

Toggle pin output.
Source§

impl Wait for Flex<'_>

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.

Auto Trait Implementations§

§

impl<'d> Freeze for Flex<'d>

§

impl<'d> !RefUnwindSafe for Flex<'d>

§

impl<'d> !Send for Flex<'d>

§

impl<'d> !Sync for Flex<'d>

§

impl<'d> Unpin for Flex<'d>

§

impl<'d> !UnwindSafe for Flex<'d>

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.