Struct stm32wlxx_hal::rcc::Lsco

source ·
pub struct Lsco { /* private fields */ }
Expand description

Low-speed oscillator output pin.

Implementations§

source§

impl Lsco

source

pub unsafe fn enable( a2: A2, sel: LscoSel, rcc: &mut RCC, cs: &CriticalSection ) -> Self

Enable the low-speed oscillator output.

Safety
  1. Backup domain write protect must be disabled.
  2. 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)
});
source

pub unsafe fn disable(self, rcc: &mut RCC) -> A2

Disable the low-speed oscillator output.

Safety
  1. 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§

source§

impl Debug for Lsco

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.