embassy/embassy-traits/src/gpio.rs

48 lines
1.5 KiB
Rust
Raw Normal View History

2021-01-06 01:10:48 +01:00
use core::future::Future;
/// Wait for a pin to become high.
pub trait WaitForHigh {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for a pin to become high.
///
/// If the pin is already high, the future completes immediately.
/// Otherwise, it completes when it becomes high.
2021-04-14 16:25:54 +02:00
fn wait_for_high<'a>(&'a mut self) -> Self::Future<'a>;
2021-01-06 01:10:48 +01:00
}
/// Wait for a pin to become low.
pub trait WaitForLow {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for a pin to become low.
///
/// If the pin is already low, the future completes immediately.
/// Otherwise, it completes when it becomes low.
2021-04-14 16:25:54 +02:00
fn wait_for_low<'a>(&'a mut self) -> Self::Future<'a>;
2021-01-06 01:10:48 +01:00
}
/// Wait for a rising edge (transition from low to high)
pub trait WaitForRisingEdge {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for a rising edge (transition from low to high)
2021-04-14 16:25:54 +02:00
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::Future<'a>;
2021-01-06 01:10:48 +01:00
}
/// Wait for a falling edge (transition from high to low)
pub trait WaitForFallingEdge {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for a falling edge (transition from high to low)
2021-04-14 16:25:54 +02:00
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::Future<'a>;
2021-01-06 01:10:48 +01:00
}
/// Wait for any edge (any transition, high to low or low to high)
pub trait WaitForAnyEdge {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for any edge (any transition, high to low or low to high)
2021-04-14 16:25:54 +02:00
fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a>;
2021-01-06 01:10:48 +01:00
}