Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 15 additions & 3 deletions cores/arduino/WInterrupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string.h>

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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -173,6 +184,7 @@ void detachInterrupt(pin_size_t pin)
for (; current<nints-1; current++) {
ISRlist[current] = ISRlist[current+1];
ISRcallback[current] = ISRcallback[current+1];
ISRcallbackParams[current] = ISRcallbackParams[current+1];
}
nints--;
}
Expand All @@ -191,7 +203,7 @@ void EIC_Handler(void)
if ((EIC->INTFLAG.reg & ISRlist[i]) != 0)
{
// Call the callback function
ISRcallback[i]();
ISRcallback[i](ISRcallbackParams[i]);
// Clear the interrupt
EIC->INTFLAG.reg = ISRlist[i];
}
Expand Down
Loading