Skip to content

Modify description of set_time() function. #5100

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions platform/mbed_rtc_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ extern "C" {
*
* @note Synchronization level: Thread safe
*
* @note On some platforms time can not be set to 0 since it is invalid value.
* In such case when 0 value is passed to this function, then RTC time
* value is set to 1.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider this a bug with the vendor implementation. If 0 is unsupported by hardware then they should have a software translation.

I would argue code like this should be updated to have an offset instead:

#define RTC_OFFSET 1
time_t rtc_read(void)
{
    return (time_t)(RTC->TSR - RTC_OFFSET);
}

void rtc_write(time_t t)
{
    RTC_StopTimer(RTC);
    RTC->TSR = t + RTC_OFFSET;
    RTC_StartTimer(RTC);
}

* Example:
* @code
* #include "mbed.h"
Expand Down