Skip to content

Commit b44168f

Browse files
authored
Make the library compatible with both API and non API cores (#35)
Fixes arduino/ArduinoCore-samd#578
1 parent 043dedb commit b44168f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/ArduinoLowPower.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
#define RTC_ALARM_WAKEUP 0xFF
2020

21+
#ifdef ARDUINO_API_VERSION
22+
using irq_mode = PinStatus;
23+
#else
24+
using irq_mode = uint32_t;
25+
#endif
26+
2127
//typedef void (*voidFuncPtr)( void ) ;
2228
typedef void (*onOffFuncPtr)( bool ) ;
2329

@@ -59,7 +65,7 @@ class ArduinoLowPowerClass {
5965
deepSleep((uint32_t)millis);
6066
}
6167

62-
void attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode);
68+
void attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, irq_mode mode);
6369

6470
#ifdef BOARD_HAS_COMPANION_CHIP
6571
void companionLowPowerCallback(onOffFuncPtr callback) {

src/samd/ArduinoLowPower.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if defined(ARDUINO_ARCH_SAMD)
22

33
#include "ArduinoLowPower.h"
4-
#include "WInterrupts.h"
54

65
static void configGCLK6()
76
{
@@ -72,15 +71,15 @@ void ArduinoLowPowerClass::deepSleep(uint32_t millis) {
7271
void ArduinoLowPowerClass::setAlarmIn(uint32_t millis) {
7372

7473
if (!rtc.isConfigured()) {
75-
attachInterruptWakeup(RTC_ALARM_WAKEUP, NULL, 0);
74+
attachInterruptWakeup(RTC_ALARM_WAKEUP, NULL, (irq_mode)0);
7675
}
7776

7877
uint32_t now = rtc.getEpoch();
7978
rtc.setAlarmEpoch(now + millis/1000);
8079
rtc.enableAlarm(rtc.MATCH_YYMMDDHHMMSS);
8180
}
8281

83-
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, uint32_t mode) {
82+
void ArduinoLowPowerClass::attachInterruptWakeup(uint32_t pin, voidFuncPtr callback, irq_mode mode) {
8483

8584
if (pin > PINS_COUNT) {
8685
// check for external wakeup sources

0 commit comments

Comments
 (0)