1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-22 04:53:50 +01:00

cpu/stm32: use RIOT_EPOCH

This commit is contained in:
Benjamin Valentin 2020-08-07 13:27:31 +02:00
parent 6d684ee748
commit 97bf000bcd

View File

@ -163,9 +163,8 @@
#error "rtc: unable to determine RTC SYNC and ASYNC prescalers from LSI value"
#endif
/* struct tm counts years since 1900 but RTC has only two-digit year hence the
* offset of 100 years. */
#define YEAR_OFFSET (100)
/* struct tm counts years since 1900 but RTC has only two-digit year, hence the offset */
#define YEAR_OFFSET (RIOT_EPOCH - 1900)
/* Use a magic number to determine the initial RTC source. This will be used
to know if a reset of the RTC is required at initialization. */
@ -273,7 +272,7 @@ int rtc_set_time(struct tm *time)
rtc_unlock();
RTC->DR = (val2bcd((time->tm_year % 100), RTC_DR_YU_Pos, DR_Y_MASK) |
RTC->DR = (val2bcd((time->tm_year - YEAR_OFFSET), RTC_DR_YU_Pos, DR_Y_MASK) |
val2bcd(time->tm_mon + 1, RTC_DR_MU_Pos, DR_M_MASK) |
val2bcd(time->tm_mday, RTC_DR_DU_Pos, DR_D_MASK));
RTC->TR = (val2bcd(time->tm_hour, RTC_TR_HU_Pos, TR_H_MASK) |