27#ifndef _TUSB_OSAL_NONE_H_
28#define _TUSB_OSAL_NONE_H_
40TU_ATTR_WEAK
void osal_task_delay(uint32_t msec);
48 volatile uint16_t count;
53TU_ATTR_ALWAYS_INLINE
static inline osal_semaphore_t osal_semaphore_create(
osal_semaphore_def_t* semdef)
59TU_ATTR_ALWAYS_INLINE
static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl,
bool in_isr)
67TU_ATTR_ALWAYS_INLINE
static inline bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec)
71 while (sem_hdl->count == 0) { }
77TU_ATTR_ALWAYS_INLINE
static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
87typedef osal_semaphore_t osal_mutex_t;
89#if OSAL_MUTEX_REQUIRED
93TU_ATTR_ALWAYS_INLINE
static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef)
99TU_ATTR_ALWAYS_INLINE
static inline bool osal_mutex_lock (osal_mutex_t mutex_hdl, uint32_t msec)
101 return osal_semaphore_wait(mutex_hdl, msec);
104TU_ATTR_ALWAYS_INLINE
static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl)
106 return osal_semaphore_post(mutex_hdl,
false);
111#define osal_mutex_create(_mdef) (NULL)
112#define osal_mutex_lock(_mutex_hdl, _ms) (true)
113#define osal_mutex_unlock(_mutex_hdl) (true)
120#include "common/tusb_fifo.h"
124 void (*interrupt_set)(bool);
131#define OSAL_QUEUE_DEF(_int_set, _name, _depth, _type) \
132 uint8_t _name##_buf[_depth*sizeof(_type)]; \
133 osal_queue_def_t _name = { \
134 .interrupt_set = _int_set, \
135 .ff = TU_FIFO_INIT(_name##_buf, _depth, _type, false) \
139TU_ATTR_ALWAYS_INLINE
static inline void _osal_q_lock(osal_queue_t qhdl)
142 qhdl->interrupt_set(
false);
146TU_ATTR_ALWAYS_INLINE
static inline void _osal_q_unlock(osal_queue_t qhdl)
149 qhdl->interrupt_set(
true);
152TU_ATTR_ALWAYS_INLINE
static inline osal_queue_t osal_queue_create(
osal_queue_def_t* qdef)
154 tu_fifo_clear(&qdef->ff);
155 return (osal_queue_t) qdef;
158TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_receive(osal_queue_t qhdl,
void* data, uint32_t msec)
163 bool success = tu_fifo_read(&qhdl->ff, data);
164 _osal_q_unlock(qhdl);
169TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_send(osal_queue_t qhdl,
void const * data,
bool in_isr)
175 bool success = tu_fifo_write(&qhdl->ff, data);
178 _osal_q_unlock(qhdl);
186TU_ATTR_ALWAYS_INLINE
static inline bool osal_queue_empty(osal_queue_t qhdl)
190 return tu_fifo_empty(&qhdl->ff);
Definition osal_freertos.h:58
Definition osal_none.h:47
Definition tusb_fifo.h:108