Skip to content

Commit 60dedcc

Browse files
committed
[SAMD] fix RTC wakeup and FALLING/RISING on pin
1 parent e159ecf commit 60dedcc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/ArduinoLowPower.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
4343

4444
uint32_t now = rtc.getEpoch();
4545
rtc.setAlarmEpoch(now + millis/1000);
46-
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS);
46+
rtc.enableAlarm(rtc.MATCH_HHMMSS);
4747
}
4848

4949
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
5050

5151
if (pin > PINS_COUNT) {
5252
// check for external wakeup sources
53-
// only enables the wakeup bit, no callback
5453
// RTC library should call this API to enable the alarm subsystem
5554
switch (pin) {
5655
case RTC_ALARM_WAKEUP:
@@ -65,9 +64,9 @@ void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callb
6564
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
6665
return;
6766

67+
pinMode(pin, INPUT_PULLUP);
6868
attachInterrupt(pin, callback, mode);
6969

70-
#if 0
7170
// enable EIC clock
7271
GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module
7372
while (GCLK->STATUS.bit.SYNCBUSY);
@@ -80,13 +79,13 @@ void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callb
8079

8180
GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby
8281
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
83-
#endif
8482

8583
// Enable wakeup capability on pin in case being used during sleep
8684
EIC->WAKEUP.reg |= (1 << in);
8785

8886
/* Errata: Make sure that the Flash does not power all the way down
8987
* when in sleep mode. */
88+
9089
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
9190
}
9291

src/ArduinoLowPower.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include <Arduino.h>
55

6+
#ifdef ARDUINO_ARCH_AVR
7+
#error The library is not compatible with AVR boards
8+
#endif
9+
610
#ifdef ARDUINO_ARCH_SAMD
711
#include "RTCZero.h"
812
#endif

0 commit comments

Comments
 (0)