pub struct Flex<'d> { /* private fields */ }
Expand description
Flexible pin driver.
This driver allows changing the pin mode between input and output.
Implementations§
Source§impl Flex<'_>
impl Flex<'_>
Sourcepub async fn wait_for(&mut self, event: Event)
Available on crate feature unstable
only.
pub async fn wait_for(&mut self, event: Event)
unstable
only.Wait until the pin experiences a particular Event
.
The GPIO driver will disable listening for the event once it occurs,
or if the Future
is dropped.
Note that calling this function will overwrite previous
listen
operations for this pin.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub async fn wait_for_high(&mut self)
Available on crate feature unstable
only.
pub async fn wait_for_high(&mut self)
unstable
only.Wait until the pin is high.
See Self::wait_for for more information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub async fn wait_for_low(&mut self)
Available on crate feature unstable
only.
pub async fn wait_for_low(&mut self)
unstable
only.Wait until the pin is low.
See Self::wait_for for more information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub async fn wait_for_rising_edge(&mut self)
Available on crate feature unstable
only.
pub async fn wait_for_rising_edge(&mut self)
unstable
only.Wait for the pin to undergo a transition from low to high.
See Self::wait_for for more information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub async fn wait_for_falling_edge(&mut self)
Available on crate feature unstable
only.
pub async fn wait_for_falling_edge(&mut self)
unstable
only.Wait for the pin to undergo a transition from high to low.
See Self::wait_for for more information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub async fn wait_for_any_edge(&mut self)
Available on crate feature unstable
only.
pub async fn wait_for_any_edge(&mut self)
unstable
only.Wait for the pin to undergo any transition, i.e low to high OR high to low.
See Self::wait_for for more information.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl<'d> Flex<'d>
impl<'d> Flex<'d>
Sourcepub fn new(pin: impl Peripheral<P = impl Into<AnyPin>> + 'd) -> Self
Available on crate feature unstable
only.
pub fn new(pin: impl Peripheral<P = impl Into<AnyPin>> + 'd) -> Self
unstable
only.Sourcepub fn peripheral_input(&self) -> InputSignal
Available on crate feature unstable
only.
pub fn peripheral_input(&self) -> InputSignal
unstable
only.Returns a peripheral input connected to this pin.
The input signal can be passed to peripherals in place of an input pin.
let pin1_gpio = Flex::new(peripherals.GPIO1);
// Can be passed as an input.
let pin1 = pin1_gpio.peripheral_input();
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_high(&self) -> bool
Available on crate feature unstable
only.
pub fn is_high(&self) -> bool
unstable
only.Get whether the pin input level is high.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_low(&self) -> bool
Available on crate feature unstable
only.
pub fn is_low(&self) -> bool
unstable
only.Get whether the pin input level is low.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn level(&self) -> Level
Available on crate feature unstable
only.
pub fn level(&self) -> Level
unstable
only.Get the current pin input level.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn listen(&mut self, event: Event)
Available on crate feature unstable
only.
pub fn listen(&mut self, event: Event)
unstable
only.Listen for interrupts.
See Input::listen
for more information and an example.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn unlisten(&mut self)
Available on crate feature unstable
only.
pub fn unlisten(&mut self)
unstable
only.Stop listening for interrupts.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_listening(&self) -> bool
Available on crate feature unstable
only.
pub fn is_listening(&self) -> bool
unstable
only.Check if the pin is listening for interrupts.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn clear_interrupt(&mut self)
Available on crate feature unstable
only.
pub fn clear_interrupt(&mut self)
unstable
only.Clear the interrupt status bit for this Pin
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_interrupt_set(&self) -> bool
Available on crate feature unstable
only.
pub fn is_interrupt_set(&self) -> bool
unstable
only.Checks if the interrupt status bit for this Pin is set
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn wakeup_enable(
&mut self,
enable: bool,
event: WakeEvent,
) -> Result<(), WakeConfigError>
Available on crate feature unstable
only.
pub fn wakeup_enable( &mut self, enable: bool, event: WakeEvent, ) -> Result<(), WakeConfigError>
unstable
only.Enable as a wake-up source.
This will unlisten for interrupts
§Error
Configuring pin to wake up from light sleep on an edge
trigger is currently not supported, corresponding variant of
WakeConfigError
will be returned.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_as_output(&mut self)
Available on crate feature unstable
only.
pub fn set_as_output(&mut self)
unstable
only.Set the GPIO to output mode.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_high(&mut self)
Available on crate feature unstable
only.
pub fn set_high(&mut self)
unstable
only.Set the output as high.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_low(&mut self)
Available on crate feature unstable
only.
pub fn set_low(&mut self)
unstable
only.Set the output as low.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_level(&mut self, level: Level)
Available on crate feature unstable
only.
pub fn set_level(&mut self, level: Level)
unstable
only.Set the output level.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_set_high(&self) -> bool
Available on crate feature unstable
only.
pub fn is_set_high(&self) -> bool
unstable
only.Is the output pin set as high?
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn is_set_low(&self) -> bool
Available on crate feature unstable
only.
pub fn is_set_low(&self) -> bool
unstable
only.Is the output pin set as low?
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn output_level(&self) -> Level
Available on crate feature unstable
only.
pub fn output_level(&self) -> Level
unstable
only.What level output is set to
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn toggle(&mut self)
Available on crate feature unstable
only.
pub fn toggle(&mut self)
unstable
only.Toggle pin output
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_drive_strength(&mut self, strength: DriveStrength)
Available on crate feature unstable
only.
pub fn set_drive_strength(&mut self, strength: DriveStrength)
unstable
only.Configure the DriveStrength of the pin
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn set_as_open_drain(&mut self, pull: Pull)
Available on crate feature unstable
only.
pub fn set_as_open_drain(&mut self, pull: Pull)
unstable
only.Set the GPIO to open-drain mode.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn pull_direction(&mut self, pull: Pull)
Available on crate feature unstable
only.
pub fn pull_direction(&mut self, pull: Pull)
unstable
only.Configure pullup/pulldown resistors.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn enable_input(&mut self, enable_input: bool)
Available on crate feature unstable
only.
pub fn enable_input(&mut self, enable_input: bool)
unstable
only.Enable or disable the GPIO pin input buffer.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn apply_output_config(&mut self, config: &OutputConfig)
Available on crate feature unstable
only.
pub fn apply_output_config(&mut self, config: &OutputConfig)
unstable
only.Applies the given output configuration to the pin.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn apply_input_config(&mut self, config: &InputConfig)
Available on crate feature unstable
only.
pub fn apply_input_config(&mut self, config: &InputConfig)
unstable
only.Applies the given input configuration to the pin.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn split(self) -> (InputSignal, OutputSignal)
Available on crate feature unstable
only.
pub fn split(self) -> (InputSignal, OutputSignal)
unstable
only.Split the pin into an input and output signal.
Peripheral signals allow connecting peripherals together without using external hardware.
let pin1 = Flex::new(peripherals.GPIO1);
let (input, output) = pin1.split();
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Sourcepub fn into_peripheral_output(self) -> OutputSignal
Available on crate feature unstable
only.
pub fn into_peripheral_output(self) -> OutputSignal
unstable
only.Turns the pin object into a peripheral output.
The output signal can be passed to peripherals in place of an output pin.
let pin1_gpio = Flex::new(peripherals.GPIO1);
// Can be passed as an output.
let pin1 = pin1_gpio.into_peripheral_output();
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl ErrorType for Flex<'_>
Available on crate feature unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl ErrorType for Flex<'_>
unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl From<Flex<'static>> for InputConnection
Available on crate feature unstable
only.
impl From<Flex<'static>> for InputConnection
unstable
only.Source§impl From<Flex<'static>> for InputSignal
Available on crate feature unstable
only.
impl From<Flex<'static>> for InputSignal
unstable
only.Source§impl From<Flex<'static>> for OutputConnection
Available on crate feature unstable
only.
impl From<Flex<'static>> for OutputConnection
unstable
only.Source§impl From<Flex<'static>> for OutputSignal
Available on crate feature unstable
only.
impl From<Flex<'static>> for OutputSignal
unstable
only.Source§impl InputPin for Flex<'_>
Available on crate feature unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl InputPin for Flex<'_>
unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl OutputPin for Flex<'_>
Available on crate feature unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl OutputPin for Flex<'_>
unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl Peripheral for Flex<'_>
impl Peripheral for Flex<'_>
Source§unsafe fn clone_unchecked(&self) -> Self::P
unsafe fn clone_unchecked(&self) -> Self::P
Source§fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>where
Self: 'a,
fn into_ref<'a>(self) -> PeripheralRef<'a, Self::P>where
Self: 'a,
PeripheralRef
. Read moreSource§impl StatefulOutputPin for Flex<'_>
Available on crate feature unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl StatefulOutputPin for Flex<'_>
unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§impl Wait for Flex<'_>
Available on crate feature unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl Wait for Flex<'_>
unstable
only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§async fn wait_for_high(&mut self) -> Result<(), Self::Error>
async fn wait_for_high(&mut self) -> Result<(), Self::Error>
Source§async fn wait_for_low(&mut self) -> Result<(), Self::Error>
async fn wait_for_low(&mut self) -> Result<(), Self::Error>
Source§async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error>
async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error>
Source§async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error>
async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error>
Source§async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error>
async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error>
impl PeripheralInput for Flex<'static>
unstable
only.impl PeripheralOutput for Flex<'static>
unstable
only.