Skip to content
Merged
Changes from 4 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
33 changes: 22 additions & 11 deletions cores/rp2040/wiring_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <hardware/sync.h>
#include <map>

// FreeRTOS potential includes
extern void taskEXIT_CRITICAL() __attribute__((weak));
extern void taskENTER_CRITICAL() __attribute__((weak));

// Support nested IRQ disable/re-enable
#ifndef maxIRQs
#define maxIRQs 15
Expand All @@ -32,22 +36,29 @@ static uint32_t _irqStackTop[2] = { 0, 0 };
static uint32_t _irqStack[2][maxIRQs];

extern "C" void interrupts() {
auto core = get_core_num();
if (!_irqStackTop[core]) {
// ERROR
return;
if (__freeRTOSinitted) {
taskEXIT_CRITICAL();
} else {
auto core = get_core_num();
if (!_irqStackTop[core]) {
// ERROR
return;
}
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
}
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
}

extern "C" void noInterrupts() {
auto core = get_core_num();
if (_irqStackTop[core] == maxIRQs) {
// ERROR
panic("IRQ stack overflow");
if (__freeRTOSinitted) {
taskENTER_CRITICAL();
} else {
auto core = get_core_num();
if (_irqStackTop[core] == maxIRQs) {
// ERROR
panic("IRQ stack overflow");
}
_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
}

_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
}

// Only 1 GPIO IRQ callback for all pins, so we need to look at the pin it's for and
Expand Down