diff options
| author | hathach <[email protected]> | 2025-05-20 16:18:00 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-05-20 17:01:31 +0700 |
| commit | a4875fefead1a2b27f13a588dea44eaca737f553 (patch) | |
| tree | c849560774bf10fd28f6ba67911d0ba09f1b1571 /src/osal/osal_rtthread.h | |
| parent | bb1d348eb3908543f7bc80fc462d91bba62edace (diff) | |
rename osal_critcal to osal_spinlock
add spinlock implementation for most rtos
Diffstat (limited to 'src/osal/osal_rtthread.h')
| -rw-r--r-- | src/osal/osal_rtthread.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/osal/osal_rtthread.h b/src/osal/osal_rtthread.h index c27814835..97f5dc69a 100644 --- a/src/osal/osal_rtthread.h +++ b/src/osal/osal_rtthread.h @@ -43,6 +43,28 @@ TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) { } //--------------------------------------------------------------------+ +// Spinlock API +//--------------------------------------------------------------------+ +typedef struct rt_spinlock osal_spinlock_t; + +#define OSAL_SPINLOCK_DEF(_name, _int_set) \ + osal_spinlock_t _name + +TU_ATTR_ALWAYS_INLINE static inline void osal_spin_init(osal_spinlock_t *ctx) { + rt_spin_lock_init(ctx); +} + +TU_ATTR_ALWAYS_INLINE static inline void osal_spin_lock(osal_spinlock_t *ctx, bool in_isr) { + (void) in_isr; + rt_spin_lock(ctx); +} + +TU_ATTR_ALWAYS_INLINE static inline void osal_spin_unlock(osal_spinlock_t *ctx, bool in_isr) { + (void) in_isr; + rt_spin_unlock(ctx); +} + +//--------------------------------------------------------------------+ // Semaphore API //--------------------------------------------------------------------+ typedef struct rt_semaphore osal_semaphore_def_t; |
