@@ -24,15 +24,15 @@ void LowPower::deepSleep(){
24
24
R_LPM_LowPowerModeEnter (&RenesasLowPowerControlBlock);
25
25
}
26
26
27
- bool LowPower::setWakeUpAlarm (RTCTime alarmTime){
27
+ bool LowPower::setWakeUpAlarm (RTCTime alarmTime, void (* const callbackFunction)(), RTClock * rtc ){
28
28
this ->enableWakeupFromRTC ();
29
29
30
- if (!RTC. isRunning ()){
30
+ if (!rtc-> isRunning ()){
31
31
return false ;
32
32
}
33
33
34
34
RTCTime currentTime;
35
- if (!RTC. getTime (currentTime)) {
35
+ if (!rtc-> getTime (currentTime)) {
36
36
return false ; // Failed to get current time
37
37
}
38
38
@@ -45,18 +45,22 @@ bool LowPower::setWakeUpAlarm(RTCTime alarmTime){
45
45
match.addMatchMonth (); // Trigger the alarm when the months match
46
46
match.addMatchYear (); // Trigger the alarm when the years match
47
47
48
- return RTC.setAlarm (alarmTime, match);
48
+ if (callbackFunction) {
49
+ return rtc->setAlarmCallback (callbackFunction, alarmTime, match);
50
+ } else {
51
+ return rtc->setAlarm (alarmTime, match);
52
+ }
49
53
}
50
54
51
- bool LowPower::setWakeUpAlarm (uint8_t hours, uint8_t minutes, uint8_t seconds){
55
+ bool LowPower::setWakeUpAlarm (uint8_t hours, uint8_t minutes, uint8_t seconds, void (* const callbackFunction)(), RTClock * rtc ){
52
56
53
- if (!RTC. isRunning ()){
57
+ if (!rtc-> isRunning ()){
54
58
return false ;
55
59
}
56
60
57
61
// Get the current time from the RTC
58
62
RTCTime currentTime;
59
- if (!RTC. getTime (currentTime)) {
63
+ if (!rtc-> getTime (currentTime)) {
60
64
return false ; // Failed to get current time
61
65
}
62
66
@@ -67,7 +71,7 @@ bool LowPower::setWakeUpAlarm(uint8_t hours, uint8_t minutes, uint8_t seconds){
67
71
// Convert back to RTCTime
68
72
RTCTime alarmTime (currentTimestamp);
69
73
70
- return this ->setWakeUpAlarm (alarmTime);
74
+ return this ->setWakeUpAlarm (alarmTime, callbackFunction, rtc );
71
75
}
72
76
73
77
void LowPower::enableWakeupFromRTC (){
0 commit comments