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_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.