cpu/cc2538: RTT: implement missing API functions#14700
Merged
benpicco merged 3 commits intoRIOT-OS:masterfrom Aug 7, 2020
Merged
cpu/cc2538: RTT: implement missing API functions#14700benpicco merged 3 commits intoRIOT-OS:masterfrom
benpicco merged 3 commits intoRIOT-OS:masterfrom
Conversation
We can't set the hardware counter directly, so always add an offset.
We can't read back the alarm, so just store it in a variable.
Previously the setting the alarm would overwrite the overflow callback and vice versa. Since we can only set one alarm in hardware, always set the alarm to the closest event of the two.
Contributor
Author
|
ping @benpicco |
benpicco
approved these changes
Aug 6, 2020
Contributor
benpicco
left a comment
There was a problem hiding this comment.
The overhead is just a few instructions and if those functions are useful after all, we might as well add them.
It's a pity there are no tests for those / the API is not clear here.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contribution description
This PR is a takeover of #13630, rest of the description is as in the original PR, I only removed comments made in #13630 (review). This PR should help addressing #13686 since the application does not compile because of the missing functions.
The RTT implementation of
cpu/cc2538is based on the sleep timer, a 32 bit 32kHz timer that can only be read and that only supports one alarm. (No overflow interrupt)This implements functions that are defined by the RIOT API, but are not directly supported by the hardware:
rtt_set_counter(): as we can't set the counter directly, add an offset to the raw counter value insteadrtt_get_alarm(): we can't read back the alarm time, so store it in a local variable. This is also needed forrtt_set_overflow_cb(): In the previous implementation the overflow callback would always overwrite the alarm callback and vice versa.To fix this, check which event will occur first and set that alarm as well as a flag to tell which alarm it was.
When the alarm rings, set the alarm to the other event if there is one.
Testing procedure
There are no tests for those functions.
Issues/PRs references
I implemented those for #13519, but then discovered I don't need them.
So I'm not sure if this should be added just for completeness' sake when we could just as well do without.