diff options
| author | Ulf Lilleengen <[email protected]> | 2021-05-26 13:55:25 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-05-26 13:55:25 +0200 |
| commit | f960f5b105977b78c7900b0992b97da4c190f8fa (patch) | |
| tree | f55747b94ea364b7a0e8b2d93ae96da724d778e5 | |
| parent | 9743c59ad48996c4c53f0bfdfc8070b67e513ff0 (diff) | |
Rework
| -rw-r--r-- | embassy-stm32/src/rcc/l0/mod.rs | 15 |
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; | |||
| 4 | use crate::pac::peripherals::{self, RCC, TIM2}; | 4 | use crate::pac::peripherals::{self, RCC, TIM2}; |
| 5 | use crate::time::Hertz; | 5 | use crate::time::Hertz; |
| 6 | use crate::time::U32Ext; | 6 | use crate::time::U32Ext; |
| 7 | use embassy::util::Unborrow; | ||
| 7 | use pac::rcc::vals; | 8 | use pac::rcc::vals; |
| 8 | use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw}; | 9 | use 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 |
| 274 | pub struct Rcc {} | ||
| 275 | |||
| 273 | impl Rcc { | 276 | impl 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 |
| 340 | pub trait RccExt { | 349 | pub trait RccExt { |
| 341 | fn freeze(&mut self, config: Config) -> Clocks; | 350 | fn freeze(self, config: Config) -> Clocks; |
| 342 | } | 351 | } |
| 343 | 352 | ||
| 344 | impl RccExt for RCC { | 353 | impl 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) => { |
