From 69953a78f10905330fb5d682dd5bda01f13a4e0c Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 19 Oct 2021 20:48:46 +0200 Subject: [PATCH] Use async fn instead of impl Future --- embassy-nrf/src/temp.rs | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/embassy-nrf/src/temp.rs b/embassy-nrf/src/temp.rs index bd8fa75a..f7c6e660 100644 --- a/embassy-nrf/src/temp.rs +++ b/embassy-nrf/src/temp.rs @@ -4,7 +4,6 @@ use crate::interrupt; use crate::pac; use crate::peripherals::TEMP; -use core::future::Future; use core::marker::PhantomData; use core::task::Poll; use embassy::interrupt::InterruptExt; @@ -54,7 +53,7 @@ impl<'d> Temp<'d> { /// let mut t = Temp::new(p.TEMP, interrupt::take!(TEMP)); /// let v: u16 = t.read().await.to_num::(); /// ``` - pub fn read(&mut self) -> impl Future { + pub async fn read(&mut self) -> I30F2 { // In case the future is dropped, stop the task and reset events. let on_drop = OnDrop::new(|| { let t = Self::regs(); @@ -66,21 +65,19 @@ impl<'d> Temp<'d> { t.intenset.write(|w| w.datardy().set()); unsafe { t.tasks_start.write(|w| w.bits(1)) }; - async move { - let value = poll_fn(|cx| { - WAKER.register(cx.waker()); - if t.events_datardy.read().bits() == 0 { - return Poll::Pending; - } else { - t.events_datardy.reset(); - let raw = t.temp.read().bits(); - Poll::Ready(I30F2::from_bits(raw as i32)) - } - }) - .await; - on_drop.defuse(); - value - } + let value = poll_fn(|cx| { + WAKER.register(cx.waker()); + if t.events_datardy.read().bits() == 0 { + return Poll::Pending; + } else { + t.events_datardy.reset(); + let raw = t.temp.read().bits(); + Poll::Ready(I30F2::from_bits(raw as i32)) + } + }) + .await; + on_drop.defuse(); + value } fn regs() -> &'static pac::temp::RegisterBlock {