FreeRTOS: Add ISR check to critical section (#2559)

This commit is contained in:
ldursw 2024-10-26 17:08:21 -03:00 committed by GitHub
parent d96c0e6818
commit 9c217b13df
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,6 +45,7 @@
// Interfaces for the main core to use FreeRTOS mutexes
extern "C" {
extern volatile bool __otherCoreIdled;
static UBaseType_t __savedIrqs[configNUMBER_OF_CORES];
SemaphoreHandle_t __freertos_mutex_create() {
return xSemaphoreCreateMutex();
@ -93,12 +94,20 @@ extern "C" {
}
void __freertos_task_exit_critical() {
if (portGET_CRITICAL_NESTING_COUNT() == 1U && portCHECK_IF_IN_ISR()) {
taskEXIT_CRITICAL_FROM_ISR(__savedIrqs[portGET_CORE_ID()]);
} else {
taskEXIT_CRITICAL();
}
}
void __freertos_task_enter_critical() {
if (portGET_CRITICAL_NESTING_COUNT() == 0U && portCHECK_IF_IN_ISR()) {
__savedIrqs[portGET_CORE_ID()] = taskENTER_CRITICAL_FROM_ISR();
} else {
taskENTER_CRITICAL();
}
}
}