diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-11-01 20:35:03 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-01 20:35:03 +0000 |
| commit | 2765f0978f0a4001300dbb85a470503eb323ff52 (patch) | |
| tree | 72d538a46d54129437ac07620d4ed60598309904 | |
| parent | 729d69246ac23af7a9589b7df2f102abc64816cc (diff) | |
| parent | bc07539133937c254930bbdafe1b01bb0f5912e3 (diff) | |
Merge pull request #2133 from Radiator-Labs/main
Reinstate rcc::Config adc_clock_source field
| -rw-r--r-- | embassy-stm32/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l4l5.rs | 15 |
2 files changed, 14 insertions, 5 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index ffb709342..bc79ab7a2 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -58,7 +58,7 @@ rand_core = "0.6.3" | |||
| 58 | sdio-host = "0.5.0" | 58 | sdio-host = "0.5.0" |
| 59 | embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } | 59 | embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } |
| 60 | critical-section = "1.1" | 60 | critical-section = "1.1" |
| 61 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-bcc9b6bf9fa195e91625849efc4ba473d9ace4e9" } | 61 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-73b8c37ae74fc28b247188c989fd99400611bd6b" } |
| 62 | vcell = "0.1.3" | 62 | vcell = "0.1.3" |
| 63 | bxcan = "0.7.0" | 63 | bxcan = "0.7.0" |
| 64 | nb = "1.0.0" | 64 | nb = "1.0.0" |
| @@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] } | |||
| 76 | [build-dependencies] | 76 | [build-dependencies] |
| 77 | proc-macro2 = "1.0.36" | 77 | proc-macro2 = "1.0.36" |
| 78 | quote = "1.0.15" | 78 | quote = "1.0.15" |
| 79 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-bcc9b6bf9fa195e91625849efc4ba473d9ace4e9", default-features = false, features = ["metadata"]} | 79 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-73b8c37ae74fc28b247188c989fd99400611bd6b", default-features = false, features = ["metadata"]} |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | [features] | 82 | [features] |
diff --git a/embassy-stm32/src/rcc/l4l5.rs b/embassy-stm32/src/rcc/l4l5.rs index 2f89f6821..0d052713f 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))] |
| 5 | pub use crate::pac::rcc::vals::Hsepre as HsePrescaler; | 5 | pub use crate::pac::rcc::vals::Hsepre as HsePrescaler; |
| 6 | pub use crate::pac::rcc::vals::{ | 6 | pub use crate::pac::rcc::vals::{ |
| 7 | Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, | 7 | Adcsel as AdcClockSource, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, |
| 8 | 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 | }; |
| 10 | use crate::pac::{FLASH, RCC}; | 10 | use crate::pac::{FLASH, RCC}; |
| 11 | use crate::rcc::{set_freqs, Clocks}; | 11 | use crate::rcc::{set_freqs, Clocks}; |
| @@ -52,7 +52,7 @@ pub struct Pll { | |||
| 52 | pub divr: Option<PllRDiv>, | 52 | pub divr: Option<PllRDiv>, |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | /// Clocks configutation | 55 | /// Clocks configuration |
| 56 | pub struct Config { | 56 | pub struct Config { |
| 57 | // base clock sources | 57 | // base clock sources |
| 58 | pub msi: Option<MSIRange>, | 58 | pub msi: Option<MSIRange>, |
| @@ -84,6 +84,8 @@ pub struct Config { | |||
| 84 | 84 | ||
| 85 | // low speed LSI/LSE/RTC | 85 | // low speed LSI/LSE/RTC |
| 86 | pub ls: super::LsConfig, | 86 | pub ls: super::LsConfig, |
| 87 | |||
| 88 | pub adc_clock_source: AdcClockSource, | ||
| 87 | } | 89 | } |
| 88 | 90 | ||
| 89 | impl Default for Config { | 91 | impl Default for Config { |
| @@ -111,6 +113,7 @@ impl Default for Config { | |||
| 111 | #[cfg(any(stm32l4, stm32l5, stm32wb))] | 113 | #[cfg(any(stm32l4, stm32l5, stm32wb))] |
| 112 | clk48_src: Clk48Src::HSI48, | 114 | clk48_src: Clk48Src::HSI48, |
| 113 | ls: Default::default(), | 115 | ls: Default::default(), |
| 116 | adc_clock_source: AdcClockSource::SYS, | ||
| 114 | } | 117 | } |
| 115 | } | 118 | } |
| 116 | } | 119 | } |
| @@ -145,6 +148,7 @@ pub const WPAN_DEFAULT: Config = Config { | |||
| 145 | shared_ahb_pre: AHBPrescaler::DIV1, | 148 | shared_ahb_pre: AHBPrescaler::DIV1, |
| 146 | apb1_pre: APBPrescaler::DIV1, | 149 | apb1_pre: APBPrescaler::DIV1, |
| 147 | apb2_pre: APBPrescaler::DIV1, | 150 | apb2_pre: APBPrescaler::DIV1, |
| 151 | adc_clock_source: AdcClockSource::SYS, | ||
| 148 | }; | 152 | }; |
| 149 | 153 | ||
| 150 | pub(crate) unsafe fn init(config: Config) { | 154 | pub(crate) unsafe fn init(config: Config) { |
| @@ -344,6 +348,11 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 344 | }); | 348 | }); |
| 345 | while RCC.cfgr().read().sws() != config.mux {} | 349 | while RCC.cfgr().read().sws() != config.mux {} |
| 346 | 350 | ||
| 351 | #[cfg(stm32l5)] | ||
| 352 | RCC.ccipr1().modify(|w| w.set_adcsel(config.adc_clock_source)); | ||
| 353 | #[cfg(not(stm32l5))] | ||
| 354 | RCC.ccipr().modify(|w| w.set_adcsel(config.adc_clock_source)); | ||
| 355 | |||
| 347 | #[cfg(any(stm32wl, stm32wb))] | 356 | #[cfg(any(stm32wl, stm32wb))] |
| 348 | { | 357 | { |
| 349 | RCC.extcfgr().modify(|w| { | 358 | RCC.extcfgr().modify(|w| { |
