52 #define TUSB_OS_NONE 1
53 #define TUSB_OS_FREERTOS 2
54 #define TUSB_OS_CMSIS_RTX 3
55 #define TUSB_OS_UCOS3 4
58 #include "tusb_option.h"
62 #if TUSB_CFG_OS == TUSB_OS_NONE
66 #if TUSB_CFG_OS == TUSB_OS_FREERTOS
68 #elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
71 #error TUSB_CFG_OS is not defined or OS is not supported yet
75 #define OSAL_TASK_LOOP_BEGIN \
78 #define OSAL_TASK_LOOP_END \
82 #define OSAL_SUBTASK_BEGIN // TODO refractor move
83 #define OSAL_SUBTASK_END \
84 return TUSB_ERROR_NONE;
86 #define SUBTASK_EXIT(error) return error;
88 #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
92 #define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
93 #define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
95 #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
96 func_call; return error
98 #define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
99 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
100 TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
102 #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
103 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
104 condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
114 uint32_t osal_tick_get(
void);
122 #define OSAL_TASK_DEF(code, stack_depth, prio) \
125 #define OSAL_TASK_REF(name) (&name)
127 #define OSAL_TASK_FUNCTION(task_name) \
130 void osal_task_delay(uint32_t msec);
132 #define OSAL_TASK_LOOP_BEGIN
133 #define OSAL_TASK_LOOP_END
135 #define SUBTASK_EXIT(error) return error;
138 #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
141 #define OSAL_SUBTASK_BEGIN
142 #define OSAL_SUBTASK_END \
143 return TUSB_ERROR_NONE;
146 #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
147 func_call; return error
149 #define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
151 #define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
152 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
153 TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
155 #define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
157 #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
158 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
159 condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
166 typedef osal_semaphore_t * osal_semaphore_handle_t;
168 #define OSAL_SEM_DEF(name)\
169 osal_semaphore_t name
171 #define OSAL_SEM_REF(name)\
174 osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem);
175 void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec,
tusb_error_t *p_error);
176 tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl);
177 void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl);
182 #define OSAL_MUTEX_DEF(name)\
185 #define OSAL_MUTEX_REF(name)\
189 typedef osal_semaphore_handle_t osal_mutex_handle_t;
191 osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex);
192 void osal_mutex_wait(osal_mutex_handle_t mutex_hdl, uint32_t msec,
tusb_error_t *p_error);
193 tusb_error_t osal_mutex_release(osal_mutex_handle_t mutex_hdl);
194 void osal_mutex_reset(osal_mutex_handle_t mutex_hdl);
199 uint32_t *
const buffer ;
200 uint8_t
const depth ;
201 volatile uint8_t count ;
202 volatile uint8_t wr_idx ;
203 volatile uint8_t rd_idx ;
208 #define OSAL_QUEUE_DEF(name, queue_depth, type) \
211 #define OSAL_QUEUE_REF(name) (&name)
213 osal_queue_handle_t osal_queue_create (
osal_queue_t *p_queue);
214 void osal_queue_receive (osal_queue_handle_t
const queue_hdl,
void *p_data, uint32_t msec,
tusb_error_t *p_error);
215 tusb_error_t osal_queue_send (osal_queue_handle_t
const queue_hdl,
const void * data);
216 void osal_queue_flush(osal_queue_handle_t
const queue_hdl);
221 uint32_t osal_tick_get(
void);
Definition: osal_cmsis_rtx.h:119
Definition: osal_freeRTOS.h:160
tusb_error_t
Error Code returned.
Definition: tusb_errors.h:100
Definition: osal_freeRTOS.h:69
Definition: osal_cmsis_rtx.h:82