Skip to content
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