[FL-2392] FuriHal: refactor interrupts subsystem (#1066)
* FuriHal: refactor interrupts subsystem * Furi,FuriHal: gather all ISRs under interrupt API, improve crtitical section and cleanup garbage * FuriHal: mirgate ipcc and hsem to LL * Format Sources * FuriHal,BleGlue: move to new critical section * Format Sources * FuriHal: correct flash locking * FuriHal: replace critical section with interrupt disable in OS routine, minor fixex
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include "check.h"
|
||||
#include "furi_hal_task.h"
|
||||
#include "common_defines.h"
|
||||
|
||||
#include <furi_hal_console.h>
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void __furi_print_name() {
|
||||
if(task_is_isr_context()) {
|
||||
if(FURI_IS_ISR()) {
|
||||
furi_hal_console_puts("[ISR] ");
|
||||
} else {
|
||||
const char* name = osThreadGetName(osThreadGetId());
|
||||
|
34
core/furi/common_defines.h
Executable file → Normal file
34
core/furi/common_defines.h
Executable file → Normal file
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) \
|
||||
({ \
|
||||
@@ -75,12 +78,35 @@
|
||||
#define FURI_BIT(x, n) ((x) >> (n)&1)
|
||||
#endif
|
||||
|
||||
#ifndef FURI_IS_IRQ_MASKED
|
||||
#define FURI_IS_IRQ_MASKED() (__get_PRIMASK() != 0U)
|
||||
#endif
|
||||
|
||||
#ifndef FURI_IS_IRQ_MODE
|
||||
#define FURI_IS_IRQ_MODE() (__get_IPSR() != 0U)
|
||||
#endif
|
||||
|
||||
#ifndef FURI_IS_ISR
|
||||
#define FURI_IS_ISR() \
|
||||
(FURI_IS_IRQ_MODE() || (FURI_IS_IRQ_MASKED() && (osKernelGetState() == osKernelRunning)))
|
||||
#endif
|
||||
|
||||
#ifndef FURI_CRITICAL_ENTER
|
||||
#define FURI_CRITICAL_ENTER() \
|
||||
uint32_t primask_bit = __get_PRIMASK(); \
|
||||
__disable_irq()
|
||||
#define FURI_CRITICAL_ENTER() \
|
||||
uint32_t __isrm = 0; \
|
||||
bool __from_isr = FURI_IS_ISR(); \
|
||||
if(__from_isr) { \
|
||||
__isrm = taskENTER_CRITICAL_FROM_ISR(); \
|
||||
} else { \
|
||||
taskENTER_CRITICAL(); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FURI_CRITICAL_EXIT
|
||||
#define FURI_CRITICAL_EXIT() __set_PRIMASK(primask_bit)
|
||||
#define FURI_CRITICAL_EXIT() \
|
||||
if(__from_isr) { \
|
||||
taskEXIT_CRITICAL_FROM_ISR(__isrm); \
|
||||
} else { \
|
||||
taskEXIT_CRITICAL(); \
|
||||
}
|
||||
#endif
|
||||
|
@@ -41,7 +41,6 @@
|
||||
#include <stm32wbxx.h>
|
||||
#include <furi_hal_console.h>
|
||||
#include <furi/common_defines.h>
|
||||
#include <furi_hal_task.h>
|
||||
|
||||
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
|
||||
all the API functions to use the MPU wrappers. That should only be done when
|
||||
|
Reference in New Issue
Block a user