27#ifndef TUSB_OSAL_PICO_H_
28#define TUSB_OSAL_PICO_H_
32#include "pico/mutex.h"
33#include "pico/critical_section.h"
52 sem_init(semdef, 0, 255);
68 return sem_acquire_timeout_ms(sem_hdl, msec);
72 sem_reset(sem_hdl, 0);
92 return mutex_enter_timeout_ms(mutex_hdl, msec);
96 mutex_exit(mutex_hdl);
107 struct critical_section critsec;
113#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
114 uint8_t _name##_buf[_depth*sizeof(_type)]; \
115 osal_queue_def_t _name = { \
116 .ff = TU_FIFO_INIT(_name##_buf, _depth, _type, false) \
120 critical_section_init(&qdef->
critsec);
127 critical_section_deinit(&qdef->
critsec);
134 critical_section_enter_blocking(&qhdl->critsec);
136 critical_section_exit(&qhdl->critsec);
144 critical_section_enter_blocking(&qhdl->critsec);
146 critical_section_exit(&qhdl->critsec);
StaticSemaphore_t osal_mutex_def_t
QueueHandle_t osal_queue_t
SemaphoreHandle_t osal_semaphore_t
SemaphoreHandle_t osal_mutex_t
struct semaphore * osal_semaphore_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)
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 mutex * osal_mutex_t
static TU_ATTR_ALWAYS_INLINE void osal_semaphore_reset(osal_semaphore_t sem_hdl)
static TU_ATTR_ALWAYS_INLINE osal_mutex_t osal_mutex_create(osal_mutex_def_t *mdef)
struct critical_section critsec
bool tu_fifo_read(tu_fifo_t *f, void *buffer)
Read one element out of the buffer.
bool tu_fifo_empty(tu_fifo_t *f)
Check if FIFO is empty.
bool tu_fifo_write(tu_fifo_t *f, const void *data)
Write one element into the buffer.
bool tu_fifo_clear(tu_fifo_t *f)
Clear the fifo read and write pointers.