summaryrefslogtreecommitdiff
path: root/components/drivers/include
diff options
context:
space:
mode:
authorShell <[email protected]>2024-08-15 21:30:58 +0800
committerRbb666 <[email protected]>2024-08-19 10:39:15 +0800
commitc451dce8203fb2616d6ec4634db1f4a7b766680c (patch)
tree61f814df3b2e19cd7a5560253e73cd75159dd60d /components/drivers/include
parentd87f30cf21c74b380ec394fd896c1dcea5a2968b (diff)
feat: add ISR safe completion API
Since the completion is used to sync with ISR mostly, we should set the default semantic to ISR-safe. So most user will be happy and don't see any weird behavior in their codes. Changes: - Added `rt_completion_wait_noisr` and `rt_completion_wait_flags_noisr` functions in `completion.h`, `completion_comm.c`, `completion_mp.c`, and `completion_up.c`. - The new APIs allow waiting for completions in non-ISR contexts while ensuring thread context safety. - Existing documentation and comments were updated to clarify usage contexts and emphasize restrictions on ISR usage. Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'components/drivers/include')
-rw-r--r--components/drivers/include/ipc/completion.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/drivers/include/ipc/completion.h b/components/drivers/include/ipc/completion.h
index 30f4acf81c..bc075c410c 100644
--- a/components/drivers/include/ipc/completion.h
+++ b/components/drivers/include/ipc/completion.h
@@ -14,9 +14,9 @@
#include <rtconfig.h>
/**
- * Completion - A tiny & rapid IPC primitive for resource-constrained scenarios
+ * RT-Completion - A Tiny(resource-constrained) & Rapid(lockless) IPC Primitive
*
- * It's an IPC using one CPU word with the encoding:
+ * It's an IPC using one pointer word with the encoding:
*
* BIT | MAX-1 ----------------- 1 | 0 |
* CONTENT | suspended_thread & ~1 | completed flag |
@@ -33,8 +33,12 @@ struct rt_completion
void rt_completion_init(struct rt_completion *completion);
rt_err_t rt_completion_wait(struct rt_completion *completion,
rt_int32_t timeout);
+rt_err_t rt_completion_wait_noisr(struct rt_completion *completion,
+ rt_int32_t timeout);
rt_err_t rt_completion_wait_flags(struct rt_completion *completion,
rt_int32_t timeout, int suspend_flag);
+rt_err_t rt_completion_wait_flags_noisr(struct rt_completion *completion,
+ rt_int32_t timeout, int suspend_flag);
void rt_completion_done(struct rt_completion *completion);
rt_err_t rt_completion_wakeup(struct rt_completion *completion);
rt_err_t rt_completion_wakeup_by_errno(struct rt_completion *completion, rt_err_t error);