stm32-rs / stm32wlxx-hal

A Hardware abstraction layer for the stm32wl series chips written in rust.
Apache License 2.0
45 stars 18 forks source link

How to Establish a Continuous LPTIM Peripheral #319

Open justacec opened 2 years ago

justacec commented 2 years ago

I would like to use an LPTIM peripheral to track time. To do so I would like it to be in continuous mode so it just fires off the event and then reloads and keeps going. Unfortunately, the start function implementation for the LPTIM peripherals seems to set the mode to Single. How would I go about setting this up for continuous?

newAM commented 2 years ago

Continuous timers are part of the PwmPin traits: https://github.com/stm32-rs/stm32wlxx-hal/blob/a9d4b5a77d7d4fc6d5da3402328196d980d4b680/hal/src/lptim/mod.rs#L767

There's an example here: https://docs.rs/stm32wlxx-hal/latest/stm32wlxx_hal/lptim/trait.LpTim.html#example-5

The new_output_pin method is optional, that's just for PWM.

justacec commented 2 years ago

Ahh. Got it. I should have seen that. I will take a look there and see if I can get everything to work.

Thanks for being so helpful and responsive. :)

newAM commented 2 years ago

No problem! It is misleading being called PwmPin when the pin isn't even required :sweat_smile: