File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 21
21
22
22
static bool __time24 = false ;
23
23
24
+ voidFuncPtr RTC_callBack = NULL ;
25
+
24
26
void RTCZero::begin (bool timeRep)
25
27
{
26
28
uint16_t tmp_reg = 0 ;
@@ -76,6 +78,10 @@ void RTCZero::begin(bool timeRep)
76
78
77
79
void RTC_Handler (void )
78
80
{
81
+ if (RTC_callBack != NULL ) {
82
+ RTC_callBack ();
83
+ }
84
+
79
85
RTC->MODE2 .INTFLAG .reg = RTC_MODE2_INTFLAG_ALARM0; // must clear flag at end
80
86
}
81
87
@@ -93,6 +99,16 @@ void RTCZero::disableAlarm()
93
99
;
94
100
}
95
101
102
+ void RTCZero::attachInterrupt (voidFuncPtr callback)
103
+ {
104
+ RTC_callBack = callback;
105
+ }
106
+
107
+ void RTCZero::detachInterrupt ()
108
+ {
109
+ RTC_callBack = NULL ;
110
+ }
111
+
96
112
/*
97
113
* Get Functions
98
114
*/
Original file line number Diff line number Diff line change 24
24
25
25
#include " Arduino.h"
26
26
27
+ typedef void (*voidFuncPtr)(void );
28
+
27
29
class RTCZero {
28
30
public:
29
31
@@ -43,6 +45,9 @@ class RTCZero {
43
45
44
46
void enableAlarm (Alarm_Match match);
45
47
void disableAlarm ();
48
+
49
+ void attachInterrupt (voidFuncPtr callback);
50
+ void detachInterrupt ();
46
51
47
52
/* Get Functions */
48
53
You can’t perform that action at this time.
0 commit comments