1
0
mirror of https://github.com/arduino-libraries/ArduinoLowPower.git synced 2025-04-19 11:42:14 +03:00

[SAMD] fix RTC wakeup and FALLING/RISING on pin

This commit is contained in:
Martino Facchin 2016-11-03 16:52:43 +01:00
parent e159ecf46f
commit 60dedcc4b0
2 changed files with 7 additions and 4 deletions

View File

@ -43,14 +43,13 @@ void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
uint32_t now = rtc.getEpoch(); uint32_t now = rtc.getEpoch();
rtc.setAlarmEpoch(now + millis/1000); rtc.setAlarmEpoch(now + millis/1000);
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS); rtc.enableAlarm(rtc.MATCH_HHMMSS);
} }
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) { void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
if (pin > PINS_COUNT) { if (pin > PINS_COUNT) {
// check for external wakeup sources // check for external wakeup sources
// only enables the wakeup bit, no callback
// RTC library should call this API to enable the alarm subsystem // RTC library should call this API to enable the alarm subsystem
switch (pin) { switch (pin) {
case RTC_ALARM_WAKEUP: case RTC_ALARM_WAKEUP:
@ -65,9 +64,9 @@ void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callb
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI) if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
return; return;
pinMode(pin, INPUT_PULLUP);
attachInterrupt(pin, callback, mode); attachInterrupt(pin, callback, mode);
#if 0
// enable EIC clock // enable EIC clock
GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module GCLK->CLKCTRL.bit.CLKEN = 0; //disable GCLK module
while (GCLK->STATUS.bit.SYNCBUSY); while (GCLK->STATUS.bit.SYNCBUSY);
@ -80,13 +79,13 @@ void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callb
GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby GCLK->GENCTRL.bit.RUNSTDBY = 1; //GCLK6 run standby
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY); while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY);
#endif
// Enable wakeup capability on pin in case being used during sleep // Enable wakeup capability on pin in case being used during sleep
EIC->WAKEUP.reg |= (1 << in); EIC->WAKEUP.reg |= (1 << in);
/* Errata: Make sure that the Flash does not power all the way down /* Errata: Make sure that the Flash does not power all the way down
* when in sleep mode. */ * when in sleep mode. */
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val; NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
} }

View File

@ -3,6 +3,10 @@
#include <Arduino.h> #include <Arduino.h>
#ifdef ARDUINO_ARCH_AVR
#error The library is not compatible with AVR boards
#endif
#ifdef ARDUINO_ARCH_SAMD #ifdef ARDUINO_ARCH_SAMD
#include "RTCZero.h" #include "RTCZero.h"
#endif #endif