Skip to content

Commit

Permalink
lse_enable() should be available on all platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
akashihi committed Oct 14, 2020
1 parent d4edfbc commit 7c82114
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/rcc.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::pac::RCC;
use crate::pwr::PWR;
use crate::time::{Hertz, U32Ext};

#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
use crate::{pac::CRS, pwr::PWR, syscfg::SYSCFG};
use crate::{pac::CRS, syscfg::SYSCFG};

/// System clock mux source
#[derive(Clone, Copy)]
Expand Down Expand Up @@ -192,6 +193,17 @@ pub struct Rcc {
pub(crate) rb: RCC,
}

impl Rcc {

pub fn enable_lse(&mut self, _: &PWR) {
self.rb.csr.modify(|_, w| {
// Enable LSE clock
w.lseon().set_bit()
});
while self.rb.csr.read().lserdy().bit_is_clear() {}
}
}

#[cfg(any(feature = "stm32l0x2", feature = "stm32l0x3"))]
impl Rcc {
pub fn enable_hsi48(&mut self, syscfg: &mut SYSCFG, crs: CRS) -> HSI48 {
Expand Down Expand Up @@ -224,14 +236,6 @@ impl Rcc {

HSI48(())
}

pub fn enable_lse(&mut self, _: &PWR) {
self.rb.csr.modify(|_, w| {
// Enable LSE clock
w.lseon().set_bit()
});
while self.rb.csr.read().lserdy().bit_is_clear() {}
}
}

/// Extension trait that freezes the `RCC` peripheral with provided clocks configuration
Expand Down

0 comments on commit 7c82114

Please sign in to comment.