-
Notifications
You must be signed in to change notification settings - Fork 3k
st rtc api: remove usage of mktime/localtime in favor of dedicated functions #4479
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
Conversation
…nctions. The use of mktime was causing a fault when called in interrupt handler because on GCC it lock the mutex protecting the environment, To overcome this issue, this patch add dedicated routine to convert a time_t into a tm and vice versa. In the process mktime has been optimized and is now an order of magnitude faster than the routines present in the C library. It should increase the accuracy of the low power timer.
@pan- should the test and time functions be in mbed platform/* directories so other rtc peripherals can use it or are they ST specific? |
Yes, it just fulfill the needs of the ST RTC in that given context:
Nonetheless it wouldn't be difficult to turn functions in this PR into full fledged versions of |
This field was not filled by the previous implementation while being used in rtc_write.
/morph test |
Result: FAILUREYour command has finished executing! Here's what you wrote!
OutputBuild failed! |
void test_is_leap_year() { | ||
for (int i = 70; i < 138; ++i) { | ||
bool expected = is_leap_year(i); | ||
bool actual_value = is_leap_year(i); |
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.
Actual and expected are using the same function
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.
That's embarrassing 😅
superseded by #4499 . |
Description
The use of mktime was causing a fault when called in interrupt handler because on GCC it lock the mutex protecting the environment, To overcome this issue, this patch add dedicated routine to convert a time_t into a tm and vice versa.
In the process mktime has been optimized and is now an order of magnitude faster than the routines present in the C library. It should increase the accuracy of the low power timer.
Status
READY
Migrations
NO
Related PRs
partially solve #4369