28#ifndef TUSB_OSAL_RTTHREAD_H_
29#define TUSB_OSAL_RTTHREAD_H_
42 rt_thread_mdelay(msec);
51TU_ATTR_ALWAYS_INLINE
static inline
53 rt_sem_init(semdef,
"tusb", 0, RT_IPC_FLAG_PRIO);
58 return RT_EOK == rt_sem_detach(semd_hdl);
63 return rt_sem_release(sem_hdl) == RT_EOK;
67 return rt_sem_take(sem_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK;
71 rt_sem_control(sem_hdl, RT_IPC_CMD_RESET, 0);
81 rt_mutex_init(mdef,
"tusb", RT_IPC_FLAG_PRIO);
86 return RT_EOK == rt_mutex_detach(mutex_hdl);
90 return rt_mutex_take(mutex_hdl, rt_tick_from_millisecond((rt_int32_t) msec)) == RT_EOK;
94 return rt_mutex_release(mutex_hdl) == RT_EOK;
102#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
103 static _type _name##_##buf[_depth]; \
104 osal_queue_def_t _name = { .depth = _depth, .item_sz = sizeof(_type), .buf = _name##_##buf };
111 struct rt_messagequeue sq;
117 rt_mq_init(&(qdef->
sq),
"tusb", qdef->
buf, qdef->
item_sz,
123 return RT_EOK == rt_mq_detach(qhdl);
127 rt_tick_t tick = rt_tick_from_millisecond((rt_int32_t) msec);
128#if RT_VERSION_MAJOR >= 5
129 return rt_mq_recv(qhdl,
data, qhdl->msg_size, tick) > 0;
131 return rt_mq_recv(qhdl,
data, qhdl->msg_size, tick) == RT_EOK;
137 return rt_mq_send(qhdl, (
void *)
data, qhdl->msg_size) == RT_EOK;
141 return (qhdl->entry) == 0;
StaticSemaphore_t osal_mutex_def_t
QueueHandle_t osal_queue_t
SemaphoreHandle_t osal_semaphore_t
SemaphoreHandle_t osal_mutex_t
static TU_ATTR_ALWAYS_INLINE bool osal_queue_empty(osal_queue_t qhdl)
static TU_ATTR_ALWAYS_INLINE bool osal_semaphore_delete(osal_semaphore_t semd_hdl)
static TU_ATTR_ALWAYS_INLINE bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec)
static TU_ATTR_ALWAYS_INLINE osal_queue_t osal_queue_create(osal_queue_def_t *qdef)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec)
static TU_ATTR_ALWAYS_INLINE void osal_task_delay(uint32_t msec)
static TU_ATTR_ALWAYS_INLINE bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_delete(osal_mutex_t mutex_hdl)
rt_sem_t osal_semaphore_t
static TU_ATTR_ALWAYS_INLINE bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr)
static TU_ATTR_ALWAYS_INLINE bool osal_queue_receive(osal_queue_t qhdl, void *data, uint32_t msec)
static TU_ATTR_ALWAYS_INLINE bool osal_queue_delete(osal_queue_t qhdl)
static TU_ATTR_ALWAYS_INLINE void osal_semaphore_reset(osal_semaphore_t const sem_hdl)
static TU_ATTR_ALWAYS_INLINE osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t *semdef)
static TU_ATTR_ALWAYS_INLINE osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef)