aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/src/gpiote.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index ead3c47d3..fbd8c093c 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -3,7 +3,7 @@ use core::future::Future;
3use core::marker::PhantomData; 3use core::marker::PhantomData;
4use core::task::{Context, Poll}; 4use core::task::{Context, Poll};
5use embassy::interrupt::InterruptExt; 5use embassy::interrupt::InterruptExt;
6use embassy::traits::gpio::{WaitForHigh, WaitForLow}; 6use embassy::traits::gpio::{WaitForAnyEdge, WaitForHigh, WaitForLow};
7use embassy::util::AtomicWaker; 7use embassy::util::AtomicWaker;
8use embassy_extras::impl_unborrow; 8use embassy_extras::impl_unborrow;
9use embedded_hal::digital::v2::{InputPin, StatefulOutputPin}; 9use embedded_hal::digital::v2::{InputPin, StatefulOutputPin};
@@ -340,6 +340,21 @@ impl<'d, T: GpioPin> WaitForLow for PortInput<'d, T> {
340 } 340 }
341} 341}
342 342
343impl<'d, T: GpioPin> WaitForAnyEdge for PortInput<'d, T> {
344 type Future<'a> = PortInputFuture<'a>;
345 fn wait_for_any_edge<'a>(&'a mut self) -> Self::Future<'a> {
346 if self.is_high().ok().unwrap() {
347 self.pin.pin.conf().modify(|_, w| w.sense().low());
348 } else {
349 self.pin.pin.conf().modify(|_, w| w.sense().high());
350 }
351 PortInputFuture {
352 pin_port: self.pin.pin.pin_port(),
353 phantom: PhantomData,
354 }
355 }
356}
357
343pub struct PortInputFuture<'a> { 358pub struct PortInputFuture<'a> {
344 pin_port: u8, 359 pin_port: u8,
345 phantom: PhantomData<&'a mut AnyPin>, 360 phantom: PhantomData<&'a mut AnyPin>,