diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 9b542a297..35c9b8cce 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -21,9 +21,10 @@ #include -static voidFuncPtr ISRcallback[EXTERNAL_NUM_INTERRUPTS]; -static uint32_t ISRlist[EXTERNAL_NUM_INTERRUPTS]; -static uint32_t nints; // Stores total number of attached interrupts +static voidFuncPtrParam ISRcallback[EXTERNAL_NUM_INTERRUPTS]; +static void* ISRcallbackParams[EXTERNAL_NUM_INTERRUPTS]; +static uint32_t ISRlist[EXTERNAL_NUM_INTERRUPTS]; +static uint32_t nints; // Stores total number of attached interrupts /* Configure I/O interrupt sources */ static void __initialize() @@ -55,7 +56,7 @@ static void __initialize() * \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. * Replaces any previous function that was attached to the interrupt. */ -void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode) +void attachInterruptParam(pin_size_t pin, voidFuncPtrParam callback, PinStatus mode, void* params) { static int enabled = 0; uint32_t config; @@ -100,8 +101,9 @@ void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode) // Need to make a new entry nints++; } - ISRlist[current] = inMask; // List of interrupt in order of when they were attached - ISRcallback[current] = callback; // List of callback adresses + ISRlist[current] = inMask; // List of interrupt in order of when they were attached + ISRcallback[current] = callback; // List of callback adresses + ISRcallbackParams[current] = params; // List of arguments to send to the callbacks // Look for right CONFIG register to be addressed if (in > EXTERNAL_INT_7) { @@ -141,6 +143,15 @@ void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode) EIC->INTENSET.reg = EIC_INTENSET_EXTINT(inMask); } +/* + * \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. + * Replaces any previous function that was attached to the interrupt. + */ +void attachInterrupt(uint8_t pin, voidFuncPtr callback, PinStatus mode) +{ + attachInterruptParam(pin, (voidFuncPtrParam)callback, mode, NULL); +} + /* * \brief Turns off the given interrupt. */ @@ -171,8 +182,9 @@ void detachInterrupt(pin_size_t pin) // Shift the reminder down for (; currentINTFLAG.reg & ISRlist[i]) != 0) { // Call the callback function - ISRcallback[i](); + ISRcallback[i](ISRcallbackParams[i]); // Clear the interrupt EIC->INTFLAG.reg = ISRlist[i]; }