This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 1d8fb674da5 drivers/timers/pcf85263: report a lost time as lost.
1d8fb674da5 is described below
commit 1d8fb674da5e36f9122f131545c524064244eb92
Author: Royyan Zahir <[email protected]>
AuthorDate: Wed Sep 30 08:20:09 2026 +0400
drivers/timers/pcf85263: report a lost time as lost.
A stopped oscillator sets OS in the seconds register and leaves stale
time behind, which the driver returned as the time. Return -EAGAIN, as
it already does before it is enabled, so the clock starts unset instead
of wrong. Setting the time clears OS.
Signed-off-by: Royyan Zahir <[email protected]>
---
drivers/timers/pcf85263.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/timers/pcf85263.c b/drivers/timers/pcf85263.c
index 6420098341d..96adf092c40 100644
--- a/drivers/timers/pcf85263.c
+++ b/drivers/timers/pcf85263.c
@@ -175,6 +175,7 @@ static uint8_t rtc_bin2bcd(int value)
static int rtc_bcd2bin(uint8_t value)
{
int tens = ((int)value >> 4) * 10;
+
return tens + (value & 0x0f);
}
@@ -379,6 +380,12 @@ int up_rtc_getdatetime(FAR struct tm *tp)
while ((buffer[0] & PCF85263_RTC_SECONDS_MASK) >
(seconds & PCF85263_RTC_SECONDS_MASK));
+ if (buffer[0] & PCF85263_RTC_SECONDS_OS)
+ {
+ rtcwarn("WARNING: oscillator stopped, time lost\n");
+ return -EAGAIN;
+ }
+
/* Format the return time */
/* Return seconds (0-61) */