aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshakencodes <[email protected]>2023-11-01 12:06:19 -0700
committershakencodes <[email protected]>2023-11-01 12:06:19 -0700
commite2688dda22a813fdcf7938ef7ca003be4c94c0c2 (patch)
tree08fc1dcf6d258241747c75f9dd08aa26e8391942
parentd0d8585e4cdb73373ead13289a28b7d155377963 (diff)
Eliminates redefinition of AdcClockSource
-rw-r--r--embassy-stm32/src/rcc/l4l5.rs31
1 files changed, 4 insertions, 27 deletions
diff --git a/embassy-stm32/src/rcc/l4l5.rs b/embassy-stm32/src/rcc/l4l5.rs
index a7c136a31..78b8e0606 100644
--- a/embassy-stm32/src/rcc/l4l5.rs
+++ b/embassy-stm32/src/rcc/l4l5.rs
@@ -4,8 +4,8 @@ pub use crate::pac::rcc::vals::Clk48sel as Clk48Src;
4#[cfg(any(stm32wb, stm32wl))] 4#[cfg(any(stm32wb, stm32wl))]
5pub use crate::pac::rcc::vals::Hsepre as HsePrescaler; 5pub use crate::pac::rcc::vals::Hsepre as HsePrescaler;
6pub use crate::pac::rcc::vals::{ 6pub use crate::pac::rcc::vals::{
7 Adcsel, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, 7 Adcsel as AdcClockSource, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul,
8 Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc, 8 Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc,
9}; 9};
10use crate::pac::{FLASH, RCC}; 10use crate::pac::{FLASH, RCC};
11use crate::rcc::{set_freqs, Clocks}; 11use crate::rcc::{set_freqs, Clocks};
@@ -52,29 +52,6 @@ pub struct Pll {
52 pub divr: Option<PllRDiv>, 52 pub divr: Option<PllRDiv>,
53} 53}
54 54
55#[derive(Clone, Copy)]
56pub enum AdcClockSource {
57 HSI16,
58 PLLPCLK,
59 SYSCLK,
60}
61
62impl AdcClockSource {
63 pub fn adcsel(&self) -> Adcsel {
64 match self {
65 AdcClockSource::HSI16 => Adcsel::HSI,
66 AdcClockSource::PLLPCLK => Adcsel::PLL1_P,
67 AdcClockSource::SYSCLK => Adcsel::SYS,
68 }
69 }
70}
71
72impl Default for AdcClockSource {
73 fn default() -> Self {
74 Self::HSI16
75 }
76}
77
78/// Clocks configuration 55/// Clocks configuration
79pub struct Config { 56pub struct Config {
80 // base clock sources 57 // base clock sources
@@ -136,7 +113,7 @@ impl Default for Config {
136 #[cfg(any(stm32l4, stm32l5, stm32wb))] 113 #[cfg(any(stm32l4, stm32l5, stm32wb))]
137 clk48_src: Clk48Src::HSI48, 114 clk48_src: Clk48Src::HSI48,
138 ls: Default::default(), 115 ls: Default::default(),
139 adc_clock_source: AdcClockSource::default(), 116 adc_clock_source: AdcClockSource::HSI,
140 } 117 }
141 } 118 }
142} 119}
@@ -370,7 +347,7 @@ pub(crate) unsafe fn init(config: Config) {
370 }); 347 });
371 while RCC.cfgr().read().sws() != config.mux {} 348 while RCC.cfgr().read().sws() != config.mux {}
372 349
373 RCC.ccipr().modify(|w| w.set_adcsel(config.adc_clock_source.adcsel())); 350 RCC.ccipr().modify(|w| w.set_adcsel(config.adc_clock_source));
374 351
375 #[cfg(any(stm32wl, stm32wb))] 352 #[cfg(any(stm32wl, stm32wb))]
376 { 353 {