RTC_BASE_YEAR is set to 1980 in hal_rtc.h, and used in hal_rtc.c [rtcConvertDateTimeToStructTm() and rtcConvertStructTmToDateTime()] to calculate an offset in years from the start of 1980.
A consequence of this is that the year field in the TOD clock is 20 years ahead, which gives scope for confusion.
Maybe this was intentional; however the RP2040 RTC driver looks as if it might store the year as is.
There do seem to be some wider consequences to attempting to redefine RTC_BASE_YEAR (e.g. FAT filesystem time stamp calculations, and the start date for UNIX time stamps), so maybe any handling of the 20-year offset should be in the individual LLDs.
For now I've put this aside; might try and offer a patch later (depends how frustrated I get explaining to forgetful others why the "raw" year is out by 20!)
RTC_BASE_YEAR cannot be overridden
- Giovanni
- Site Admin
- Posts: 14320
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1054 times
- Been thanked: 895 times
- Contact:
Re: RTC_BASE_YEAR cannot be overridden
Hi,
LLD are meant to do adjustments, the 1980 as base year is only the external representation. Do you see a better approach?
Giovanni
LLD are meant to do adjustments, the 1980 as base year is only the external representation. Do you see a better approach?
Giovanni
Re: RTC_BASE_YEAR cannot be overridden
Giovanni wrote:LLD are meant to do adjustments, the 1980 as base year is only the external representation. Do you see a better approach?
Not in this specific case - I agree that LLDs are the place to do the adjustment, but didn't make it very clear. Really putting up a marker for any new stuff. And perhaps highlighting that, where possible, there should be close correlation between high level data and its low-level representation (on any LLD).
Who is online
Users browsing this forum: No registered users and 7 guests