aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/src/gpiote.rs22
-rw-r--r--embassy/src/util/waker.rs3
2 files changed, 10 insertions, 15 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index 920d69236..9ea008f01 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -395,9 +395,8 @@ pub struct PortInputFuture<'a> {
395 395
396impl<'a> Drop for PortInputFuture<'a> { 396impl<'a> Drop for PortInputFuture<'a> {
397 fn drop(&mut self) { 397 fn drop(&mut self) {
398 unsafe { AnyPin::steal(self.pin_port) } 398 let pin = unsafe { AnyPin::steal(self.pin_port) };
399 .conf() 399 pin.conf().modify(|_, w| w.sense().disabled());
400 .modify(|_, w| w.sense().disabled());
401 } 400 }
402} 401}
403 402
@@ -405,18 +404,13 @@ impl<'a> Future for PortInputFuture<'a> {
405 type Output = (); 404 type Output = ();
406 405
407 fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { 406 fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
408 let dis = unsafe { AnyPin::steal(self.pin_port) }
409 .conf()
410 .read()
411 .sense()
412 .is_disabled();
413
414 if dis {
415 return Poll::Ready(());
416 }
417
418 PORT_WAKERS[self.pin_port as usize].register(cx.waker()); 407 PORT_WAKERS[self.pin_port as usize].register(cx.waker());
419 408
420 Poll::Pending 409 let pin = unsafe { AnyPin::steal(self.pin_port) };
410 if pin.conf().read().sense().is_disabled() {
411 Poll::Ready(())
412 } else {
413 Poll::Pending
414 }
421 } 415 }
422} 416}
diff --git a/embassy/src/util/waker.rs b/embassy/src/util/waker.rs
index cd53cca61..393155099 100644
--- a/embassy/src/util/waker.rs
+++ b/embassy/src/util/waker.rs
@@ -1,7 +1,7 @@
1use core::ptr::{self, NonNull}; 1use core::ptr::{self, NonNull};
2use core::task::Waker; 2use core::task::Waker;
3 3
4use atomic_polyfill::{AtomicPtr, Ordering}; 4use atomic_polyfill::{compiler_fence, AtomicPtr, Ordering};
5 5
6use crate::executor::raw::{task_from_waker, wake_task, TaskHeader}; 6use crate::executor::raw::{task_from_waker, wake_task, TaskHeader};
7 7
@@ -63,6 +63,7 @@ impl AtomicWaker {
63 pub fn register(&self, w: &Waker) { 63 pub fn register(&self, w: &Waker) {
64 let w = unsafe { task_from_waker(w) }; 64 let w = unsafe { task_from_waker(w) };
65 self.waker.store(w.as_ptr(), Ordering::Relaxed); 65 self.waker.store(w.as_ptr(), Ordering::Relaxed);
66 compiler_fence(Ordering::SeqCst);
66 } 67 }
67 68
68 /// Wake the registered waker, if any. 69 /// Wake the registered waker, if any.