Desugar some async fns

This commit is contained in:
Dániel Buga
2024-12-30 12:13:13 +01:00
parent a4f8fddd69
commit 44217aa092
18 changed files with 103 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
//! ADC driver.
use core::future::poll_fn;
use core::future::{poll_fn, Future};
use core::marker::PhantomData;
use core::mem;
use core::sync::atomic::{compiler_fence, Ordering};
@@ -193,18 +193,18 @@ impl<'d> Adc<'d, Async> {
Self { phantom: PhantomData }
}
async fn wait_for_ready() {
fn wait_for_ready() -> impl Future<Output = ()> {
let r = Self::regs();
r.inte().write(|w| w.set_fifo(true));
compiler_fence(Ordering::SeqCst);
poll_fn(|cx| {
poll_fn(move |cx| {
WAKER.register(cx.waker());
if r.cs().read().ready() {
return Poll::Ready(());
}
Poll::Pending
})
.await;
}
/// Sample a value from a channel until completed.