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
STM32 RTC sub seconds support #61580
STM32 RTC sub seconds support #61580
Conversation
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.
Some comments on new magic values that could be replaced. Otherwise LGTM
1c45c28
to
376f885
Compare
I haven't payed attention to that earlier, but the clock source was checked incorrectly. I've fixed that in the new, first commit. |
7f529f0
to
75dac8b
Compare
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.
LGTM! Thanks
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.
Please add some (at least minimal) way to get this compiled in CI
Sorry for the delay, I'm working on the comments now. |
Do you have any suggestions how to do it? |
Here is the log:
|
Thanks for the logs. How do you run the tests? It's executed on the |
I've managed to reproduce the tests on the nucleo_f429zi board. Working on the fix. |
I've debugged the problem. The test failures occur when 1 tick alarm is programmed. For example I've noticed that the alarm doesn't occur when it is programmed one tick before deadline. It is a case when one tick occurs during the calculation of register values in the I think it means 1 tick alarm won't work for RTC with subseconds and an additional check should be added that the relative minimum tick value is 2. @erwango Please let me know what you think. |
It seems there's a good amount of drivers dealing with such cases already. See STM32 timer based counter driver for instance. |
cfb5f82
to
6b87b05
Compare
I had to use a bit different detection method. It works fine and passes all testes. |
The config values have been hardcoded as magic values. Introduce universal calculation based on the DTS entries. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Synchronize reading two separate registers. In some edge cases the read registers could point different dates. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
6b87b05
to
6ce4d58
Compare
Thanks I'll have a look once I have free time. Just a side note, when updating a PR, please don't rebase at the same time. This prevents to easily see the diff using the compare button provided by github and we have to review the whole change again. If everyone would do the same, it would save a lot of time to reviewers. |
Thanks for the tip. I just noticed how it works. |
1254d33
to
b0a118d
Compare
Sorry for the noise. I run the auto-formatter |
b0a118d
to
ee8654f
Compare
ee8654f
to
26fe61a
Compare
Fix indentations of the API definition. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
RTC drivers uses only seconds, so transition to microseconds is necessary. Change way of calculation tick<->time to avoid unnecessary conversations. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add support for using the sub second registers. It allows reading and setting alarm with the sub second tick resolution. The RTC module is configured to get as high frequency as possible, which equals the source clock (RTCCLK) divided by 2. To get such frequency, the asynchronous prescaler is set to 1. According to RM, setting the asynchronous prescaler to a high value minimize consumption, so the change increase the power consumption. Use a config to enable the sub second support. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
26fe61a
to
b946027
Compare
Split the read function into 2 versions (date and no date) since they don't have common code. It improves readability. Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
b946027
to
20e3123
Compare
Thanks for the comments. I should have done the requested changes by myself. |
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.
LGTM, but I'd like @gautierg-st to approve as well.
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.
LGTM
Implement support for handling the sub second registers.