Skip to content

Make attachInterrupt work as documented #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions VARIANT_COMPLIANCE_CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SAMD CORE 1.6.6

* digitalPinToInterrupt #define moved to Arduino.h, variant.h must no longer define it

SAMD CORE 1.6.3

* Timer for pin PWM selected based on value of PIN_ATTR_TIMER_ALT or PIN_ATTR_TIMER,
prior to this pin type was used
5 changes: 5 additions & 0 deletions cores/arduino/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ void loop( void ) ;

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

#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
// Interrupts
#define digitalPinToInterrupt(P) ( P )
#endif

// USB Device
#include "USB/USBDesc.h"
#include "USB/USBCore.h"
Expand Down
8 changes: 8 additions & 0 deletions cores/arduino/WInterrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
uint32_t config;
uint32_t pos;

#if ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
#else
EExt_Interrupts in = digitalPinToInterrupt(pin);
#endif
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
return;

Expand Down Expand Up @@ -116,7 +120,11 @@ void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode)
*/
void detachInterrupt(uint32_t pin)
{
#if (ARDUINO_SAMD_VARIANT_COMPLIANCE >= 10606)
EExt_Interrupts in = g_APinDescription[pin].ulExtInt;
#else
EExt_Interrupts in = digitalPinToInterrupt(pin);
#endif
if (in == NOT_AN_INTERRUPT || in == EXTERNAL_INT_NMI)
return;

Expand Down
7 changes: 2 additions & 5 deletions variants/arduino_zero/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#ifndef _VARIANT_ARDUINO_ZERO_
#define _VARIANT_ARDUINO_ZERO_

// The definitions here needs a SAMD core >=1.6.3
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10603
// The definitions here needs a SAMD core >=1.6.6
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10606

/*----------------------------------------------------------------------------
* Definitions
Expand Down Expand Up @@ -76,9 +76,6 @@ extern "C"
*/
// #define digitalPinToTimer(P)

// Interrupts
#define digitalPinToInterrupt(P) ( g_APinDescription[P].ulExtInt )

// LEDs
#define PIN_LED_13 (13u)
#define PIN_LED_RXL (25u)
Expand Down
5 changes: 2 additions & 3 deletions variants/mkr1000/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#pragma once

// The definitions here needs a SAMD core >=1.6.3
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10603
// The definitions here needs a SAMD core >=1.6.6
#define ARDUINO_SAMD_VARIANT_COMPLIANCE 10606

#include <WVariant.h>

Expand Down Expand Up @@ -51,7 +51,6 @@
#define portInputRegister(port) (&(port->IN.reg))
#define portModeRegister(port) (&(port->DIR.reg))
#define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER)
#define digitalPinToInterrupt(P) (g_APinDescription[P].ulExtInt)

/*
* digitalPinToTimer(..) is AVR-specific and is not defined for SAMD
Expand Down