Skip to content

Commit 5986765

Browse files
committed
Fix PLL enable.
1 parent dd1cebb commit 5986765

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/rcc.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ use crate::pac::RCC;
22
use crate::time::{Hertz, U32Ext};
33

44
#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
5-
use crate::{
6-
pac::CRS,
7-
syscfg::SYSCFG,
8-
};
9-
5+
use crate::{pac::CRS, syscfg::SYSCFG};
106

117
/// System clock mux source
128
#[derive(Clone, Copy)]
@@ -199,27 +195,22 @@ impl Rcc {
199195
// Initialize CRS
200196
crs.cfgr.write(|w|
201197
// Select LSE as synchronization source
202-
unsafe { w.syncsrc().bits(0b01) }
203-
);
204-
crs.cr.write(|w|
205-
w
206-
.autotrimen().set_bit()
207-
.cen().set_bit()
208-
);
198+
unsafe { w.syncsrc().bits(0b01) });
199+
crs.cr
200+
.modify(|_, w| w.autotrimen().set_bit().cen().set_bit());
209201

210202
// Enable VREFINT reference for HSI48 oscillator
211-
syscfg.syscfg.cfgr3.modify(|_, w|
212-
w
213-
.enref_hsi48().set_bit()
214-
.en_vrefint().set_bit()
215-
);
203+
syscfg
204+
.syscfg
205+
.cfgr3
206+
.modify(|_, w| w.enref_hsi48().set_bit().en_vrefint().set_bit());
216207

217208
// Select HSI48 as USB clock
218209
self.rb.ccipr.modify(|_, w| w.hsi48msel().set_bit());
219210

220211
// Enable dedicated USB clock
221212
self.rb.crrcr.modify(|_, w| w.hsi48on().set_bit());
222-
while self.rb.crrcr.read().hsi48rdy().bit_is_clear() {};
213+
while self.rb.crrcr.read().hsi48rdy().bit_is_clear() {}
223214

224215
HSI48(())
225216
}
@@ -280,7 +271,7 @@ impl RccExt for RCC {
280271
};
281272

282273
// Disable PLL
283-
self.cr.write(|w| w.pllon().clear_bit());
274+
self.cr.modify(|_, w| w.pllon().clear_bit());
284275
while self.cr.read().pllrdy().bit_is_set() {}
285276

286277
let mul_bytes = mul as u8;
@@ -315,7 +306,7 @@ impl RccExt for RCC {
315306
});
316307

317308
// Enable PLL
318-
self.cr.write(|w| w.pllon().set_bit());
309+
self.cr.modify(|_, w| w.pllon().set_bit());
319310
while self.cr.read().pllrdy().bit_is_clear() {}
320311

321312
(freq, 3)
@@ -366,7 +357,6 @@ impl RccExt for RCC {
366357

367358
Rcc { rb: self, clocks }
368359
}
369-
370360
}
371361

372362
/// Frozen clock frequencies
@@ -420,7 +410,6 @@ impl Clocks {
420410
}
421411
}
422412

423-
424413
/// Token that exists only, if the HSI48 clock has been enabled
425414
///
426415
/// You can get an instance of this struct by calling [`Rcc::enable_hsi48`].

0 commit comments

Comments
 (0)