summaryrefslogtreecommitdiff
path: root/src/osal/osal_zephyr.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-05-20 16:18:00 +0700
committerhathach <[email protected]>2025-05-20 17:01:31 +0700
commita4875fefead1a2b27f13a588dea44eaca737f553 (patch)
treec849560774bf10fd28f6ba67911d0ba09f1b1571 /src/osal/osal_zephyr.h
parentbb1d348eb3908543f7bc80fc462d91bba62edace (diff)
rename osal_critcal to osal_spinlock
add spinlock implementation for most rtos
Diffstat (limited to 'src/osal/osal_zephyr.h')
-rw-r--r--src/osal/osal_zephyr.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/osal/osal_zephyr.h b/src/osal/osal_zephyr.h
index 8ecb13c6d..7a43b8ec1 100644
--- a/src/osal/osal_zephyr.h
+++ b/src/osal/osal_zephyr.h
@@ -36,6 +36,31 @@ TU_ATTR_ALWAYS_INLINE static inline void osal_task_delay(uint32_t msec) {
}
//--------------------------------------------------------------------+
+// Spinlock API
+//--------------------------------------------------------------------+
+typedef struct {
+ struct k_spinlock lock;
+ k_spinlock_key_t key;
+} 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) {
+ (void) ctx;
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void osal_spin_lock(osal_spinlock_t *ctx, bool in_isr) {
+ (void) in_isr;
+ ctx->key = k_spin_lock(&ctx->lock);
+}
+
+TU_ATTR_ALWAYS_INLINE static inline void osal_spin_unlock(osal_spinlock_t *ctx, bool in_isr) {
+ (void) in_isr;
+ k_spin_unlock(&ctx->lock, ctx->key);
+}
+
+//--------------------------------------------------------------------+
// Binary Semaphore API
//--------------------------------------------------------------------+
typedef struct k_sem osal_semaphore_def_t, * osal_semaphore_t;