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>
impl<'d> Flex<'d>
Sourcepub fn new(pin: Peri<'d, impl Pin>) -> Self
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.
Sourcepub fn pin_number(&self) -> u8
pub fn pin_number(&self) -> u8
Sourcepub fn bit(&self) -> u32
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);
Sourcepub fn set_as_output(&mut self)
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.
pub fn set_as_input(&mut self)
Source§impl Flex<'_>
impl Flex<'_>
Sourcepub async fn wait_for_any_edge(&mut self) -> Option<()>
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
.
Sourcepub async fn wait_for_falling_edge(&mut self) -> Option<()>
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
.
Sourcepub async fn wait_for_rising_edge(&mut self) -> Option<()>
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
.
Sourcepub async fn wait_for_low(&mut self) -> Option<()>
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
.
Sourcepub async fn wait_for_high(&mut self) -> Option<()>
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
.