Merge pull request #2133 from Radiator-Labs/main
Reinstate rcc::Config adc_clock_source field
This commit is contained in:
commit
2765f0978f
@ -58,7 +58,7 @@ rand_core = "0.6.3"
|
|||||||
sdio-host = "0.5.0"
|
sdio-host = "0.5.0"
|
||||||
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
|
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
|
||||||
critical-section = "1.1"
|
critical-section = "1.1"
|
||||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-bcc9b6bf9fa195e91625849efc4ba473d9ace4e9" }
|
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-73b8c37ae74fc28b247188c989fd99400611bd6b" }
|
||||||
vcell = "0.1.3"
|
vcell = "0.1.3"
|
||||||
bxcan = "0.7.0"
|
bxcan = "0.7.0"
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] }
|
|||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
proc-macro2 = "1.0.36"
|
proc-macro2 = "1.0.36"
|
||||||
quote = "1.0.15"
|
quote = "1.0.15"
|
||||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-bcc9b6bf9fa195e91625849efc4ba473d9ace4e9", default-features = false, features = ["metadata"]}
|
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-73b8c37ae74fc28b247188c989fd99400611bd6b", default-features = false, features = ["metadata"]}
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -4,8 +4,8 @@ pub use crate::pac::rcc::vals::Clk48sel as Clk48Src;
|
|||||||
#[cfg(any(stm32wb, stm32wl))]
|
#[cfg(any(stm32wb, stm32wl))]
|
||||||
pub use crate::pac::rcc::vals::Hsepre as HsePrescaler;
|
pub use crate::pac::rcc::vals::Hsepre as HsePrescaler;
|
||||||
pub use crate::pac::rcc::vals::{
|
pub use crate::pac::rcc::vals::{
|
||||||
Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv,
|
Adcsel as AdcClockSource, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul,
|
||||||
Pllr as PllRDiv, Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc,
|
Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc,
|
||||||
};
|
};
|
||||||
use crate::pac::{FLASH, RCC};
|
use crate::pac::{FLASH, RCC};
|
||||||
use crate::rcc::{set_freqs, Clocks};
|
use crate::rcc::{set_freqs, Clocks};
|
||||||
@ -52,7 +52,7 @@ pub struct Pll {
|
|||||||
pub divr: Option<PllRDiv>,
|
pub divr: Option<PllRDiv>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clocks configutation
|
/// Clocks configuration
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
// base clock sources
|
// base clock sources
|
||||||
pub msi: Option<MSIRange>,
|
pub msi: Option<MSIRange>,
|
||||||
@ -84,6 +84,8 @@ pub struct Config {
|
|||||||
|
|
||||||
// low speed LSI/LSE/RTC
|
// low speed LSI/LSE/RTC
|
||||||
pub ls: super::LsConfig,
|
pub ls: super::LsConfig,
|
||||||
|
|
||||||
|
pub adc_clock_source: AdcClockSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@ -111,6 +113,7 @@ impl Default for Config {
|
|||||||
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
||||||
clk48_src: Clk48Src::HSI48,
|
clk48_src: Clk48Src::HSI48,
|
||||||
ls: Default::default(),
|
ls: Default::default(),
|
||||||
|
adc_clock_source: AdcClockSource::SYS,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,6 +148,7 @@ pub const WPAN_DEFAULT: Config = Config {
|
|||||||
shared_ahb_pre: AHBPrescaler::DIV1,
|
shared_ahb_pre: AHBPrescaler::DIV1,
|
||||||
apb1_pre: APBPrescaler::DIV1,
|
apb1_pre: APBPrescaler::DIV1,
|
||||||
apb2_pre: APBPrescaler::DIV1,
|
apb2_pre: APBPrescaler::DIV1,
|
||||||
|
adc_clock_source: AdcClockSource::SYS,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) unsafe fn init(config: Config) {
|
pub(crate) unsafe fn init(config: Config) {
|
||||||
@ -344,6 +348,11 @@ pub(crate) unsafe fn init(config: Config) {
|
|||||||
});
|
});
|
||||||
while RCC.cfgr().read().sws() != config.mux {}
|
while RCC.cfgr().read().sws() != config.mux {}
|
||||||
|
|
||||||
|
#[cfg(stm32l5)]
|
||||||
|
RCC.ccipr1().modify(|w| w.set_adcsel(config.adc_clock_source));
|
||||||
|
#[cfg(not(stm32l5))]
|
||||||
|
RCC.ccipr().modify(|w| w.set_adcsel(config.adc_clock_source));
|
||||||
|
|
||||||
#[cfg(any(stm32wl, stm32wb))]
|
#[cfg(any(stm32wl, stm32wb))]
|
||||||
{
|
{
|
||||||
RCC.extcfgr().modify(|w| {
|
RCC.extcfgr().modify(|w| {
|
||||||
|
Loading…
Reference in New Issue
Block a user