Struct stm32l0xx_hal::lptim::LpTimer
source · [−]pub struct LpTimer<M: CountMode> { /* private fields */ }
Expand description
Low-Power Timer (LPTIM
).
The Low-Power Timer is a 16-bit timer with a prescaler of up to 128. It can run off of the APB1, LSI, HSI16, or LSE clocks. With LSE, the slowest clock at 32.768 kHz, this results in a maximum timeout of 256 seconds, or 4 minutes and 16 seconds.
The timer can be initialized either in one-shot mode or in periodic mode, using init_oneshot
or init_periodic
respectively. In periodic mode, the embedded-hal Periodic
marker trait is
implemented and the CountDown
implementation uses Hertz
as the time unit. In one-shot mode,
the CountDown
implementation instead uses Microseconds
, allowing for a multi-second timeout
to be configured (with the tradeoff being a larger code size due to use of 64-bit arithmetic).
Implementations
sourceimpl LpTimer<Encoder>
impl LpTimer<Encoder>
sourcepub fn init_encoder(
lptim: LPTIM,
pwr: &mut PWR,
rcc: &mut Rcc,
clk: ClockSrc,
(pb5, pb7): (PB5<Analog>, PB7<Analog>)
) -> Self
pub fn init_encoder(
lptim: LPTIM,
pwr: &mut PWR,
rcc: &mut Rcc,
clk: ClockSrc,
(pb5, pb7): (PB5<Analog>, PB7<Analog>)
) -> Self
Initializes the Low-Power Timer in encoder mode.
The start
method must be called to enable the encoder input.
sourcepub fn enable(&mut self, arr: u16)
pub fn enable(&mut self, arr: u16)
Enable the timer and begin counting encoder pulses.
The provided value is stored in the ARR (Auto Reload Register). The timer’s internal counter will wrap when this value is reached.
sourcepub fn clear_flags(&self)
pub fn clear_flags(&self)
Clear all LPTIM interrupt flags
sourceimpl<M: CountMode> LpTimer<M>
impl<M: CountMode> LpTimer<M>
sourcepub fn free(self) -> LPTIM
pub fn free(self) -> LPTIM
Disables and destructs the timer, returning the raw LPTIM
peripheral.
sourcepub fn enable_interrupts(&mut self, interrupts: Interrupts)
pub fn enable_interrupts(&mut self, interrupts: Interrupts)
Disables the timer and enables the given interrupts.
sourcepub fn disable_interrupts(&mut self, interrupts: Interrupts)
pub fn disable_interrupts(&mut self, interrupts: Interrupts)
Disables the timer and disables the given interrupts.
Trait Implementations
impl Periodic for LpTimer<Periodic>
Auto Trait Implementations
impl<M> RefUnwindSafe for LpTimer<M> where
M: RefUnwindSafe,
impl<M> Send for LpTimer<M> where
M: Send,
impl<M> !Sync for LpTimer<M>
impl<M> Unpin for LpTimer<M> where
M: Unpin,
impl<M> UnwindSafe for LpTimer<M> where
M: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more