File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -421,12 +421,16 @@ void RTCZero::setEpoch(uint32_t ts)
421
421
time_t t = ts;
422
422
struct tm * tmp = gmtime (&t);
423
423
424
- RTC->MODE2 .CLOCK .bit .YEAR = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
425
- RTC->MODE2 .CLOCK .bit .MONTH = tmp->tm_mon + 1 ;
426
- RTC->MODE2 .CLOCK .bit .DAY = tmp->tm_mday ;
427
- RTC->MODE2 .CLOCK .bit .HOUR = tmp->tm_hour ;
428
- RTC->MODE2 .CLOCK .bit .MINUTE = tmp->tm_min ;
429
- RTC->MODE2 .CLOCK .bit .SECOND = tmp->tm_sec ;
424
+ RTC_MODE2_CLOCK_Type clockTime;
425
+
426
+ clockTime.bit .YEAR = tmp->tm_year - EPOCH_TIME_YEAR_OFF;
427
+ clockTime.bit .MONTH = tmp->tm_mon + 1 ;
428
+ clockTime.bit .DAY = tmp->tm_mday ;
429
+ clockTime.bit .HOUR = tmp->tm_hour ;
430
+ clockTime.bit .MINUTE = tmp->tm_min ;
431
+ clockTime.bit .SECOND = tmp->tm_sec ;
432
+
433
+ RTC->MODE2 .CLOCK .reg = clockTime.reg ;
430
434
431
435
while (RTCisSyncing ())
432
436
;
You can’t perform that action at this time.
0 commit comments