Skip to content

Commit b8504c9

Browse files
committed
Added attachable ISR.
This is not strictly required for a wake alarm as the IRQ routine will wake the board.
1 parent 656c8a2 commit b8504c9

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/RTCZero.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
static bool __time24 = false;
2323

24+
voidFuncPtr RTC_callBack = NULL;
25+
2426
void RTCZero::begin(bool timeRep)
2527
{
2628
uint16_t tmp_reg = 0;
@@ -76,6 +78,10 @@ void RTCZero::begin(bool timeRep)
7678

7779
void RTC_Handler(void)
7880
{
81+
if (RTC_callBack != NULL) {
82+
RTC_callBack();
83+
}
84+
7985
RTC->MODE2.INTFLAG.reg = RTC_MODE2_INTFLAG_ALARM0; // must clear flag at end
8086
}
8187

@@ -93,6 +99,16 @@ void RTCZero::disableAlarm()
9399
;
94100
}
95101

102+
void RTCZero::attachInterrupt(voidFuncPtr callback)
103+
{
104+
RTC_callBack = callback;
105+
}
106+
107+
void RTCZero::detachInterrupt()
108+
{
109+
RTC_callBack = NULL;
110+
}
111+
96112
/*
97113
* Get Functions
98114
*/

src/RTCZero.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "Arduino.h"
2626

27+
typedef void(*voidFuncPtr)(void);
28+
2729
class RTCZero {
2830
public:
2931

@@ -43,6 +45,9 @@ class RTCZero {
4345

4446
void enableAlarm(Alarm_Match match);
4547
void disableAlarm();
48+
49+
void attachInterrupt(voidFuncPtr callback);
50+
void detachInterrupt();
4651

4752
/* Get Functions */
4853

0 commit comments

Comments
 (0)