diff options
| author | sakumisu <[email protected]> | 2025-06-03 17:31:31 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-06-03 22:43:35 +0800 |
| commit | bff8a632a926cf976c3bbb18097f8a70d7cd9b93 (patch) | |
| tree | d2219f3e1674f78b8cc69bae6aa18df06cac8be5 /osal/usb_osal_rtthread.c | |
| parent | a8bf2687bde6ff5eb8e5b501226cb21945a7f8df (diff) | |
feat(class): add usb_osal_thread_schedule_other to allow the applications which use the struct usbh_xxx to exit properly before free struct usbh_xxx
Signed-off-by: sakumisu <[email protected]>
Diffstat (limited to 'osal/usb_osal_rtthread.c')
| -rw-r--r-- | osal/usb_osal_rtthread.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/osal/usb_osal_rtthread.c b/osal/usb_osal_rtthread.c index dd1075a5..14448fc4 100644 --- a/osal/usb_osal_rtthread.c +++ b/osal/usb_osal_rtthread.c @@ -34,6 +34,23 @@ void usb_osal_thread_delete(usb_osal_thread_t thread) rt_thread_delete(thread); } +void usb_osal_thread_schedule_other(void) +{ + rt_thread_t self = rt_thread_self(); + rt_uint8_t priority; +#if (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0)) + const rt_uint8_t old_priority = RT_SCHED_PRIV(self).current_priority; +#else + const rt_uint8_t old_priority = self->current_priority; +#endif + priority = RT_THREAD_PRIORITY_MAX - 1; + rt_thread_control(self, RT_THREAD_CTRL_CHANGE_PRIORITY, (void *)&priority); + + rt_thread_yield(); + + rt_thread_control(self, RT_THREAD_CTRL_CHANGE_PRIORITY, (void *)&old_priority); +} + usb_osal_sem_t usb_osal_sem_create(uint32_t initial_count) { usb_osal_sem_t sem = (usb_osal_sem_t)rt_sem_create("usbh_sem", initial_count, RT_IPC_FLAG_FIFO); |
