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.
Sourcepub fn set_as_output(&mut self, drive: OutputDrive)
pub fn set_as_output(&mut self, drive: OutputDrive)
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, pull: Pull, drive: OutputDrive)
pub fn set_as_input_output(&mut self, pull: Pull, drive: OutputDrive)
Put the pin into input + output mode.
This is commonly used for “open drain” mode. If you set drive = Standard0Disconnect1
,
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.
Sourcepub fn set_as_disconnected(&mut self)
pub fn set_as_disconnected(&mut self)
Put the pin into disconnected 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.
Trait Implementations§
Source§impl<'d> InputPin for Flex<'d>
impl<'d> InputPin for Flex<'d>
Implement embedded_hal_02::digital::v2::InputPin
for Flex
;
If the pin is not in input mode the result is unspecified.
Source§impl<'d> InputPin for Flex<'d>
impl<'d> InputPin for Flex<'d>
Implement [InputPin
] for Flex
;
If the pin is not in input mode the result is unspecified.