aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy/src/gpio.rs48
-rw-r--r--embassy/src/lib.rs1
2 files changed, 49 insertions, 0 deletions
diff --git a/embassy/src/gpio.rs b/embassy/src/gpio.rs
new file mode 100644
index 000000000..4c3feac21
--- /dev/null
+++ b/embassy/src/gpio.rs
@@ -0,0 +1,48 @@
1use core::future::Future;
2use core::pin::Pin;
3
4/// Wait for a pin to become high.
5pub trait WaitForHigh {
6 type Future<'a>: Future<Output = ()> + 'a;
7
8 /// Wait for a pin to become high.
9 ///
10 /// If the pin is already high, the future completes immediately.
11 /// Otherwise, it completes when it becomes high.
12 fn wait_for_high<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a>;
13}
14
15/// Wait for a pin to become low.
16pub trait WaitForLow {
17 type Future<'a>: Future<Output = ()> + 'a;
18
19 /// Wait for a pin to become low.
20 ///
21 /// If the pin is already low, the future completes immediately.
22 /// Otherwise, it completes when it becomes low.
23 fn wait_for_low<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a>;
24}
25
26/// Wait for a rising edge (transition from low to high)
27pub trait WaitForRisingEdge {
28 type Future<'a>: Future<Output = ()> + 'a;
29
30 /// Wait for a rising edge (transition from low to high)
31 fn wait_for_rising_edge<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a>;
32}
33
34/// Wait for a falling edge (transition from high to low)
35pub trait WaitForFallingEdge {
36 type Future<'a>: Future<Output = ()> + 'a;
37
38 /// Wait for a falling edge (transition from high to low)
39 fn wait_for_falling_edge<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a>;
40}
41
42/// Wait for any edge (any transition, high to low or low to high)
43pub trait WaitForAnyEdge {
44 type Future<'a>: Future<Output = ()> + 'a;
45
46 /// Wait for any edge (any transition, high to low or low to high)
47 fn wait_for_any_edge<'a>(self: Pin<&'a mut Self>) -> Self::Future<'a>;
48}
diff --git a/embassy/src/lib.rs b/embassy/src/lib.rs
index 02d72a84f..4fa37a55c 100644
--- a/embassy/src/lib.rs
+++ b/embassy/src/lib.rs
@@ -8,6 +8,7 @@ pub(crate) mod fmt;
8 8
9pub mod executor; 9pub mod executor;
10pub mod flash; 10pub mod flash;
11pub mod gpio;
11pub mod interrupt; 12pub mod interrupt;
12pub mod io; 13pub mod io;
13pub mod rand; 14pub mod rand;