sys/ztimer: add LPTIMER auto init#17654
Conversation
|
Maybe @jue89 could review this, as he has the hardware and also is interested in a use case for this. |
|
So say I have --- a/boards/same54-xpro/include/periph_conf.h
+++ b/boards/same54-xpro/include/periph_conf.h
@@ -92,6 +92,15 @@ static const tc32_conf_t timer_config[] = {
.gclk_id = TC2_GCLK_ID,
.gclk_src = SAM0_GCLK_TIMER,
.flags = TC_CTRLA_MODE_COUNT32,
+ },
+ { /* Timer 2, low power */
+ .dev = TC4,
+ .irq = TC4_IRQn,
+ .mclk = &MCLK->APBCMASK.reg,
+ .mclk_mask = MCLK_APBCMASK_TC4 | MCLK_APBCMASK_TC5,
+ .gclk_id = TC4_GCLK_ID,
+ .gclk_src = SAM0_GCLK_32KHZ,
+ .flags = TC_CTRLA_MODE_COUNT32,
}
};
@@ -103,6 +112,10 @@ static const tc32_conf_t timer_config[] = {
#define TIMER_1_CHANNELS 2
#define TIMER_1_ISR isr_tc2
+/* Timer 2 configuration */
+#define TIMER_2_CHANNELS 2
+#define TIMER_2_ISR isr_tc4
+
#define TIMER_NUMOF ARRAY_SIZE(timer_config)
/** @} */how would I go about using this? |
|
maybe the example commit helps reviewing this I am not sure how to incorporate the extra timer configuration with our boards (stm32 had just one perih_timer prepared for use -not sure how common that is) i should have used timer5 (TIM3 has only 16bits) |
6057078 to
00afe56
Compare
|
I can confirm that this works on Please squash (& rebase to solve the merge conflict) |
384843f to
3bb2929
Compare
tests/ztimer_xsec/Makefile
Outdated
| USEMODULE += ztimer_sec | ||
| USEMODULE += ztimer_periph_lptimer | ||
|
|
||
| CFLAGS += "-DCONFIG_ZTIMER_LPTIMER_DEV=TIMER_DEV(1)" "-DCONFIG_ZTIMER_LPTIMER_FREQ=1000LU" "-DCONFIG_ZTIMER_LPTIMER_WIDTH=32" "-DCONFIG_ZTIMER_LPTIMER_BLOCK_PM_MODE=ZTIMER_CLOCK_NO_REQUIRED_PM_MODE" |
There was a problem hiding this comment.
This will break for all non-stm32 boards
There was a problem hiding this comment.
i will remove that -- maybe i should remove the whole example commit ?
There was a problem hiding this comment.
Yea it's probably for the better
|
I the details a diff can be found adding a second timer for stm32 (may not work on all devices) and using that in the Details |
3bb2929 to
81d06c8
Compare
Contribution description
adds LPTIMER to ztimer auto init
Testing procedure
have to be defined
and
ztimer_periph_lptimerbe used
msec and sec prefer lptimer over rtt
I the details a diff can be found adding a second timer for stm32 (may not work on all devices) and using that in the
ztimer_xsecexample since this PR is about adding the lowpower-timer (lptimer) support toztimerthis was removed from it.Details
Issues/PRs references
includes #16342
fixes #17611
this may help with using rtt64 by PR #18120