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 <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-06-03 17:31:31 +08:00
parent a8bf2687bd
commit bff8a632a9
25 changed files with 111 additions and 0 deletions

View File

@@ -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);