Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Add rtc module #93
Add rtc module #93
Changes from 12 commits
c113526
5a7723a
b24c4f9
9175483
7cf3829
476a92c
44fe6fc
fb505ec
1422683
98c3f24
c629df9
1533749
144588e
4c6d8d6
91f831b
4777f6d
158632a
ad355d6
348e4a9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
We must not allow cloning of the
CFGR
struct. This struct is responsible for making sure that the clocks are only configured once. When you callfreeze()
it consumes the struct and thereby ensures the clocks won't change anymore, so other code can rely on that. If you makeCFGR
clonable you could suddenly have multiple instances of this struct around, which would allow you to change the clocks and break the assumption that they are stableThere 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.
Where do these numbers come from? Have you considered that HSE is variable and can differ between boards?
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.
These numbers came from AN4795:
I like the idea of a function that takes care of choosing the correct prescalers to produce a 1 hz RTC clock source. This is possible for LSI and LSE, but the fact that HSE frequency can vary (I read that the HSE frequency can be between 4 and 32 Mhz) makes that a challenge.
The concept of making some methods "visible" given a parameter (the RTCSrc) sounds like a good solution, if it is possible.
For example :
if RTCSrc::LSE or RTCSrc::LSI, make the following method visible....
else, there is a more general function
set_frequency
that is always visible that would be used if the user is using an HSE of any frequency. The user would then supply prescalers to set appropriate frequency.I think I am not using the correct words to search to see if this feature of making methods "visible" or "invisible" exists, because I am not able to find anything online. Can something like this be accomplished?
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.
Ah interesting to know. I would like to see a comment or make these tuples for fixed "input" frequencies (meaning LSI LSE) constants.
I have difficulties to find the AN4795 Application note, can you provide a link?
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.
Apologies, it was a typo. I meant AN4759
Here is the link:
https://www.st.com/resource/en/application_note/dm00226326-using-the-hardware-realtime-clock-rtc-and-the-tamper-management-unit-tamp-with-stm32-microcontrollers-stmicroelectronics.pdf
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.
Because HSE clock frequencies can vary, perhaps the user should choose a source and prescaler values to produce the desired rtc input clock speed through a configuration structure.
eg.
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.
So, if I understand correctly, this function converts
92
to9
and2
. If that's true then you could massively simplify it to:But there also needs to be a (panicking) check that
word
is smaller than 100.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.
Similarly, this can be simplified to: