diff options
| author | hathach <[email protected]> | 2025-05-19 22:51:40 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-05-19 22:51:40 +0700 |
| commit | bb1d348eb3908543f7bc80fc462d91bba62edace (patch) | |
| tree | 73268b6ccd7a7d70ff4498698ce05e9b72516c14 /src/osal/osal_none.h | |
| parent | bffe5d97cc2f4f5a9ba8b4f09d30be97ce70a3de (diff) | |
implement osal critical for none/freertos/pico-sdk
Diffstat (limited to 'src/osal/osal_none.h')
| -rw-r--r-- | src/osal/osal_none.h | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index d9100cfdd..05a121ae6 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -43,18 +43,27 @@ TU_ATTR_WEAK void osal_task_delay(uint32_t msec); //--------------------------------------------------------------------+ // Critical API //--------------------------------------------------------------------+ -typedef uint8_t osal_critical_t; // not used +typedef struct { + void (* interrupt_set)(bool); +} osal_critical_t; + +#define OSAL_CRITIAL_DEF(_name, _int_set) \ + osal_critical_t _name = { .interrupt_set = _int_set } TU_ATTR_ALWAYS_INLINE static inline void osal_critical_init(osal_critical_t *ctx) { (void) ctx; } -TU_ATTR_ALWAYS_INLINE static inline void osal_critical_enter(osal_critical_t *ctx) { - (void) ctx; +TU_ATTR_ALWAYS_INLINE static inline void osal_critical_enter(osal_critical_t *ctx, bool in_isr) { + if (!in_isr) { + ctx->interrupt_set(false); + } } -TU_ATTR_ALWAYS_INLINE static inline void osal_critical_exit(osal_critical_t *ctx) { - (void) ctx; +TU_ATTR_ALWAYS_INLINE static inline void osal_critical_exit(osal_critical_t *ctx, bool in_isr) { + if (!in_isr) { + ctx->interrupt_set(true); + } } //--------------------------------------------------------------------+ |
