Module stm32l4x6_lptim1

Source
Expand description

A AsyncTimer implementation for the LPTIM1 peripheral in the STM32L4x6 running at 32kHz.

This module provides it’s own RTC implementation on top of the LPTIM1 which extends its 16 bit counter to 32 bits, and provides alarms.

This implementation assumes:

  • LSI on.
  • 32kHz granularity.
  • Interrupts are handled at least every second.
  • ~1.5 days maximum operation time.

Warning: time will not observably progress (from get_time()) unless interrupts are handled.

let p = stm32l4xx_hal::stm32::Peripherals::take().unwrap();
let timer = AsyncTimer::new(Lptim1Rtc::new(p.LPTIM1, &p.RCC)));
let mut flash = p.FLASH.constrain();
let mut rcc = p.RCC.constrain();
rcc.cfgr.lsi(true).freeze(&mut flash.acr);

Do not forget to call handle_interrupt in the interrupt handler for LPTIM1.

Structs§

DeadlinePassed
Error to indicate that the just scheduled deadline has already passed.
DurationU32
The duration as efficiently usable with instants of the Lptim1Rtc timer.
InstantU32
The instant as directly used by the Lptim1Rtc timer.
Lptim1Rtc
A low-level Real Time Clock with alarms implemented with the LPTIM1 peripheral.

Functions§

handle_interrupt
Handle the LPTIM1 interrupt.