1
0
mirror of https://github.com/arduino-libraries/ArduinoLowPower.git synced 2025-10-16 02:46:40 +03:00

Added nRF52 compatibility

Waking from deepSleep() is comparable to an hard reset; the sketch won't restart from the sleep invocation but the wakeuup source can be retrieved with wakeupReason()
This commit is contained in:
chiararuggeri
2017-04-19 11:12:15 +02:00
committed by Martino Facchin
parent fcbf16f6a3
commit 21d2f7527f
6 changed files with 303 additions and 4 deletions

View File

@@ -11,7 +11,7 @@
#include "RTCZero.h"
#endif
#if defined(ARDUINO_SAMD_TIAN)
#if defined(ARDUINO_SAMD_TIAN) || defined(ARDUINO_NRF52_PRIMO)
// add here any board with companion chip which can be woken up
#define BOARD_HAS_COMPANION_CHIP
#endif
@@ -21,6 +21,14 @@
//typedef void (*voidFuncPtr)( void ) ;
typedef void (*onOffFuncPtr)( bool ) ;
typedef enum{
OTHER_WAKEUP = 0,
GPIO_WAKEUP = 1,
NFC_WAKEUP = 2,
ANALOG_COMPARATOR_WAKEUP = 3
} wakeup_reason;
class ArduinoLowPowerClass {
public:
void idle(void);
@@ -55,9 +63,16 @@ class ArduinoLowPowerClass {
}
#endif
#ifdef ARDUINO_ARCH_NRF52
void enableWakeupFrom(wakeup_reason peripheral, uint32_t pin = 0xFF, uint32_t event = 0xFF, uint32_t option = 0xFF);
wakeup_reason wakeupReason();
#endif
private:
void setAlarmIn(uint32_t millis);
#ifdef ARDUINO_ARCH_SAMD
RTCZero rtc;
#endif
#ifdef BOARD_HAS_COMPANION_CHIP
void (*companionSleepCB)(bool);
#endif