Hi, with spare time in my hands due to quarantine I'm picking up a low-power project using STM32L4, prototyping over Nucleo L476RG board. I'm using LPTIM timers, one as PWM (I implemented that in the past) and would like to use the other as pulse-counter by configuring the timer as external clock source, which would count pulses from the given pin.
>From the user-side, I could expose this via the qencoder driver (in this case, >pulses would only go up), although maybe eventually the "qencoder" could be >generalized to "pulse counter". Now, I could have a lower-half driver that >calls into stm32l4_lptim_* functions to initialize timer in pulse-counter mode >and allow to retrieve/reset counter. By looking at stm32l4_lptim.h/c I would >need to extend stm32l4_lptim_setmode to include a new "pulse counter" mode >flag which would just enable the timer (no single/continuous setting). Then I >would need to add a function to allow setting counter mode (external >clock/source, external clock+internal source, internal clock+source) and when >to count (rising, falling, both edges). Also, I would expose the counter via a >getcounter function. Would this be the correct way to expose the pulse-counter functionality of LPTIM? I think it is most similar to how the common TIM functionality is exposed in stm32l4_tim.h/c. Thanks, Matias