-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/ztimer: add power management for ztimer clocks #13722
Conversation
sys/include/ztimer.h
Outdated
@@ -297,6 +297,9 @@ struct ztimer_clock { | |||
uint32_t lower_last; /**< timer value at last now() call */ | |||
ztimer_now_t checkpoint; /**< cumulated time at last now() call */ | |||
#endif | |||
#if MODULE_PM_LAYERED | |||
int8_t required_pm_mode; /**< min. pm mode required for the clock to run */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about using -1
here as a value. 0
is idle and then we have four additional modes. I would be a fan of 255
as an invalid mode, as it is also "below" the deepest sleep mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay good point.
Thinking about this a second time, I would rather define ZTIMER_NO_REQUIRED_PM_MODE
and use this instead of checking magic numbers. Would you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Without knowing all the details about ztimer this looks straightforward. However, is it possible to have the same physical hardware timer for the usec and msec timer? If so, it could be possible to specify different required pm modes. |
Thank you for looking into this PR!
Yes, by default If you want to have a |
Sorry for not giving feedback earlier. I think we should try as proposed here. I thought I could do some actual power measurement, but most of my gear is unavailable due to the quarantine. :( |
@kaspar030 don't worry. I also have to stick with the power measurement included in the SAMR30-XPRO board. It is not that accurate, but I can tell if the board is drawing 10uA or 100uA. |
Is there anything I could do to support the review of this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine.
Tested on nucleo-f401re by pimping tests/periph_pm
using this patch, which sets two timers. (patch assumes that mode 1 is the one to block).
ACK.
@jue89 please rebase and squash! |
7fd71dc
to
73e2261
Compare
Contribution description
This is a follow-up of #13585. After some discussion with @kaspar030 I came up with an implementation of his approach.
The basic idea / assumptions behind this PR:
ZTIMER_USEC
clock.ztimer_t
is running on theZTIMER_USEC
clock.ztimer_t
requires theZTIMER_USEC
clock and unblocks it if noztimer_t
is running onZTIMER_USEC
.Testing procedure
I'll describe the testing procedure later if the over-all architecture is considered acceptable
Issues/PRs references
Closes #13585
Closes #13580