2021-05-18 13:51:00 +03:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-22 20:06:17 +03:00
|
|
|
#include "core_defines.h"
|
2022-03-29 20:37:23 +03:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-03-30 18:23:40 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2024-03-19 17:43:52 +03:00
|
|
|
#define FURI_NORETURN [[noreturn]]
|
|
|
|
#else
|
|
|
|
#include <stdnoreturn.h>
|
|
|
|
#define FURI_NORETURN noreturn
|
2022-03-30 18:23:40 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <cmsis_compiler.h>
|
|
|
|
|
2022-12-17 01:20:10 +03:00
|
|
|
#ifndef FURI_WARN_UNUSED
|
|
|
|
#define FURI_WARN_UNUSED __attribute__((warn_unused_result))
|
|
|
|
#endif
|
|
|
|
|
2024-02-12 05:04:12 +03:00
|
|
|
#ifndef FURI_DEPRECATED
|
|
|
|
#define FURI_DEPRECATED __attribute__((deprecated))
|
|
|
|
#endif
|
|
|
|
|
2023-05-03 06:58:59 +03:00
|
|
|
#ifndef FURI_WEAK
|
|
|
|
#define FURI_WEAK __attribute__((weak))
|
|
|
|
#endif
|
|
|
|
|
2023-12-01 12:16:48 +03:00
|
|
|
#ifndef FURI_PACKED
|
|
|
|
#define FURI_PACKED __attribute__((packed))
|
|
|
|
#endif
|
|
|
|
|
2024-07-06 13:44:25 +03:00
|
|
|
#ifndef FURI_ALWAYS_INLINE
|
|
|
|
#define FURI_ALWAYS_INLINE __attribute__((always_inline)) inline
|
2024-02-07 12:09:29 +03:00
|
|
|
#endif
|
|
|
|
|
2022-03-29 20:37:23 +03:00
|
|
|
#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
|
2022-04-13 23:50:25 +03:00
|
|
|
#define FURI_IS_ISR() (FURI_IS_IRQ_MODE() || FURI_IS_IRQ_MASKED())
|
2022-03-29 20:37:23 +03:00
|
|
|
#endif
|
|
|
|
|
2023-06-06 22:00:43 +03:00
|
|
|
typedef struct {
|
|
|
|
uint32_t isrm;
|
|
|
|
bool from_isr;
|
|
|
|
bool kernel_running;
|
|
|
|
} __FuriCriticalInfo;
|
|
|
|
|
|
|
|
__FuriCriticalInfo __furi_critical_enter(void);
|
|
|
|
|
|
|
|
void __furi_critical_exit(__FuriCriticalInfo info);
|
|
|
|
|
2021-12-01 01:07:17 +03:00
|
|
|
#ifndef FURI_CRITICAL_ENTER
|
2023-06-06 22:00:43 +03:00
|
|
|
#define FURI_CRITICAL_ENTER() __FuriCriticalInfo __furi_critical_info = __furi_critical_enter();
|
2021-12-01 01:07:17 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FURI_CRITICAL_EXIT
|
2023-06-06 22:00:43 +03:00
|
|
|
#define FURI_CRITICAL_EXIT() __furi_critical_exit(__furi_critical_info);
|
2022-01-03 00:39:56 +03:00
|
|
|
#endif
|
2022-03-30 18:23:40 +03:00
|
|
|
|
2023-12-01 12:16:48 +03:00
|
|
|
#ifndef FURI_CHECK_RETURN
|
|
|
|
#define FURI_CHECK_RETURN __attribute__((__warn_unused_result__))
|
|
|
|
#endif
|
|
|
|
|
2024-06-10 20:04:29 +03:00
|
|
|
#ifndef FURI_NAKED
|
|
|
|
#define FURI_NAKED __attribute__((naked))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FURI_DEFAULT
|
|
|
|
#define FURI_DEFAULT(x) __attribute__((weak, alias(x)))
|
|
|
|
#endif
|
|
|
|
|
2022-03-30 18:23:40 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|