File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -69,8 +69,14 @@ void STM32RTC::begin(bool resetTime, Hour_Format format)
6969 , resetTime);
7070 _timeSet = !reinit;
7171
72- syncTime ();
7372 syncDate ();
73+ syncTime ();
74+
75+ /* fix race condition where date may have changed between reading date and time */
76+ if (_seconds == 0 && _minutes == 0 && _hours == 0 ) {
77+ syncDate ();
78+ }
79+
7480 syncAlarmTime ();
7581 if (!IS_RTC_DATE (_alarmDay)) {
7682 // Use current time to init alarm members,
@@ -1109,6 +1115,11 @@ time_t STM32RTC::getEpoch(uint32_t *subSeconds)
11091115 syncDate ();
11101116 syncTime ();
11111117
1118+ /* fix race condition where date may have changed between reading date and time */
1119+ if (_seconds == 0 && _minutes == 0 && _hours == 0 ) {
1120+ syncDate ();
1121+ }
1122+
11121123 tm.tm_isdst = -1 ;
11131124 /*
11141125 * mktime ignores the values supplied by the caller in the
You can’t perform that action at this time.
0 commit comments