pub struct Flex<'d> { /* private fields */ }
Expand description
GPIO flexible pin.
This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain set while not in output mode, so the pin’s level will be ‘remembered’ when it is not in output mode.
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
.
The pin remains disconnected. The initial output level is unspecified, but can be changed before the pin is put into output mode.
Sourcepub fn set_as_input(&mut self)
pub fn set_as_input(&mut self)
Put the pin into input mode.
The pull setting is left unchanged.
Sourcepub fn set_as_output(&mut self)
pub fn set_as_output(&mut self)
Put the pin into output mode.
The pin level will be whatever was set before (or low by default). If you want it to begin
at a specific level, call set_high
/set_low
on the pin first.
Sourcepub fn set_as_input_output(&mut self)
pub fn set_as_input_output(&mut self)
Put the pin into input + open-drain output mode.
The hardware will drive the line low if you set it to low, and will leave it floating if you set it to high, in which case you can read the input to figure out whether another device is driving the line low.
The pin level will be whatever was set before (or low by default). If you want it to begin
at a specific level, call set_high
/set_low
on the pin first.
The internal weak pull-up and pull-down resistors will be disabled.
Sourcepub fn set_as_disconnected(&mut self)
pub fn set_as_disconnected(&mut self)
Set the pin as “disconnected”, ie doing nothing and consuming the lowest amount of power possible.
This is currently the same as [Self::set_as_analog()
] but is semantically different
really. Drivers should set_as_disconnected()
pins when dropped.
Note that this also disables the internal weak pull-up and pull-down resistors.
Sourcepub fn set_inversion(&mut self, invert: bool)
pub fn set_inversion(&mut self, invert: bool)
Configure the logic inversion of this pin.
Logic inversion applies to both the input and output path of this pin.
Sourcepub fn set_pf_unchecked(&mut self, pf: u8)
pub fn set_pf_unchecked(&mut self, pf: u8)
Put the pin into the PF mode, unchecked.
This puts the pin into the PF mode, with the request number. This is completely unchecked, it can attach the pin to literally any peripheral, so use with care. In addition the pin peripheral is connected in the iomux.
The peripheral attached to the pin depends on the part in use. Consult the datasheet or technical reference manual for additional details.
Sourcepub fn get_output_level(&self) -> Level
pub fn get_output_level(&self) -> Level
Get the current pin input level.
Sourcepub fn is_set_high(&self) -> bool
pub fn is_set_high(&self) -> bool
Is the output level high?
Sourcepub fn is_set_low(&self) -> bool
pub fn is_set_low(&self) -> bool
Is the output level low?
Sourcepub async fn wait_for_high(&mut self)
pub async fn wait_for_high(&mut self)
Wait until the pin is high. If it is already high, return immediately.
Sourcepub async fn wait_for_low(&mut self)
pub async fn wait_for_low(&mut self)
Wait until the pin is low. If it is already low, return immediately.
Sourcepub async fn wait_for_rising_edge(&mut self)
pub async fn wait_for_rising_edge(&mut self)
Wait for the pin to undergo a transition from low to high.
Sourcepub async fn wait_for_falling_edge(&mut self)
pub async fn wait_for_falling_edge(&mut self)
Wait for the pin to undergo a transition from high to low.
Sourcepub async fn wait_for_any_edge(&mut self)
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.