pub struct ExtiInput<'d, Mode: PeriMode> { /* private fields */ }Expand description
EXTI input driver.
This driver augments a GPIO Input with EXTI functionality. EXTI is not
built into Input itself because it needs to take ownership of the corresponding
EXTI channel, which is a limited resource.
Pins PA5, PB5, PC5… all use EXTI channel 5, so you can’t use EXTI on, say, PA5 and PC5 at the same time.
Implementations§
Source§impl<'d> ExtiInput<'d, Async>
impl<'d> ExtiInput<'d, Async>
Sourcepub fn new<T: ExtiPin + GpioPin>(
pin: Peri<'d, T>,
_ch: Peri<'d, T::ExtiChannel>,
pull: Pull,
_irq: impl Binding<<<T as ExtiPin>::ExtiChannel as Channel>::IRQ, InterruptHandler<<<T as ExtiPin>::ExtiChannel as Channel>::IRQ>>,
) -> Self
pub fn new<T: ExtiPin + GpioPin>( pin: Peri<'d, T>, _ch: Peri<'d, T::ExtiChannel>, pull: Pull, _irq: impl Binding<<<T as ExtiPin>::ExtiChannel as Channel>::IRQ, InterruptHandler<<<T as ExtiPin>::ExtiChannel as Channel>::IRQ>>, ) -> Self
Create an EXTI input.
The Binding must bind the Channel’s IRQ to InterruptHandler.
Sourcepub async fn wait_for_high(&mut self)
pub async fn wait_for_high(&mut self)
Asynchronously wait until the pin is high.
This returns immediately if the pin is already high.
Sourcepub async fn wait_for_low(&mut self)
pub async fn wait_for_low(&mut self)
Asynchronously wait until the pin is low.
This returns immediately if the pin is already low.
Sourcepub async fn wait_for_rising_edge(&mut self)
pub async fn wait_for_rising_edge(&mut self)
Asynchronously wait until the pin sees a rising edge.
If the pin is already high, it will wait for it to go low then back high.
Sourcepub fn poll_for_rising_edge<'a>(&mut self, cx: &mut Context<'a>)
pub fn poll_for_rising_edge<'a>(&mut self, cx: &mut Context<'a>)
Asynchronously wait until the pin sees a rising edge.
If the pin is already high, it will wait for it to go low then back high.
Sourcepub async fn wait_for_falling_edge(&mut self)
pub async fn wait_for_falling_edge(&mut self)
Asynchronously wait until the pin sees a falling edge.
If the pin is already low, it will wait for it to go high then back low.
Sourcepub fn poll_for_falling_edge<'a>(&mut self, cx: &mut Context<'a>)
pub fn poll_for_falling_edge<'a>(&mut self, cx: &mut Context<'a>)
Asynchronously wait until the pin sees a falling edge.
If the pin is already low, it will wait for it to go high then back low.
Sourcepub async fn wait_for_any_edge(&mut self)
pub async fn wait_for_any_edge(&mut self)
Asynchronously wait until the pin sees any edge (either rising or falling).
Sourcepub fn poll_for_any_edge<'a>(&mut self, cx: &mut Context<'a>)
pub fn poll_for_any_edge<'a>(&mut self, cx: &mut Context<'a>)
Asynchronously wait until the pin sees any edge (either rising or falling).
Source§impl<'d> ExtiInput<'d, Blocking>
impl<'d> ExtiInput<'d, Blocking>
Sourcepub fn new_blocking<T: GpioPin + ExtiPin>(
pin: Peri<'d, T>,
_ch: Peri<'d, T::ExtiChannel>,
pull: Pull,
trigger_edge: TriggerEdge,
) -> Self
pub fn new_blocking<T: GpioPin + ExtiPin>( pin: Peri<'d, T>, _ch: Peri<'d, T::ExtiChannel>, pull: Pull, trigger_edge: TriggerEdge, ) -> Self
Creates a new EXTI input for use with manual interrupt handling.
This configures and enables the EXTI interrupt for the pin, but does not provide async methods for waiting on events. You must provide your own interrupt handler to service EXTI events and clear pending flags.
For async/await integration with Embassy’s executor, use ExtiInput<Async> instead.
§Arguments
pin- The GPIO pin to usech- The EXTI channel corresponding to the pin (consumed for ownership tracking)pull- The pull configuration for the pintrigger_edge- The edge triggering mode (falling, rising, or any)
§Returns
A new ExtiInput instance with interrupts enabled
Sourcepub fn set_edge_detection(&mut self, trigger_edge: TriggerEdge)
pub fn set_edge_detection(&mut self, trigger_edge: TriggerEdge)
Reconfigures the edge detection mode for this pin’s EXTI line
This method updates which edges (rising, falling, or any) will trigger interrupts for this pin. Note that reconfiguring the edge detection will clear any pending interrupt flag for this pin.
Sourcepub fn enable_interrupt(&mut self)
pub fn enable_interrupt(&mut self)
Enables the EXTI interrupt for this pin
Sourcepub fn disable_interrupt(&mut self)
pub fn disable_interrupt(&mut self)
Disables the EXTI interrupt for this pin
Sourcepub fn clear_pending(&mut self)
pub fn clear_pending(&mut self)
Clears any pending interrupt for this pin
This method clears the pending interrupt flag for the EXTI line associated with this pin. This should typically be called from the interrupt handler after processing an interrupt.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Checks if an interrupt is pending for the current pin
This method checks if there is a pending interrupt on the EXTI line associated with this pin.
§Returns
true if an interrupt is pending, false otherwise