From 37d8f2e51256403cc4839c3b45e5c2253e3a09f1 Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Wed, 5 Apr 2023 15:28:42 -0500 Subject: [PATCH] Properly enable and reset adc --- embassy-stm32/src/adc/v1.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index 0fdb9556..a699d8f7 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs @@ -7,12 +7,6 @@ use crate::Peripheral; pub const VDDA_CALIB_MV: u32 = 3300; pub const VREF_INT: u32 = 1230; -fn enable() { - critical_section::with(|_| unsafe { - crate::pac::RCC.apb2enr().modify(|reg| reg.set_adcen(true)); - }); -} - pub trait InternalChannel: sealed::InternalChannel {} mod sealed { @@ -48,7 +42,8 @@ impl sealed::InternalChannel for Temperature { impl<'d, T: Instance> Adc<'d, T> { pub fn new(adc: impl Peripheral

+ 'd, delay: &mut impl DelayUs) -> Self { into_ref!(adc); - enable(); + T::enable(); + T::reset(); // Delay 1μs when using HSI14 as the ADC clock. //