From c97d5262f56814639fa995c8426384efdf379c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Kr=C3=B6ger?= Date: Wed, 30 Dec 2020 12:15:49 +0100 Subject: [PATCH] Blocking wait method for signals --- embassy/src/util/signal.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/embassy/src/util/signal.rs b/embassy/src/util/signal.rs index bde10c56..cb641061 100644 --- a/embassy/src/util/signal.rs +++ b/embassy/src/util/signal.rs @@ -62,4 +62,13 @@ impl Signal { pub fn wait(&self) -> impl Future + '_ { futures::future::poll_fn(move |cx| self.poll_wait(cx)) } + + /// Blocks until the signal has been received. + /// + /// Returns immediately when [`poll_wait()`] has not been called before. + pub fn blocking_wait(&self) { + while cortex_m::interrupt::free(|_| { + matches!(unsafe { &*self.state.get() }, State::Waiting(_)) + }) {} + } }