From f960f5b105977b78c7900b0992b97da4c190f8fa Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Wed, 26 May 2021 13:55:25 +0200 Subject: [PATCH] Rework --- embassy-stm32/src/rcc/l0/mod.rs | 15 ++++++++++++--- 1 file 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; use crate::pac::peripherals::{self, RCC, TIM2}; use crate::time::Hertz; use crate::time::U32Ext; +use embassy::util::Unborrow; use pac::rcc::vals; use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw}; @@ -269,8 +270,16 @@ impl Config { } } -/* +/// RCC peripheral +pub struct Rcc {} + impl Rcc { + pub fn new(_rcc: impl Unborrow + 'static) -> Self { + Self {} + } +} + +/* pub fn enable_lse(&mut self, _: &PWR) -> LSE { self.rb.csr.modify(|_, w| { // Enable LSE clock @@ -338,7 +347,7 @@ impl Rcc { /// Extension trait that freezes the `RCC` peripheral with provided clocks configuration pub trait RccExt { - fn freeze(&mut self, config: Config) -> Clocks; + fn freeze(self, config: Config) -> Clocks; } impl RccExt for RCC { @@ -346,7 +355,7 @@ impl RccExt for RCC { // marking this function and all `Config` constructors and setters as `#[inline]`. // This saves ~900 Bytes for the `pwr.rs` example. #[inline] - fn freeze(&mut self, cfgr: Config) -> Clocks { + fn freeze(self, cfgr: Config) -> Clocks { let rcc = pac::RCC; let (sys_clk, sw) = match cfgr.mux { ClockSrc::MSI(range) => {