embassy-stm32

Crates

git

Versions

stm32h753ii

Flavors

ExtiInput

Struct ExtiInput 

Source
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, Mode: PeriMode> ExtiInput<'d, Mode>

Source

pub fn is_high(&self) -> bool

Get whether the pin is high.

Source

pub fn is_low(&self) -> bool

Get whether the pin is low.

Source

pub fn get_level(&self) -> Level

Get the pin level.

Source§

impl<'d> ExtiInput<'d, Async>

Source

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.

Source

pub async fn wait_for_high(&mut self)

Asynchronously wait until the pin is high.

This returns immediately if the pin is already high.

Source

pub async fn wait_for_low(&mut self)

Asynchronously wait until the pin is low.

This returns immediately if the pin is already low.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn wait_for_any_edge(&mut self)

Asynchronously wait until the pin sees any edge (either rising or falling).

Source

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>

Source

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 use
  • ch - The EXTI channel corresponding to the pin (consumed for ownership tracking)
  • pull - The pull configuration for the pin
  • trigger_edge - The edge triggering mode (falling, rising, or any)
§Returns

A new ExtiInput instance with interrupts enabled

Source

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.

Source

pub fn enable_interrupt(&mut self)

Enables the EXTI interrupt for this pin

Source

pub fn disable_interrupt(&mut self)

Disables the EXTI interrupt for this pin

Source

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.

Source

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

Trait Implementations§

Source§

impl<'d, Mode: PeriMode> ErrorType for ExtiInput<'d, Mode>

Source§

type Error = Infallible

Error type
Source§

impl<'d, Mode: PeriMode> InputPin for ExtiInput<'d, Mode>

Source§

type Error = Infallible

Error type
Source§

fn is_high(&self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl<'d, Mode: PeriMode> InputPin for ExtiInput<'d, Mode>

Source§

fn is_high(&mut self) -> Result<bool, Self::Error>

Is the input pin high?
Source§

fn is_low(&mut self) -> Result<bool, Self::Error>

Is the input pin low?
Source§

impl<'d> Wait for ExtiInput<'d, Async>

Source§

async fn wait_for_high(&mut self) -> Result<(), Self::Error>

Wait until the pin is high. If it is already high, return immediately. Read more
Source§

async fn wait_for_low(&mut self) -> Result<(), Self::Error>

Wait until the pin is low. If it is already low, return immediately. Read more
Source§

async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo a transition from low to high. Read more
Source§

async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo a transition from high to low. Read more
Source§

async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error>

Wait for the pin to undergo any transition, i.e low to high OR high to low.
Source§

impl<'d, Mode: PeriMode> Unpin for ExtiInput<'d, Mode>

Auto Trait Implementations§

§

impl<'d, Mode> Freeze for ExtiInput<'d, Mode>

§

impl<'d, Mode> RefUnwindSafe for ExtiInput<'d, Mode>
where Mode: RefUnwindSafe,

§

impl<'d, Mode> Send for ExtiInput<'d, Mode>
where Mode: Send,

§

impl<'d, Mode> Sync for ExtiInput<'d, Mode>
where Mode: Sync,

§

impl<'d, Mode> !UnwindSafe for ExtiInput<'d, Mode>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.