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
74 #define OSAL_TASK_LOOP_BEGIN while(1) {
75 #define OSAL_TASK_LOOP_END }
78 #define OSAL_SUBTASK_BEGIN // TODO refractor move
79 #define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
81 #define SUBTASK_EXIT(error) return error;
82 #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
85 #define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
86 #define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
88 #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) func_call; return error
90 #define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
91 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
92 TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
94 #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
95 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
96 condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
105 uint32_t osal_tick_get(
void);
113 #define OSAL_TASK_DEF(code, stack_depth, prio) osal_task_t variable
115 #define OSAL_TASK_REF(name) (&name)
117 #define OSAL_TASK_FUNCTION(task_name) void task_name
119 void osal_task_delay(uint32_t msec);
121 #define OSAL_TASK_LOOP_BEGIN
122 #define OSAL_TASK_LOOP_END
124 #define SUBTASK_EXIT(error) return error;
127 #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
129 #define OSAL_SUBTASK_BEGIN
130 #define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
133 #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) func_call; return error
135 #define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
137 #define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
138 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
139 TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
141 #define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
143 #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
144 ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
145 condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
151 typedef osal_semaphore_t * osal_semaphore_handle_t;
153 #define OSAL_SEM_DEF(name) osal_semaphore_t name
154 #define OSAL_SEM_REF(name) &name
156 osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem);
157 void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec,
tusb_error_t *p_error);
158 tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl);
159 void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl);
164 #define OSAL_MUTEX_DEF(name) osal_mutex_t name
165 #define OSAL_MUTEX_REF(name) &name
168 typedef osal_semaphore_handle_t osal_mutex_handle_t;
170 osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex);
171 void osal_mutex_wait(osal_mutex_handle_t mutex_hdl, uint32_t msec,
tusb_error_t *p_error);
172 tusb_error_t osal_mutex_release(osal_mutex_handle_t mutex_hdl);
173 void osal_mutex_reset(osal_mutex_handle_t mutex_hdl);
178 uint32_t *
const buffer ;
179 uint8_t
const depth ;
180 volatile uint8_t count ;
181 volatile uint8_t wr_idx ;
182 volatile uint8_t rd_idx ;
187 #define OSAL_QUEUE_DEF(name, queue_depth, type) osal_queue_t name
188 #define OSAL_QUEUE_REF(name) (&name)
190 osal_queue_handle_t osal_queue_create (
osal_queue_t *p_queue);
191 void osal_queue_receive (osal_queue_handle_t
const queue_hdl,
void *p_data, uint32_t msec,
tusb_error_t *p_error);
192 tusb_error_t osal_queue_send (osal_queue_handle_t
const queue_hdl,
const void * data);
193 void osal_queue_flush(osal_queue_handle_t
const queue_hdl);
198 uint32_t osal_tick_get(
void);
tusb_error_t
Error Code returned.