Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit97adafa

Browse files
ant32tfpistm
authored andcommitted
fix reading time after date race
1 parenta3036e0 commit97adafa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎src/STM32RTC.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp