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 ...
This commit is contained in:
parent
111ebd65c5
commit
0fcfae7d1c
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user