Skip to content

Commit 35676eb

Browse files
committed
Support WioExtRTC to GD32F4XX
1 parent 82852b3 commit 35676eb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/Extension/WioExtRTC.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,27 @@ bool WioExtRTC::HwGetDateTime(int& year2digit, int& month, int& day, int& weekda
153153
return true;
154154
}
155155

156+
#if defined TARGET_GD32F4XX
157+
uint8_t data[7];
158+
uint8_t data2[7];
159+
for (int i = 0; i < sizeof(data); ++i)
160+
{
161+
if (_Device->ReadReg8(PCF8523_SECONDS + i, &data[i]) != 1) return false;
162+
}
163+
while (true)
164+
{
165+
for (int i = 0; i < sizeof(data2); ++i)
166+
{
167+
if (_Device->ReadReg8(PCF8523_SECONDS + i, &data2[i]) != 1) return false;
168+
}
169+
if (memcmp(data, data2, sizeof(data)) == 0) break;
170+
171+
memcpy(data, data2, sizeof(data));
172+
}
173+
#else
156174
uint8_t data[7];
157175
if (_Device->ReadRegN(PCF8523_SECONDS, data, sizeof(data)) != sizeof(data)) return false;
176+
#endif
158177

159178
second = DecodeBCD(data[0] & 0x7f);
160179
minute = DecodeBCD(data[1] & 0x7f);

0 commit comments

Comments
 (0)