embassy-nxp

Crates

git

Versions

lpc55-core0

Flavors

Struct Flex

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

A flexible GPIO (digital mode) pin whose mode is not yet determined. Under the hood, this is a reference to a type-erased pin called “AnyPin”.

Implementations§

Source§

impl<'d> Flex<'d>

Source

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

Wrap the pin in a Flex.

Note: you cannot assume that the pin will be in Digital mode after this call.

Source

pub fn pin_bank(&self) -> Bank

Get the bank of this pin. See also Bank.

§Example
use embassy_nxp::gpio::{Bank, Flex};

let p = embassy_nxp::init(Default::default());
let pin = Flex::new(p.PIO1_15);

assert_eq!(pin.pin_bank(), Bank::Bank1);
Source

pub fn pin_number(&self) -> u8

Get the number of this pin within its bank. See also Bank.

§Example
use embassy_nxp::gpio::Flex;

let p = embassy_nxp::init(Default::default());
let pin = Flex::new(p.PIO1_15);

assert_eq!(pin.pin_number(), 15 as u8);
Source

pub fn bit(&self) -> u32

Get the bit mask for this pin. Useful for setting or clearing bits in a register. Note: PIOx_0 is bit 0, PIOx_1 is bit 1, etc.

§Example
use embassy_nxp::gpio::Flex;

let p = embassy_nxp::init(Default::default());
let pin = Flex::new(p.PIO1_3);

assert_eq!(pin.bit(), 0b0000_1000);
Source

pub fn set_as_output(&mut self)

Set the pin in output mode. This implies setting the pin to digital mode, which this function handles itself.

Source

pub fn set_as_input(&mut self)

Source§

impl Flex<'_>

Source

pub async fn wait_for_any_edge(&mut self) -> Option<()>

Wait for a falling or rising edge on the pin. You can have at most 8 pins waiting. If you try to wait for more than 8 pins, this function will return None.

Source

pub async fn wait_for_falling_edge(&mut self) -> Option<()>

Wait for a falling edge on the pin. You can have at most 8 pins waiting. If you try to wait for more than 8 pins, this function will return None.

Source

pub async fn wait_for_rising_edge(&mut self) -> Option<()>

Wait for a rising edge on the pin. You can have at most 8 pins waiting. If you try to wait for more than 8 pins, this function will return None.

Source

pub async fn wait_for_low(&mut self) -> Option<()>

Wait for a low level on the pin. You can have at most 8 pins waiting. If you try to wait for more than 8 pins, this function will return None.

Source

pub async fn wait_for_high(&mut self) -> Option<()>

Wait for a high level on the pin. You can have at most 8 pins waiting. If you try to wait for more than 8 pins, this function will return None.

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.