From 40f957341a444a16728db5fbced90368ce1542f2 Mon Sep 17 00:00:00 2001 From: Branham Date: Thu, 23 Oct 2025 12:42:10 +0200 Subject: [PATCH] feat(ISR): implement attachInterruptParam --- .github/workflows/compile-examples.yml | 2 +- cores/arduino/WInterrupts.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index b2d769725..c9e604844 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -264,7 +264,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Save memory usage change report as artifact - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v5 with: name: sketches-reports path: sketches-reports diff --git a/cores/arduino/WInterrupts.c b/cores/arduino/WInterrupts.c index 9b542a297..101323af8 100644 --- a/cores/arduino/WInterrupts.c +++ b/cores/arduino/WInterrupts.c @@ -22,6 +22,7 @@ #include static voidFuncPtr 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 @@ -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, voidFuncPtr callback, PinStatus mode, void* params) { static int enabled = 0; uint32_t config; @@ -101,7 +102,8 @@ void attachInterrupt(pin_size_t pin, voidFuncPtr callback, PinStatus mode) nints++; } ISRlist[current] = inMask; // List of interrupt in order of when they were attached - ISRcallback[current] = callback; // List of callback adresses + ISRcallback[current] = callback; // List of callback + 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. */ @@ -173,6 +184,7 @@ void detachInterrupt(pin_size_t pin) for (; currentINTFLAG.reg & ISRlist[i]) != 0) { // Call the callback function - ISRcallback[i](); + ISRcallback[i](ISRcallbackParams[i]); // Clear the interrupt EIC->INTFLAG.reg = ISRlist[i]; }