-
Notifications
You must be signed in to change notification settings - Fork 3k
[API] Added option to modify RTC source #926
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
This should not be an atomic operation?
So if I call this function, yes, I "switch RTC callbacks" to new ones but where is the code to for example:
My point is I only call new
rtc_init()
when I set new time. Maybe I should have some flag saying I changed RTC API callbacks, just in case if someone calls rtc read/write I will reinit for him.I probably missed something but I think some piece of comment / documentation about (example usage of:
attach_rtc()
) how it should work in source code would be great.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.
Init is called as it is even now. set_time reinits RTC, and time() invokes set_time() if RTC is not enabled.
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.
Outside of init on which Martin already commented: Yes ideally it is atomic, and also the other RTC functions you don't want interrupted by attach. I might even do something nice with shadow variables. However: Is it really needed? There are a ton of mbed functions which can break when interrupting them (including for example changing pins of the same port to input/output). It seems to me to be in any normal use case a highly unlikely situation where this would interrupt anything: Normally you will call it at the start of your code.
For example usage, I published my test program (ignore lines 26/27, was debugging, not my own library I started with and helloworld was broken). This is using it with a C++ class, where for the functions I needed static member functions. If you do it purely C it would be easier, but this works fine. Should at least clarify how the attach_rtc is used: http://developer.mbed.org/users/Sissors/code/Adafruit_RTCLib/rev/09c202144d63. I don't think the init function will be used often in practise, easier to do that in the constructor.