aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-05-05 17:09:26 +0000
committerGitHub <[email protected]>2023-05-05 17:09:26 +0000
commita9c7263ba02181fc4d54975a63d8a1e92426dff3 (patch)
treec4e16bb98eafff6a926fcfbc3757f9aac22e067f
parent4439031d4323a5d1e11af22887a32bb76cb953fb (diff)
parentdb2bc8783e756d0e10838869603c844d8c276feb (diff)
Merge #1432
1432: Support PLLXTPRE switch. r=Dirbaio a=MrOscarLoplate See figure 2. Clock tree page 12 DS5319 Rev 18 https://www.st.com/resource/en/datasheet/stm32f103cb.pdf Co-authored-by: Marco Pastrello <[email protected]>
-rw-r--r--embassy-stm32/src/rcc/f1.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-stm32/src/rcc/f1.rs b/embassy-stm32/src/rcc/f1.rs
index e667dbf90..4769b7059 100644
--- a/embassy-stm32/src/rcc/f1.rs
+++ b/embassy-stm32/src/rcc/f1.rs
@@ -24,10 +24,13 @@ pub struct Config {
24 pub pclk1: Option<Hertz>, 24 pub pclk1: Option<Hertz>,
25 pub pclk2: Option<Hertz>, 25 pub pclk2: Option<Hertz>,
26 pub adcclk: Option<Hertz>, 26 pub adcclk: Option<Hertz>,
27 pub pllxtpre: bool,
27} 28}
28 29
29pub(crate) unsafe fn init(config: Config) { 30pub(crate) unsafe fn init(config: Config) {
30 let pllsrcclk = config.hse.map(|hse| hse.0).unwrap_or(HSI_FREQ.0 / 2); 31 let pllxtpre_div = if config.pllxtpre { 2 } else { 1 };
32 let pllsrcclk = config.hse.map(|hse| hse.0 / pllxtpre_div).unwrap_or(HSI_FREQ.0 / 2);
33
31 let sysclk = config.sys_ck.map(|sys| sys.0).unwrap_or(pllsrcclk); 34 let sysclk = config.sys_ck.map(|sys| sys.0).unwrap_or(pllsrcclk);
32 let pllmul = sysclk / pllsrcclk; 35 let pllmul = sysclk / pllsrcclk;
33 36
@@ -143,6 +146,9 @@ pub(crate) unsafe fn init(config: Config) {
143 } 146 }
144 147
145 if let Some(pllmul_bits) = pllmul_bits { 148 if let Some(pllmul_bits) = pllmul_bits {
149 let pllctpre_flag: u8 = if config.pllxtpre { 1 } else { 0 };
150 RCC.cfgr().modify(|w| w.set_pllxtpre(Pllxtpre(pllctpre_flag)));
151
146 // enable PLL and wait for it to be ready 152 // enable PLL and wait for it to be ready
147 RCC.cfgr().modify(|w| { 153 RCC.cfgr().modify(|w| {
148 w.set_pllmul(Pllmul(pllmul_bits)); 154 w.set_pllmul(Pllmul(pllmul_bits));