aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/rcc/f0.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-02-14 02:12:06 +0100
committerDario Nieuwenhuis <[email protected]>2022-02-14 02:12:06 +0100
commit39d06b59cd8eb6f64e5986bfaaf4e5f7d504f5c1 (patch)
treefa49fb426a7db68550c33e7b26dfe2f720ceae15 /embassy-stm32/src/rcc/f0.rs
parentc8f9f1bead8aa02076ff8daec3c83c752808dbcb (diff)
Update stm32-data
Diffstat (limited to 'embassy-stm32/src/rcc/f0.rs')
-rw-r--r--embassy-stm32/src/rcc/f0.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/embassy-stm32/src/rcc/f0.rs b/embassy-stm32/src/rcc/f0.rs
index 1527afa05..427c958f0 100644
--- a/embassy-stm32/src/rcc/f0.rs
+++ b/embassy-stm32/src/rcc/f0.rs
@@ -1,4 +1,4 @@
1use crate::pac::rcc::vals::{Hpre, Hsebyp, Pllmul, Pllsrc, Ppre, Sw, Usbsw}; 1use crate::pac::rcc::vals::{Hpre, Pllmul, Pllsrc, Ppre, Sw, Usbsw};
2use crate::pac::{FLASH, RCC}; 2use crate::pac::{FLASH, RCC};
3use crate::time::Hertz; 3use crate::time::Hertz;
4 4
@@ -16,7 +16,7 @@ pub struct Config {
16 pub bypass_hse: bool, 16 pub bypass_hse: bool,
17 pub usb_pll: bool, 17 pub usb_pll: bool,
18 18
19 #[cfg(rcc_f0)] 19 #[cfg(not(stm32f0x0))]
20 pub hsi48: bool, 20 pub hsi48: bool,
21 21
22 pub sys_ck: Option<Hertz>, 22 pub sys_ck: Option<Hertz>,
@@ -28,7 +28,7 @@ pub(crate) unsafe fn init(config: Config) {
28 let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI); 28 let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI);
29 29
30 let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| { 30 let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| {
31 #[cfg(rcc_f0)] 31 #[cfg(not(stm32f0x0))]
32 if config.hsi48 { 32 if config.hsi48 {
33 return (48_000_000, true); 33 return (48_000_000, true);
34 } 34 }
@@ -97,10 +97,7 @@ pub(crate) unsafe fn init(config: Config) {
97 RCC.cr().modify(|w| { 97 RCC.cr().modify(|w| {
98 w.set_csson(true); 98 w.set_csson(true);
99 w.set_hseon(true); 99 w.set_hseon(true);
100 100 w.set_hsebyp(config.bypass_hse);
101 if config.bypass_hse {
102 w.set_hsebyp(Hsebyp::BYPASSED);
103 }
104 }); 101 });
105 while !RCC.cr().read().hserdy() {} 102 while !RCC.cr().read().hserdy() {}
106 103
@@ -108,14 +105,12 @@ pub(crate) unsafe fn init(config: Config) {
108 RCC.cfgr().modify(|w| w.set_pllsrc(Pllsrc::HSE_DIV_PREDIV)) 105 RCC.cfgr().modify(|w| w.set_pllsrc(Pllsrc::HSE_DIV_PREDIV))
109 } 106 }
110 } 107 }
108 // use_hsi48 will always be false for stm32f0x0
109 #[cfg(not(stm32f0x0))]
111 (false, true) => { 110 (false, true) => {
112 // use_hsi48 will always be false for rcc_f0x0
113 #[cfg(rcc_f0)]
114 RCC.cr2().modify(|w| w.set_hsi48on(true)); 111 RCC.cr2().modify(|w| w.set_hsi48on(true));
115 #[cfg(rcc_f0)]
116 while !RCC.cr2().read().hsi48rdy() {} 112 while !RCC.cr2().read().hsi48rdy() {}
117 113
118 #[cfg(rcc_f0)]
119 if pllmul_bits.is_some() { 114 if pllmul_bits.is_some() {
120 RCC.cfgr() 115 RCC.cfgr()
121 .modify(|w| w.set_pllsrc(Pllsrc::HSI48_DIV_PREDIV)) 116 .modify(|w| w.set_pllsrc(Pllsrc::HSI48_DIV_PREDIV))
@@ -155,7 +150,7 @@ pub(crate) unsafe fn init(config: Config) {
155 if config.hse.is_some() { 150 if config.hse.is_some() {
156 w.set_sw(Sw::HSE); 151 w.set_sw(Sw::HSE);
157 } else if use_hsi48 { 152 } else if use_hsi48 {
158 #[cfg(rcc_f0)] 153 #[cfg(not(stm32f0x0))]
159 w.set_sw(Sw::HSI48); 154 w.set_sw(Sw::HSI48);
160 } else { 155 } else {
161 w.set_sw(Sw::HSI) 156 w.set_sw(Sw::HSI)
@@ -169,6 +164,6 @@ pub(crate) unsafe fn init(config: Config) {
169 apb2: Hertz(pclk), 164 apb2: Hertz(pclk),
170 apb1_tim: Hertz(pclk * timer_mul), 165 apb1_tim: Hertz(pclk * timer_mul),
171 apb2_tim: Hertz(pclk * timer_mul), 166 apb2_tim: Hertz(pclk * timer_mul),
172 ahb: Hertz(hclk), 167 ahb1: Hertz(hclk),
173 }); 168 });
174} 169}