Skip to content

Commit ec449b1

Browse files
committed
use FreeRTOS macros in noInterrupts/interrupts when applicable.
1 parent 6b41bfb commit ec449b1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cores/rp2040/wiring_private.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#include <hardware/sync.h>
2525
#include <map>
2626

27+
// FreeRTOS potential includes
28+
extern void taskEXIT_CRITICAL() __attribute__((weak));
29+
extern void taskENTER_CRITICAL() __attribute__((weak));
30+
2731
// Support nested IRQ disable/re-enable
2832
#ifndef maxIRQs
2933
#define maxIRQs 15
@@ -32,22 +36,30 @@ static uint32_t _irqStackTop[2] = { 0, 0 };
3236
static uint32_t _irqStack[2][maxIRQs];
3337

3438
extern "C" void interrupts() {
39+
if (__freeRTOSinitted){
40+
taskEXIT_CRITICAL();
41+
} else {
3542
auto core = get_core_num();
3643
if (!_irqStackTop[core]) {
3744
// ERROR
3845
return;
3946
}
4047
restore_interrupts(_irqStack[core][--_irqStackTop[core]]);
48+
}
4149
}
4250

4351
extern "C" void noInterrupts() {
52+
if (__freeRTOSinitted) {
53+
taskENTER_CRITICAL();
54+
} else {
4455
auto core = get_core_num();
4556
if (_irqStackTop[core] == maxIRQs) {
4657
// ERROR
4758
panic("IRQ stack overflow");
4859
}
4960

5061
_irqStack[core][_irqStackTop[core]++] = save_and_disable_interrupts();
62+
}
5163
}
5264

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

0 commit comments

Comments
 (0)