@@ -56,15 +56,15 @@ static void rtc_configure_time_and_date()
5656 mDate .WeekDay = 1 ;
5757 mDate .Month = 1 ;
5858 mDate .Date = 1 ;
59- mDate .Year = 1970 ;
59+ mDate .Year = 2 ;
6060 if (HAL_RTC_SetDate (& RtcHandle , & mDate , RTC_FORMAT_BIN ) != HAL_OK ) {
6161 error ("Date set failed\n" );
6262 }
6363
6464 mTime .Hours = 0 ;
6565 mTime .Minutes = 0 ;
6666 mTime .Seconds = 0 ;
67- mTime .TimeFormat = RTC_HOURFORMAT12_AM ;
67+ mTime .TimeFormat = RTC_HOURFORMAT_24 ;
6868 mTime .DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
6969 mTime .StoreOperation = RTC_STOREOPERATION_RESET ;
7070 if (HAL_RTC_SetTime (& RtcHandle , & mTime , RTC_FORMAT_BIN ) != HAL_OK ) {
@@ -243,12 +243,7 @@ time_t rtc_read(void) {
243243 timeinfo .tm_wday = dateStruct .WeekDay ;
244244 timeinfo .tm_mon = dateStruct .Month - 1 ;
245245 timeinfo .tm_mday = dateStruct .Date ;
246- #if DEVICE_LOWPOWERTIMER
247- //We need to add 52 to get the 1970 year
248- timeinfo .tm_year = dateStruct .Year + 52 ;
249- #else
250- timeinfo .tm_year = dateStruct .Year + 100 ;
251- #endif
246+ timeinfo .tm_year = dateStruct .Year + 68 ;
252247 timeinfo .tm_hour = timeStruct .Hours ;
253248 timeinfo .tm_min = timeStruct .Minutes ;
254249 timeinfo .tm_sec = timeStruct .Seconds ;
@@ -273,11 +268,11 @@ void rtc_write(time_t t) {
273268 dateStruct .WeekDay = timeinfo -> tm_wday ;
274269 dateStruct .Month = timeinfo -> tm_mon + 1 ;
275270 dateStruct .Date = timeinfo -> tm_mday ;
276- dateStruct .Year = timeinfo -> tm_year - 100 ;
271+ dateStruct .Year = timeinfo -> tm_year - 68 ;
277272 timeStruct .Hours = timeinfo -> tm_hour ;
278273 timeStruct .Minutes = timeinfo -> tm_min ;
279274 timeStruct .Seconds = timeinfo -> tm_sec ;
280- timeStruct .TimeFormat = RTC_HOURFORMAT12_PM ;
275+ timeStruct .TimeFormat = RTC_HOURFORMAT_24 ;
281276 timeStruct .DayLightSaving = RTC_DAYLIGHTSAVING_NONE ;
282277 timeStruct .StoreOperation = RTC_STOREOPERATION_RESET ;
283278
@@ -295,7 +290,7 @@ void rtc_set_alarm(struct tm *ti, uint32_t subsecs)
295290 mAlarm .AlarmTime .Minutes = ti -> tm_min ;
296291 mAlarm .AlarmTime .Seconds = ti -> tm_sec ;
297292 mAlarm .AlarmTime .SubSeconds = subsecs ;
298- mAlarm .AlarmTime .TimeFormat = RTC_HOURFORMAT12_AM ;
293+ mAlarm .AlarmTime .TimeFormat = RTC_HOURFORMAT_24 ;
299294 mAlarm .AlarmMask = RTC_ALARMMASK_DATEWEEKDAY ;
300295 mAlarm .AlarmSubSecondMask = RTC_ALARMSUBSECONDMASK_NONE ;
301296 mAlarm .AlarmDateWeekDaySel = RTC_ALARMDATEWEEKDAYSEL_DATE ;
0 commit comments