File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,8 @@ void RTCZero::begin(bool timeRep)
64
64
NVIC_EnableIRQ (RTC_IRQn); // enable RTC interrupt
65
65
NVIC_SetPriority (RTC_IRQn, 0x00 );
66
66
67
- RTC->MODE2 .INTENSET .reg &= ~RTC_MODE2_INTENSET_ALARM0; // disable alarm interrupt by default
67
+ RTC->MODE2 .INTENSET .reg |= RTC_MODE2_INTENSET_ALARM0; // enable alarm interrupt
68
+ RTC->MODE2 .Mode2Alarm [0 ].MASK .bit .SEL = MATCH_OFF; // default alarm match is off (disabled)
68
69
69
70
while (RTCisSyncing ())
70
71
;
@@ -78,6 +79,20 @@ void RTC_Handler(void)
78
79
RTC->MODE2 .INTFLAG .reg = RTC_MODE2_INTFLAG_ALARM0; // must clear flag at end
79
80
}
80
81
82
+ void RTCZero::enableAlarm (Alarm_Match match)
83
+ {
84
+ RTC->MODE2 .Mode2Alarm [0 ].MASK .bit .SEL = match;
85
+ while (RTCisSyncing ())
86
+ ;
87
+ }
88
+
89
+ void RTCZero::disableAlarm ()
90
+ {
91
+ RTC->MODE2 .Mode2Alarm [0 ].MASK .bit .SEL = 0x00 ;
92
+ while (RTCisSyncing ())
93
+ ;
94
+ }
95
+
81
96
/*
82
97
* Get Functions
83
98
*/
Original file line number Diff line number Diff line change 27
27
class RTCZero {
28
28
public:
29
29
30
+ enum Alarm_Match: uint8_t
31
+ {
32
+ MATCH_OFF = 0x00 ,
33
+ MATCH_SS = 0x01 ,
34
+ MATCH_MMSS = 0x02 ,
35
+ MATCH_HHMMSS = 0x03 ,
36
+ MATCH_DHHMMSS = 0x04 ,
37
+ MATCH_MMDDHHMMSS = 0x05 ,
38
+ MATCH_YYMMDDHHMMSS = 0x06
39
+ };
40
+
30
41
RTCZero () {};
31
42
void begin (bool timeRep);
43
+
44
+ void enableAlarm (Alarm_Match match);
45
+ void disableAlarm ();
32
46
33
47
/* Get Functions */
34
48
You can’t perform that action at this time.
0 commit comments