File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ void RTCZero::begin(bool resetTime)
50
50
// not due to POR or BOD, preserve the clock time
51
51
// POR causes a reset anyway, BOD behaviour is?
52
52
bool validTime = false ;
53
- RTC_MODE2_CLOCK_Type oldTime;
53
+ RTC_MODE2_CLOCK_Type oldTime = {. reg = 0L } ;
54
54
55
55
if ((!resetTime) && (PM->RCAUSE .reg & (PM_RCAUSE_SYST | PM_RCAUSE_WDT | PM_RCAUSE_EXT))) {
56
56
if (RTC->MODE2 .CTRL .reg & RTC_MODE2_CTRL_MODE_CLOCK) {
@@ -391,11 +391,32 @@ time_t RTCZero::getEpoch()
391
391
return mktime (&tm );
392
392
}
393
393
394
- uint32_t RTCZero::getY2kEpoch ()
394
+ time_t RTCZero::getY2kEpoch ()
395
395
{
396
396
return (getEpoch () - EPOCH_TIME_OFF);
397
397
}
398
398
399
+ time_t RTCZero::getAlarmEpoch ()
400
+ {
401
+ RTCreadRequest ();
402
+ RTC_MODE2_ALARM_Type alarmTime;
403
+ alarmTime.reg = RTC->MODE2 .Mode2Alarm [0 ].ALARM .reg ;
404
+
405
+ struct tm tm ;
406
+
407
+ tm .tm_isdst = -1 ;
408
+ tm .tm_yday = 0 ;
409
+ tm .tm_wday = 0 ;
410
+ tm .tm_year = alarmTime.bit .YEAR + EPOCH_TIME_YEAR_OFF;
411
+ tm .tm_mon = alarmTime.bit .MONTH - 1 ;
412
+ tm .tm_mday = alarmTime.bit .DAY ;
413
+ tm .tm_hour = alarmTime.bit .HOUR ;
414
+ tm .tm_min = alarmTime.bit .MINUTE ;
415
+ tm .tm_sec = alarmTime.bit .SECOND ;
416
+
417
+ return mktime (&tm );
418
+ }
419
+
399
420
void RTCZero::setAlarmEpoch (uint32_t ts)
400
421
{
401
422
if (_configured) {
Original file line number Diff line number Diff line change @@ -92,7 +92,8 @@ class RTCZero {
92
92
/* Epoch Functions */
93
93
94
94
time_t getEpoch ();
95
- uint32_t getY2kEpoch ();
95
+ time_t getY2kEpoch ();
96
+ time_t getAlarmEpoch ();
96
97
void setEpoch (uint32_t ts);
97
98
void setY2kEpoch (uint32_t ts);
98
99
void setAlarmEpoch (uint32_t ts);
You can’t perform that action at this time.
0 commit comments