Module stm32wlxx_hal::lptim

source ·
Expand description

Low-power timers

The low power timers implements the embedded-hal PwmPin and CountDown traits.

Example

Setup a one-shot timer.

use stm32wlxx_hal::{
    embedded_hal::timer::CountDown,
    lptim::{self, LpTim, LpTim1, Prescaler::Div1},
    pac,
};

let mut dp: pac::Peripherals = pac::Peripherals::take().unwrap();

// enable the HSI16 source clock
dp.RCC.cr.modify(|_, w| w.hsion().set_bit());
while dp.RCC.cr.read().hsirdy().is_not_ready() {}

let mut lptim1: LpTim1 = LpTim1::new(dp.LPTIM1, lptim::Clk::Hsi16, Div1, &mut dp.RCC);
// wait 16,000 cycles at 16MHz
lptim1.start(16_000_u16);
nb::block!(lptim1.wait());

Modules

Structs

Enums

  • Timer clock selection.
  • Filter for triggers and external clocks.
  • Timer clock prescaler.
  • Trigger polarity.
  • LPTIM1 and LPTIM2 trigger selection.
  • LPTIM3 trigger selection.

Traits

  • Low-power timer trait.