diff options
| author | Grant Miller <[email protected]> | 2023-04-05 15:28:42 -0500 |
|---|---|---|
| committer | Grant Miller <[email protected]> | 2023-04-05 15:28:42 -0500 |
| commit | 37d8f2e51256403cc4839c3b45e5c2253e3a09f1 (patch) | |
| tree | fab0ba9e3c12cb5e821db223cc012847022c7520 | |
| parent | efd9e18321c258a188fa675804d59346a4c11cc2 (diff) | |
Properly enable and reset adc
| -rw-r--r-- | embassy-stm32/src/adc/v1.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/embassy-stm32/src/adc/v1.rs b/embassy-stm32/src/adc/v1.rs index 0fdb95562..a699d8f74 100644 --- a/embassy-stm32/src/adc/v1.rs +++ b/embassy-stm32/src/adc/v1.rs | |||
| @@ -7,12 +7,6 @@ use crate::Peripheral; | |||
| 7 | pub const VDDA_CALIB_MV: u32 = 3300; | 7 | pub const VDDA_CALIB_MV: u32 = 3300; |
| 8 | pub const VREF_INT: u32 = 1230; | 8 | pub const VREF_INT: u32 = 1230; |
| 9 | 9 | ||
| 10 | fn enable() { | ||
| 11 | critical_section::with(|_| unsafe { | ||
| 12 | crate::pac::RCC.apb2enr().modify(|reg| reg.set_adcen(true)); | ||
| 13 | }); | ||
| 14 | } | ||
| 15 | |||
| 16 | pub trait InternalChannel<T>: sealed::InternalChannel<T> {} | 10 | pub trait InternalChannel<T>: sealed::InternalChannel<T> {} |
| 17 | 11 | ||
| 18 | mod sealed { | 12 | mod sealed { |
| @@ -48,7 +42,8 @@ impl<T: Instance> sealed::InternalChannel<T> for Temperature { | |||
| 48 | impl<'d, T: Instance> Adc<'d, T> { | 42 | impl<'d, T: Instance> Adc<'d, T> { |
| 49 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { | 43 | pub fn new(adc: impl Peripheral<P = T> + 'd, delay: &mut impl DelayUs<u32>) -> Self { |
| 50 | into_ref!(adc); | 44 | into_ref!(adc); |
| 51 | enable(); | 45 | T::enable(); |
| 46 | T::reset(); | ||
| 52 | 47 | ||
| 53 | // Delay 1μs when using HSI14 as the ADC clock. | 48 | // Delay 1μs when using HSI14 as the ADC clock. |
| 54 | // | 49 | // |
