2023-06-06 19:00:43 +00:00
|
|
|
#include "common_defines.h"
|
|
|
|
|
2023-11-01 07:24:11 +00:00
|
|
|
#include <FreeRTOS.h>
|
|
|
|
#include <task.h>
|
|
|
|
|
2023-06-06 19:00:43 +00:00
|
|
|
__FuriCriticalInfo __furi_critical_enter(void) {
|
|
|
|
__FuriCriticalInfo info;
|
|
|
|
|
|
|
|
info.isrm = 0;
|
|
|
|
info.from_isr = FURI_IS_ISR();
|
|
|
|
info.kernel_running = (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING);
|
|
|
|
|
|
|
|
if(info.from_isr) {
|
|
|
|
info.isrm = taskENTER_CRITICAL_FROM_ISR();
|
|
|
|
} else if(info.kernel_running) {
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
} else {
|
|
|
|
__disable_irq();
|
|
|
|
}
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __furi_critical_exit(__FuriCriticalInfo info) {
|
|
|
|
if(info.from_isr) {
|
|
|
|
taskEXIT_CRITICAL_FROM_ISR(info.isrm);
|
|
|
|
} else if(info.kernel_running) {
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
} else {
|
|
|
|
__enable_irq();
|
|
|
|
}
|
2024-07-15 04:38:49 +00:00
|
|
|
}
|