39TU_ATTR_ALWAYS_INLINE
static inline void osal_task_delay(uint32_t msec) {
40 os_time_delay( os_time_ms_to_ticks32(msec) );
60 return os_sem_release(sem_hdl) == OS_OK;
64 uint32_t
const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec);
65 return os_sem_pend(sem_hdl, ticks) == OS_OK;
79 return (os_mutex_init(mdef) == OS_OK) ? (
osal_mutex_t) mdef : NULL;
88 uint32_t
const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? OS_TIMEOUT_NEVER : os_time_ms_to_ticks32(msec);
89 return os_mutex_pend(mutex_hdl, ticks) == OS_OK;
93 return os_mutex_release(mutex_hdl) == OS_OK;
101#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
102 static _type _name##_##buf[_depth];\
103 static struct os_event _name##_##evbuf[_depth];\
104 osal_queue_def_t _name = { .depth = _depth, .item_sz = sizeof(_type), .buf = _name##_##buf, .evbuf = _name##_##evbuf};\
112 struct os_mempool mpool;
113 struct os_mempool epool;
115 struct os_eventq evq;
121 if ( OS_OK != os_mempool_init(&qdef->
mpool, qdef->
depth, qdef->
item_sz, qdef->
buf,
"usb queue") )
return NULL;
122 if ( OS_OK != os_mempool_init(&qdef->
epool, qdef->
depth,
sizeof(
struct os_event), qdef->
evbuf,
"usb evqueue") )
return NULL;
124 os_eventq_init(&qdef->
evq);
137 ev = os_eventq_get(&qhdl->evq);
140 os_memblock_put(&qhdl->mpool, ev->ev_arg);
141 os_memblock_put(&qhdl->epool, ev);
150 void* ptr = os_memblock_get(&qhdl->mpool);
151 if (!ptr)
return false;
155 struct os_event* ev = (
struct os_event*) os_memblock_get(&qhdl->epool);
157 os_memblock_put(&qhdl->mpool, ptr);
160 tu_memclr(ev,
sizeof(
struct os_event));
163 os_eventq_put(&qhdl->evq, ev);
169 return STAILQ_EMPTY(&qhdl->evq.evq_list);
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 void osal_semaphore_reset(osal_semaphore_t sem_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)
struct os_sem * osal_semaphore_t
static TU_ATTR_ALWAYS_INLINE bool osal_mutex_lock(osal_mutex_t mutex_hdl, uint32_t msec)
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 osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t *semdef)
struct os_mutex * osal_mutex_t
static bool osal_queue_send(osal_queue_t qhdl, void const *data, bool in_isr)
static TU_ATTR_ALWAYS_INLINE osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef)
TU_ATTR_WEAK void osal_task_delay(uint32_t msec)
static void * memcpy(void *dst, const void *src, size_t n)