This commit is contained in:
Ulf Lilleengen 2021-05-26 13:55:25 +02:00
parent 9743c59ad4
commit f960f5b105

View File

@ -4,6 +4,7 @@ use crate::pac;
use crate::pac::peripherals::{self, RCC, TIM2}; use crate::pac::peripherals::{self, RCC, TIM2};
use crate::time::Hertz; use crate::time::Hertz;
use crate::time::U32Ext; use crate::time::U32Ext;
use embassy::util::Unborrow;
use pac::rcc::vals; use pac::rcc::vals;
use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw}; use vals::{Hpre, Lptimen, Msirange, Plldiv, Pllmul, Pllon, Pllsrc, Ppre, Sw};
@ -269,8 +270,16 @@ impl Config {
} }
} }
/* /// RCC peripheral
pub struct Rcc {}
impl Rcc { impl Rcc {
pub fn new(_rcc: impl Unborrow<Target = peripherals::RCC> + 'static) -> Self {
Self {}
}
}
/*
pub fn enable_lse(&mut self, _: &PWR) -> LSE { pub fn enable_lse(&mut self, _: &PWR) -> LSE {
self.rb.csr.modify(|_, w| { self.rb.csr.modify(|_, w| {
// Enable LSE clock // Enable LSE clock
@ -338,7 +347,7 @@ impl Rcc {
/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration /// Extension trait that freezes the `RCC` peripheral with provided clocks configuration
pub trait RccExt { pub trait RccExt {
fn freeze(&mut self, config: Config) -> Clocks; fn freeze(self, config: Config) -> Clocks;
} }
impl RccExt for RCC { impl RccExt for RCC {
@ -346,7 +355,7 @@ impl RccExt for RCC {
// marking this function and all `Config` constructors and setters as `#[inline]`. // marking this function and all `Config` constructors and setters as `#[inline]`.
// This saves ~900 Bytes for the `pwr.rs` example. // This saves ~900 Bytes for the `pwr.rs` example.
#[inline] #[inline]
fn freeze(&mut self, cfgr: Config) -> Clocks { fn freeze(self, cfgr: Config) -> Clocks {
let rcc = pac::RCC; let rcc = pac::RCC;
let (sys_clk, sw) = match cfgr.mux { let (sys_clk, sw) = match cfgr.mux {
ClockSrc::MSI(range) => { ClockSrc::MSI(range) => {