nrf/saadc: remove Pin
This commit is contained in:
parent
211fdb6e84
commit
e3ab02c7e3
@ -1,6 +1,5 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::pin::Pin;
|
|
||||||
use core::sync::atomic::{compiler_fence, Ordering};
|
use core::sync::atomic::{compiler_fence, Ordering};
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
use embassy::util::{wake_on_interrupt, Unborrow};
|
use embassy::util::{wake_on_interrupt, Unborrow};
|
||||||
@ -138,17 +137,16 @@ pub trait Sample {
|
|||||||
where
|
where
|
||||||
Self: 'a;
|
Self: 'a;
|
||||||
|
|
||||||
fn sample<'a>(self: Pin<&'a mut Self>) -> Self::SampleFuture<'a>;
|
fn sample<'a>(&'a mut self) -> Self::SampleFuture<'a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T: PositivePin> Sample for OneShot<'d, T> {
|
impl<'d, T: PositivePin> Sample for OneShot<'d, T> {
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
type SampleFuture<'a> where Self: 'a = impl Future<Output = i16> + 'a;
|
type SampleFuture<'a> where Self: 'a = impl Future<Output = i16> + 'a;
|
||||||
|
|
||||||
fn sample<'a>(self: Pin<&'a mut Self>) -> Self::SampleFuture<'a> {
|
fn sample<'a>(&'a mut self) -> Self::SampleFuture<'a> {
|
||||||
async move {
|
async move {
|
||||||
let this = unsafe { self.get_unchecked_mut() };
|
let r = self.regs();
|
||||||
let r = this.regs();
|
|
||||||
|
|
||||||
// Set up the DMA
|
// Set up the DMA
|
||||||
let mut val: i16 = 0;
|
let mut val: i16 = 0;
|
||||||
@ -161,7 +159,7 @@ impl<'d, T: PositivePin> Sample for OneShot<'d, T> {
|
|||||||
r.events_end.reset();
|
r.events_end.reset();
|
||||||
r.intenset.write(|w| w.end().set());
|
r.intenset.write(|w| w.end().set());
|
||||||
|
|
||||||
// Don't reorder the ADC start event before the previous writes. Hopefully this
|
// Don't reorder the ADC start event before the previous writes. Hopefully self
|
||||||
// wouldn't happen anyway.
|
// wouldn't happen anyway.
|
||||||
compiler_fence(Ordering::SeqCst);
|
compiler_fence(Ordering::SeqCst);
|
||||||
|
|
||||||
@ -170,14 +168,14 @@ impl<'d, T: PositivePin> Sample for OneShot<'d, T> {
|
|||||||
|
|
||||||
// Wait for 'end' event.
|
// Wait for 'end' event.
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
let r = this.regs();
|
let r = self.regs();
|
||||||
|
|
||||||
if r.events_end.read().bits() != 0 {
|
if r.events_end.read().bits() != 0 {
|
||||||
r.events_end.reset();
|
r.events_end.reset();
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
|
|
||||||
wake_on_interrupt(&mut this.irq, cx.waker());
|
wake_on_interrupt(&mut self.irq, cx.waker());
|
||||||
|
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user