Skip to content
Merged
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
3 changes: 3 additions & 0 deletions cores/rp2040/_freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ extern "C" {

extern void __freertos_idle_other_core() __attribute__((weak));
extern void __freertos_resume_other_core() __attribute__((weak));

extern void __freertos_task_exit_critical() __attribute__((weak));
extern void __freertos_task_enter_critical() __attribute__((weak));
}
extern SemaphoreHandle_t __get_freertos_mutex_for_ptr(mutex_t *m, bool recursive = false);
31 changes: 20 additions & 11 deletions cores/rp2040/wiring_private.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <hardware/gpio.h>
#include <hardware/sync.h>
#include <map>
#include "_freertos.h"


// Support nested IRQ disable/re-enable
#ifndef maxIRQs
Expand All @@ -32,22 +34,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) {
__freertos_task_exit_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) {
__freertos_task_enter_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
8 changes: 8 additions & 0 deletions libraries/FreeRTOS/src/variantHooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ extern "C" {
bool __freertos_check_if_in_isr() {
return portCHECK_IF_IN_ISR();
}

void __freertos_task_exit_critical() {
taskEXIT_CRITICAL();
}

void __freertos_task_enter_critical() {
taskENTER_CRITICAL();
}
}


Expand Down
Loading