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

Make the library compatible with both API and non API cores (#35)

Fixes https://github.com/arduino/ArduinoCore-samd/issues/578
This commit is contained in:
Martino Facchin 2020-12-17 10:54:44 +01:00 committed by GitHub
parent 043dedba33
commit b44168f223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -18,6 +18,12 @@
#define RTC_ALARM_WAKEUP 0xFF
#ifdef ARDUINO_API_VERSION
using irq_mode = PinStatus;
#else
using irq_mode = uint32_t;
#endif
//typedef void (*voidFuncPtr)( void ) ;
typedef void (*onOffFuncPtr)( bool ) ;
@ -59,7 +65,7 @@ class ArduinoLowPowerClass {
deepSleep((uint32_t)millis);
}
void attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode);
void attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, irq_mode mode);
#ifdef BOARD_HAS_COMPANION_CHIP
void companionLowPowerCallback(onOffFuncPtr callback) {

View File

@ -1,7 +1,6 @@
#if defined(ARDUINO_ARCH_SAMD)
#include "ArduinoLowPower.h"
#include "WInterrupts.h"
static void configGCLK6()
{
@ -72,7 +71,7 @@ void ArduinoLowPowerClass::deepSleep(uint32_t millis) {
void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
if (!rtc.isConfigured()) {
attachInterruptWakeup(RTC_ALARM_WAKEUP, NULL, 0);
attachInterruptWakeup(RTC_ALARM_WAKEUP, NULL, (irq_mode)0);
}
uint32_t now = rtc.getEpoch();
@ -80,7 +79,7 @@ void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS);
}
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, irq_mode mode) {
if (pin > PINS_COUNT) {
// check for external wakeup sources