From 0e05ba688d10c8a8dc60ac46bf241811fa17fc38 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 7 Oct 2021 02:10:22 +0200 Subject: [PATCH] nrf/saadc: remove Sample trait. --- embassy-nrf/src/saadc.rs | 22 ++-------------------- examples/nrf/src/bin/saadc.rs | 2 +- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index e909e7d5..b6e8f4e4 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 311ffe2e..c4d23360 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::*;