Struct stm32wlxx_hal::rcc::Lsco
source · pub struct Lsco { /* private fields */ }
Expand description
Low-speed oscillator output pin.
Implementations§
source§impl Lsco
impl Lsco
sourcepub unsafe fn enable(
a2: A2,
sel: LscoSel,
rcc: &mut RCC,
cs: &CriticalSection
) -> Self
pub unsafe fn enable( a2: A2, sel: LscoSel, rcc: &mut RCC, cs: &CriticalSection ) -> Self
Enable the low-speed oscillator output.
Safety
- Backup domain write protect must be disabled.
- The selected clock must be enabled for system use.
Example
use stm32wlxx_hal::{
gpio::PortA,
pac,
rcc::{Lsco, LscoSel},
};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
// disable backup domain write protect
dp.PWR.cr1.modify(|_, w| w.dbp().enabled());
// enable the LSE clock
dp.RCC
.bdcr
.modify(|_, w| w.lseon().on().lsesysen().enabled());
while dp.RCC.bdcr.read().lserdy().is_not_ready() {}
while dp.RCC.bdcr.read().lsesysrdy().is_not_ready() {}
let gpioa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let a2: Lsco = cortex_m::interrupt::free(|cs| unsafe {
Lsco::enable(gpioa.a2, LscoSel::Lse, &mut dp.RCC, cs)
});
sourcepub unsafe fn disable(self, rcc: &mut RCC) -> A2
pub unsafe fn disable(self, rcc: &mut RCC) -> A2
Disable the low-speed oscillator output.
Safety
- Backup domain write protect must be disabled.
Example
use stm32wlxx_hal::{
gpio::{pins, PortA},
pac,
rcc::{Lsco, LscoSel},
};
let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();
// disable backup domain write protect
dp.PWR.cr1.modify(|_, w| w.dbp().enabled());
// enable the LSE clock
dp.RCC
.bdcr
.modify(|_, w| w.lseon().on().lsesysen().enabled());
while dp.RCC.bdcr.read().lserdy().is_not_ready() {}
while dp.RCC.bdcr.read().lsesysrdy().is_not_ready() {}
let gpioa: PortA = PortA::split(dp.GPIOA, &mut dp.RCC);
let lsco: Lsco = cortex_m::interrupt::free(|cs| unsafe {
Lsco::enable(gpioa.a2, LscoSel::Lse, &mut dp.RCC, cs)
});
// ... use LSCO
let a2: pins::A2 = unsafe { lsco.disable(&mut dp.RCC) };
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Lsco
impl Send for Lsco
impl Sync for Lsco
impl Unpin for Lsco
impl UnwindSafe for Lsco
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more