27#ifndef _TUSB_OSAL_PICO_H_
28#define _TUSB_OSAL_PICO_H_
32#include "pico/mutex.h"
33#include "pico/critical_section.h"
42TU_ATTR_ALWAYS_INLINE
static inline void osal_task_delay(uint32_t msec)
52TU_ATTR_ALWAYS_INLINE
static inline osal_semaphore_t osal_semaphore_create(
osal_semaphore_def_t* semdef)
54 sem_init(semdef, 0, 255);
58TU_ATTR_ALWAYS_INLINE
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl,
bool in_isr)
65TU_ATTR_ALWAYS_INLINE
static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec)
67 return sem_acquire_timeout_ms(sem_hdl, msec);
70TU_ATTR_ALWAYS_INLINE
static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
72 sem_reset(sem_hdl, 0);
79typedef struct mutex osal_mutex_def_t, *osal_mutex_t;
81TU_ATTR_ALWAYS_INLINE
static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef)
87TU_ATTR_ALWAYS_INLINE
static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec)
89 return mutex_enter_timeout_ms(mutex_hdl, msec);
92TU_ATTR_ALWAYS_INLINE
static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
94 mutex_exit(mutex_hdl);
101#include "common/tusb_fifo.h"
106 struct critical_section critsec;
112#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
113 uint8_t _name##_buf[_depth*sizeof(_type)]; \
114 osal_queue_def_t _name = { \
115 .ff = TU_FIFO_INIT(_name##_buf, _depth, _type, false) \
119TU_ATTR_ALWAYS_INLINE
static inline void _osal_q_lock(osal_queue_t qhdl)
121 critical_section_enter_blocking(&qhdl->critsec);
125TU_ATTR_ALWAYS_INLINE
static inline void _osal_q_unlock(osal_queue_t qhdl)
127 critical_section_exit(&qhdl->critsec);
130TU_ATTR_ALWAYS_INLINE
static inline osal_queue_t osal_queue_create(
osal_queue_def_t* qdef)
132 critical_section_init(&qdef->critsec);
133 tu_fifo_clear(&qdef->ff);
134 return (osal_queue_t) qdef;
137TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_receive(osal_queue_t qhdl,
void* data, uint32_t msec)
147 bool success = tu_fifo_read(&qhdl->ff, data);
148 _osal_q_unlock(qhdl);
153TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_send(osal_queue_t qhdl,
void const * data,
bool in_isr)
162 bool success = tu_fifo_write(&qhdl->ff, data);
163 _osal_q_unlock(qhdl);
170TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_empty(osal_queue_t qhdl)
177 return tu_fifo_empty(&qhdl->ff);
Definition osal_freertos.h:58
Definition osal_none.h:47
Definition tusb_fifo.h:108