nrf: replace PhantomData usages with PeripheralRef.

This commit is contained in:
Dario Nieuwenhuis
2022-07-23 15:13:47 +02:00
parent 19d1ef0e29
commit 709df0dc1d
12 changed files with 180 additions and 164 deletions

View File

@ -1,6 +1,5 @@
//! Quadrature decoder interface
use core::marker::PhantomData;
use core::task::Poll;
use embassy::waitqueue::AtomicWaker;
@ -15,7 +14,7 @@ use crate::{interrupt, pac, Peripheral};
/// Quadrature decoder
pub struct Qdec<'d> {
phantom: PhantomData<&'d QDEC>,
_p: PeripheralRef<'d, QDEC>,
}
#[non_exhaustive]
@ -66,14 +65,14 @@ impl<'d> Qdec<'d> {
}
fn new_inner(
_t: impl Peripheral<P = QDEC> + 'd,
p: impl Peripheral<P = QDEC> + 'd,
irq: impl Peripheral<P = interrupt::QDEC> + 'd,
a: PeripheralRef<'d, AnyPin>,
b: PeripheralRef<'d, AnyPin>,
led: Option<PeripheralRef<'d, AnyPin>>,
config: Config,
) -> Self {
into_ref!(irq);
into_ref!(p, irq);
let r = Self::regs();
// Select pins.
@ -131,7 +130,7 @@ impl<'d> Qdec<'d> {
});
irq.enable();
Self { phantom: PhantomData }
Self { _p: p }
}
/// Perform an asynchronous read of the decoder.