aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Lilleengen <[email protected]>2021-05-26 13:55:25 +0200
committerUlf Lilleengen <[email protected]>2021-05-26 13:55:25 +0200
commitf960f5b105977b78c7900b0992b97da4c190f8fa (patch)
treef55747b94ea364b7a0e8b2d93ae96da724d778e5
parent9743c59ad48996c4c53f0bfdfc8070b67e513ff0 (diff)
Rework
-rw-r--r--embassy-stm32/src/rcc/l0/mod.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs
index c756fad10..daa8431a6 100644
--- a/embassy-stm32/src/rcc/l0/mod.rs
+++ b/embassy-stm32/src/rcc/l0/mod.rs
@@ -4,6 +4,7 @@ use crate::pac;
4use crate::pac::peripherals::{self, RCC, TIM2}; 4use crate::pac::peripherals::{self, RCC, TIM2};
5use crate::time::Hertz; 5use crate::time::Hertz;
6use crate::time::U32Ext; 6use crate::time::U32Ext;
7use embassy::util::Unborrow;
7use pac::rcc::vals; 8use pac::rcc::vals;
8use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw}; 9use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw};
9 10
@@ -269,8 +270,16 @@ impl Config {
269 } 270 }
270} 271}
271 272
272/* 273/// RCC peripheral
274pub struct Rcc {}
275
273impl Rcc { 276impl Rcc {
277 pub fn new(_rcc: impl Unborrow<Target = peripherals::RCC> + 'static) -> Self {
278 Self {}
279 }
280}
281
282/*
274 pub fn enable_lse(&mut self, _: &PWR) -> LSE { 283 pub fn enable_lse(&mut self, _: &PWR) -> LSE {
275 self.rb.csr.modify(|_, w| { 284 self.rb.csr.modify(|_, w| {
276 // Enable LSE clock 285 // Enable LSE clock
@@ -338,7 +347,7 @@ impl Rcc {
338 347
339/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration 348/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration
340pub trait RccExt { 349pub trait RccExt {
341 fn freeze(&mut self, config: Config) -> Clocks; 350 fn freeze(self, config: Config) -> Clocks;
342} 351}
343 352
344impl RccExt for RCC { 353impl RccExt for RCC {
@@ -346,7 +355,7 @@ impl RccExt for RCC {
346 // marking this function and all `Config` constructors and setters as `#[inline]`. 355 // marking this function and all `Config` constructors and setters as `#[inline]`.
347 // This saves ~900 Bytes for the `pwr.rs` example. 356 // This saves ~900 Bytes for the `pwr.rs` example.
348 #[inline] 357 #[inline]
349 fn freeze(&mut self, cfgr: Config) -> Clocks { 358 fn freeze(self, cfgr: Config) -> Clocks {
350 let rcc = pac::RCC; 359 let rcc = pac::RCC;
351 let (sys_clk, sw) = match cfgr.mux { 360 let (sys_clk, sw) = match cfgr.mux {
352 ClockSrc::MSI(range) => { 361 ClockSrc::MSI(range) => {