Refactor: Use PeripheralRef

This commit is contained in:
Grant Miller
2022-10-26 18:36:04 -05:00
parent 08c8022583
commit 171b764d82
5 changed files with 16 additions and 23 deletions

View File

@ -1,5 +1,3 @@
use core::marker::PhantomData;
use embassy_hal_common::into_ref;
use embedded_hal_02::blocking::delay::DelayUs;
@ -30,8 +28,8 @@ impl<T: Instance> super::sealed::AdcPin<T> for Temperature {
}
impl<'d, T: Instance> Adc<'d, T> {
pub fn new(_peri: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
into_ref!(_peri);
pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self {
into_ref!(adc);
T::enable();
T::reset();
unsafe {
@ -60,8 +58,8 @@ impl<'d, T: Instance> Adc<'d, T> {
delay.delay_us((1_000_000) / Self::freq().0 + 1);
Self {
adc,
sample_time: Default::default(),
phantom: PhantomData,
}
}