Browse files

{attach,detach}Interrupt() on Due selects directly pin number instead…

… of interrupt number.
  • Loading branch information...
1 parent 7b94626 commit 0f23634230617dbce6dd4c670d6a88b9a02dee05 @cmaglie cmaglie committed Nov 2, 2012
View
14 hardware/arduino/sam/cores/arduino/WInterrupts.c
@@ -20,8 +20,6 @@
typedef void (*interruptCB)(void);
-static int pinMapping[EXTERNAL_NUM_INTERRUPTS] = { 2, 3, 4, 5, 6, 7, 8 };
-
static interruptCB callbacksPioA[32];
static interruptCB callbacksPioB[32];
static interruptCB callbacksPioC[32];
@@ -55,19 +53,15 @@ static void __initialize() {
}
-void attachInterrupt(uint32_t interruptNum, void (*callback)(void), uint32_t mode)
+void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
{
- if (interruptNum >= EXTERNAL_NUM_INTERRUPTS)
- return;
-
static int enabled = 0;
if (!enabled) {
__initialize();
enabled = 1;
}
// Retrieve pin information
- uint32_t pin = pinMapping[interruptNum];
Pio *pio = g_APinDescription[pin].pPort;
uint32_t mask = g_APinDescription[pin].ulPin;
uint32_t pos = 0;
@@ -115,13 +109,9 @@ void attachInterrupt(uint32_t interruptNum, void (*callback)(void), uint32_t mod
pio->PIO_IER = mask;
}
-void detachInterrupt( uint32_t interruptNum )
+void detachInterrupt(uint32_t pin)
{
- if (interruptNum >= EXTERNAL_NUM_INTERRUPTS)
- return;
-
// Retrieve pin information
- uint32_t pin = pinMapping[interruptNum];
Pio *pio = g_APinDescription[pin].pPort;
uint32_t mask = g_APinDescription[pin].ulPin;
View
4 hardware/arduino/sam/cores/arduino/WInterrupts.h
@@ -25,9 +25,9 @@
extern "C" {
#endif
-void attachInterrupt(uint32_t interruptNum, void (*callback)(void), uint32_t mode);
+void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode);
-void detachInterrupt(uint32_t interruptNum);
+void detachInterrupt(uint32_t pin);
#ifdef __cplusplus
}

0 comments on commit 0f23634

Please sign in to comment.