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, 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)
pub fn set_as_output(&mut self)
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_open_drain(&mut self)
pub fn set_as_open_drain(&mut self)
Put the pin into open-drain output mode.
Sourcepub fn set_as_alternate(&mut self, mode: AltMode)
pub fn set_as_alternate(&mut self, mode: AltMode)
Put the pin into alternate function mode.
Sourcepub fn set_as_analog(&mut self)
pub fn set_as_analog(&mut self)
Put the pin into analog mode.
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.