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: impl Peripheral<P = impl Pin> + 'd) -> Self
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> 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, pull: Pull)
pub fn set_as_input(&mut self, pull: Pull)
Put the pin into input mode.
The internal weak pull-up and pull-down resistors will be enabled according to pull
.
sourcepub fn set_as_output(&mut self, speed: Speed)
pub fn set_as_output(&mut self, speed: Speed)
Put the pin into push-pull 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.
The internal weak pull-up and pull-down resistors will be disabled.
sourcepub fn set_as_input_output(&mut self, speed: Speed)
pub fn set_as_input_output(&mut self, speed: Speed)
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_input_output_pull(&mut self, speed: Speed, pull: Pull)
pub fn set_as_input_output_pull(&mut self, speed: Speed, pull: Pull)
Put the pin into input + open-drain output mode with internal pullup or pulldown.
This works like Self::set_as_input_output()
, but it also allows to enable the internal
weak pull-up or pull-down resistors.
sourcepub fn set_as_analog(&mut self)
pub fn set_as_analog(&mut self)
Put the pin into analog mode
This mode is used by ADC and COMP but usually there is no need to set this manually as the mode change is handled by the driver.
sourcepub fn set_as_af_unchecked(&mut self, af_num: u8, af_type: AfType)
pub fn set_as_af_unchecked(&mut self, af_num: u8, af_type: AfType)
Put the pin into AF mode, unchecked.
This puts the pin into the AF mode, with the requested number and AF type. This is completely unchecked, it can attach the pin to literally any peripheral, so use with care.
sourcepub fn is_set_high(&self) -> bool
pub fn is_set_high(&self) -> bool
Get whether the output level is set to high.
sourcepub fn is_set_low(&self) -> bool
pub fn is_set_low(&self) -> bool
Get whether the output level is set to low.
sourcepub fn get_output_level(&self) -> Level
pub fn get_output_level(&self) -> Level
Get the current output level.