diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index e909e7d5a..b6e8f4e44 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs @@ -1,4 +1,3 @@ -use core::future::Future; use core::marker::PhantomData; use core::sync::atomic::{compiler_fence, Ordering}; use core::task::Poll; @@ -129,11 +128,11 @@ impl<'d> OneShot<'d> { unsafe { &*SAADC::ptr() } } - async fn sample_inner(&mut self, pin: PositiveChannel) -> i16 { + pub async fn sample(&mut self, pin: &mut impl PositivePin) -> i16 { let r = Self::regs(); // Set positive channel - r.ch[0].pselp.write(|w| w.pselp().variant(pin)); + r.ch[0].pselp.write(|w| w.pselp().variant(pin.channel())); // Set up the DMA let mut val: i16 = 0; @@ -180,23 +179,6 @@ impl<'d> Drop for OneShot<'d> { } } -pub trait Sample { - type SampleFuture<'a>: Future + 'a - where - Self: 'a; - - fn sample<'a, T: PositivePin>(&'a mut self, pin: &mut T) -> Self::SampleFuture<'a>; -} - -impl<'d> Sample for OneShot<'d> { - #[rustfmt::skip] - type SampleFuture<'a> where Self: 'a = impl Future + 'a; - - fn sample<'a, T: PositivePin>(&'a mut self, pin: &mut T) -> Self::SampleFuture<'a> { - self.sample_inner(pin.channel()) - } -} - /// A pin that can be used as the positive end of a ADC differential in the SAADC periperhal. /// /// Currently negative is always shorted to ground (0V). diff --git a/examples/nrf/src/bin/saadc.rs b/examples/nrf/src/bin/saadc.rs index 311ffe2eb..c4d23360e 100644 --- a/examples/nrf/src/bin/saadc.rs +++ b/examples/nrf/src/bin/saadc.rs @@ -7,7 +7,7 @@ mod example_common; use defmt::panic; use embassy::executor::Spawner; use embassy::time::{Duration, Timer}; -use embassy_nrf::saadc::{Config, OneShot, Sample}; +use embassy_nrf::saadc::{Config, OneShot}; use embassy_nrf::{interrupt, Peripherals}; use example_common::*;