From 687dda106f5090a3c056f503827d0fec3b8b2fa5 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Mon, 10 May 2021 20:16:13 +0200 Subject: [PATCH] Read rx amount outside of poll_fn --- embassy-nrf/src/uarte.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/embassy-nrf/src/uarte.rs b/embassy-nrf/src/uarte.rs index 7172f5033..36c9e6b23 100644 --- a/embassy-nrf/src/uarte.rs +++ b/embassy-nrf/src/uarte.rs @@ -400,11 +400,10 @@ impl<'d, U: Instance, T: TimerInstance> ReadUntilIdle for UarteWithIdle<'d, U, T trace!("startrx"); r.tasks_startrx.write(|w| unsafe { w.bits(1) }); - let n: usize = poll_fn(|cx| { + poll_fn(|cx| { s.endrx_waker.register(cx.waker()); if r.events_endrx.read().bits() != 0 { - let n: usize = r.rxd.amount.read().amount().bits() as usize; - return Poll::Ready(n); + return Poll::Ready(()); } Poll::Pending }) @@ -412,6 +411,8 @@ impl<'d, U: Instance, T: TimerInstance> ReadUntilIdle for UarteWithIdle<'d, U, T compiler_fence(Ordering::SeqCst); r.events_rxstarted.reset(); + let n = r.rxd.amount.read().amount().bits() as usize; + // Stop timer rt.tasks_stop.write(|w| unsafe { w.bits(1) }); drop.defuse();