[riot-notifications] [RIOT-OS/RIOT] Manual init for ztimer (#16756)
notifications at github.com
Thu Aug 19 11:28:58 CEST 2021
I would like to have a simple way for manually initializing ztimer: a simple call to `ztimer_init()` for instance.
#### Use case
The RTC subsystem of CPUs in SAM0 family is endowed with a few 32 bit registers marked as "general purpose" - they are meant for users to store data in (not all CPUs in the family sport them; existence can be tested with `#ifdef RTC_GPR_NUM`).
My specific use case is to store state that persist after deep sleep; which is called BACKUP mode on SAML21/SAMR34 CPUs. In backup mode the RTC clock is still powered - so any data in those registers will be available when waking up again.
Now, for the problem: resetting the RTC wipes those registers, and in RIOT this happens in on RTT/RTC initialization.
For solving this, I added
DISABLE_MODULE += periph_init_rtt
to my application Makefile, and persist manually the values at boot:
for (int i = 0; i < RTC_GPR_NUM; i++) persist[i] = RTC->MODE0.GP[i].reg;
for (int i = 0; i < RTC_GPR_NUM; i++) RTC->MODE0.GP[i].reg = persist[i];
This approach works well with the `periph_rtt` module, but I cannot find a way to produce the same solution with `ztimer`. Which is like my fault: I can't really understand how ztimer auto init can be disabled, and how to manually init the timers.
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications