stm32/exti: expose all functionality as inherent methods.
This commit is contained in:
parent
58fc64722c
commit
b526addf7b
@ -102,6 +102,18 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
||||
pub fn is_low(&self) -> bool {
|
||||
self.pin.is_low()
|
||||
}
|
||||
|
||||
pub async fn wait_for_rising_edge<'a>(&'a mut self) {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false).await
|
||||
}
|
||||
|
||||
pub async fn wait_for_falling_edge<'a>(&'a mut self) {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true).await
|
||||
}
|
||||
|
||||
pub async fn wait_for_any_edge<'a>(&'a mut self) {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, true).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> InputPin for ExtiInput<'d, T> {
|
||||
@ -120,10 +132,10 @@ impl<'d, T: GpioPin> WaitForRisingEdge for ExtiInput<'d, T> {
|
||||
type Future<'a>
|
||||
where
|
||||
Self: 'a,
|
||||
= ExtiInputFuture<'a>;
|
||||
= impl Future<Output = ()> + 'a;
|
||||
|
||||
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::Future<'a> {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false)
|
||||
self.wait_for_rising_edge()
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,10 +143,10 @@ impl<'d, T: GpioPin> WaitForFallingEdge for ExtiInput<'d, T> {
|
||||
type Future<'a>
|
||||
where
|
||||
Self: 'a,
|
||||
= ExtiInputFuture<'a>;
|
||||
= impl Future<Output = ()> + 'a;
|
||||
|
||||
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::Future<'a> {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true)
|
||||
self.wait_for_falling_edge()
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,14 +154,14 @@ impl<'d, T: GpioPin> WaitForAnyEdge for ExtiInput<'d, T> {
|
||||
type Future<'a>
|
||||
where
|
||||
Self: 'a,
|
||||
= ExtiInputFuture<'a>;
|
||||
= impl Future<Output = ()> + 'a;
|
||||
|
||||
fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> {
|
||||
ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, true)
|
||||
self.wait_for_any_edge()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExtiInputFuture<'a> {
|
||||
struct ExtiInputFuture<'a> {
|
||||
pin: u8,
|
||||
phantom: PhantomData<&'a mut AnyPin>,
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -9,7 +9,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
fn config() -> embassy_stm32::Config {
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -8,7 +8,6 @@ use embassy::executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embassy_traits::gpio::{WaitForFallingEdge, WaitForRisingEdge};
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
|
@ -10,7 +10,6 @@ mod example_common;
|
||||
|
||||
use embassy::channel::signal::Signal;
|
||||
use embassy::interrupt::{Interrupt, InterruptExt};
|
||||
use embassy::traits::gpio::WaitForRisingEdge;
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
|
Loading…
Reference in New Issue
Block a user