Skip to content

Commit eba209e

Browse files
committed
Move digitalPinToInterrupt definition to Arduino.h if variant compliance it 1.6.5 or higher
1 parent 29f5960 commit eba209e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

cores/arduino/Arduino.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ void loop( void ) ;
114114

115115
#define bit(b) (1UL << (b))
116116

117+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10605)
118+
// Interrupts
119+
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )
120+
#endif
121+
117122
// USB Device
118123
#include "USB/USBDesc.h"
119124
#include "USB/USBCore.h"

cores/arduino/WInterrupts.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
5757
uint32_t config;
5858
uint32_t pos;
5959

60+
#if ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10605
6061
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
62+
#else
63+
EExt_Interrupts in = digitalPinToInterrupt(pin);
64+
#endif
6165
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
6266
return;
6367

@@ -116,7 +120,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
116120
*/
117121
void detachInterrupt(uint32_t pin)
118122
{
123+
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10605)
119124
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
125+
#else
126+
EExt_Interrupts in = digitalPinToInterrupt(pin);
127+
#endif
120128
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
121129
return;
122130

variants/arduino_zero/variant.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
#ifndef _VARIANT_ARDUINO_ZERO_
2020
#define _VARIANT_ARDUINO_ZERO_
2121

22-
// The definitions here needs a SAMD core >=1.6.3
23-
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10603
22+
// The definitions here needs a SAMD core >=1.6.5
23+
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10605
2424

2525
/*----------------------------------------------------------------------------
2626
* Definitions
@@ -75,9 +75,6 @@ extern "C"
7575
*/
7676
// #define digitalPinToTimer(P)
7777

78-
// Interrupts
79-
#define digitalPinToInterrupt(P) ( P )
80-
8178
// LEDs
8279
#define PIN_LED_13 (13u)
8380
#define PIN_LED_RXL (25u)

0 commit comments

Comments
 (0)