28#ifndef TUSB_OSAL_RTX4_H_
29#define TUSB_OSAL_RTX4_H_
41 uint16_t hi = msec >> 16;
49TU_ATTR_ALWAYS_INLINE
static inline uint16_t
msec2wait(uint32_t msec) {
50 if (msec == OSAL_TIMEOUT_WAIT_FOREVER) {
52 }
else if (msec >= 0xFFFE) {
66 os_sem_init(semdef, 0);
79 isr_sem_send(sem_hdl);
85 return os_sem_wait(sem_hdl,
msec2wait(msec)) != OS_R_TMO;
109 return os_mut_wait(mutex_hdl,
msec2wait(msec)) != OS_R_TMO;
113 return os_mut_release(mutex_hdl) == OS_R_OK;
121#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
122 os_mbx_declare(_name##__mbox, _depth); \
123 _declare_box(_name##__pool, sizeof(_type), _depth); \
124 osal_queue_def_t _name = { .depth = _depth, .item_sz = sizeof(_type), .pool = _name##__pool, .mbox = _name##__mbox };
136 os_mbx_init(qdef->
mbox, (qdef->
depth + 4) * 4);
143 os_mbx_wait(qhdl->mbox, &buf,
msec2wait(msec));
145 _free_box(qhdl->pool, buf);
155 void* buf = _alloc_box(qhdl->pool);
158 os_mbx_send(qhdl->mbox, buf, 0xFFFF);
160 isr_mbx_send(qhdl->mbox, buf);
166 return os_mbx_check(qhdl->mbox) == qhdl->depth;
StaticSemaphore_t osal_mutex_def_t
QueueHandle_t osal_queue_t
SemaphoreHandle_t osal_semaphore_t
SemaphoreHandle_t osal_mutex_t
OS_SEM osal_semaphore_def_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 uint16_t msec2wait(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 OS_ID osal_semaphore_create(osal_semaphore_def_t *semdef)
osal_queue_def_t * osal_queue_t
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)
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_mutex_t osal_mutex_create(osal_mutex_def_t *mdef)
static void * memcpy(void *dst, const void *src, size_t n)