From 0fcfae7d1c763fd398366f4139fed8b55febae43 Mon Sep 17 00:00:00 2001 From: Th3maz1ng Date: Sun, 22 Oct 2023 09:02:38 +0200 Subject: [PATCH] Reworked the RTC driver to internally track the years from 2000 and not 1900 as there are only 7 bits for storing the years and this would overflow in 2028 ... --- src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c b/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c index cd4d1fc..6411e06 100644 --- a/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c +++ b/src/W800_SDK_v1.00.10/platform/drivers/rtc/wm_rtc.c @@ -50,6 +50,7 @@ void tls_set_rtc(struct tm *tblock) ctrl2 = 0; ctrl2 |= tblock->tm_mon; + tblock->tm_year -= 100; ctrl2 |= tblock->tm_year << 8; tls_reg_write32(HR_PMU_RTC_CTRL2, ctrl2); @@ -75,6 +76,7 @@ void tls_get_rtc(struct tm *tblock) ctrl1 = tls_reg_read32(HR_PMU_RTC_CTRL1); ctrl2 = tls_reg_read32(HR_PMU_RTC_CTRL2); tblock->tm_year = ((int)((int)ctrl2 & 0x00007f00) >> 8); + tblock->tm_year += 100; tblock->tm_mon = (ctrl2 & 0x0000000f); tblock->tm_mday = (ctrl1 & 0x1f000000) >> 24; tblock->tm_hour = (ctrl1 & 0x001f0000) >> 16;