remove OSAL_VAR for the simplicity
clean up osal.h
This commit is contained in:
@@ -71,29 +71,21 @@
|
||||
#error TUSB_CFG_OS is not defined or OS is not supported yet
|
||||
#endif
|
||||
|
||||
#define OSAL_VAR
|
||||
#define OSAL_TASK_LOOP_BEGIN \
|
||||
while(1) {
|
||||
|
||||
#define OSAL_TASK_LOOP_END \
|
||||
}
|
||||
#define OSAL_TASK_LOOP_BEGIN while(1) {
|
||||
#define OSAL_TASK_LOOP_END }
|
||||
|
||||
//------------- Sub Task -------------//
|
||||
#define OSAL_SUBTASK_BEGIN // TODO refractor move
|
||||
#define OSAL_SUBTASK_END \
|
||||
return TUSB_ERROR_NONE;
|
||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||
|
||||
#define SUBTASK_EXIT(error) return error;
|
||||
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
|
||||
status = subtask
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
|
||||
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
|
||||
func_call; return error
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) func_call; return error
|
||||
|
||||
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
|
||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
|
||||
@@ -107,7 +99,6 @@
|
||||
//------------- OSAL API for cmock -------------//
|
||||
#else
|
||||
|
||||
#define OSAL_VAR
|
||||
#include "osal_common.h"
|
||||
|
||||
//------------- Tick -------------//
|
||||
@@ -119,13 +110,11 @@ uint32_t osal_tick_get(void);
|
||||
typedef uint32_t osal_task_t;
|
||||
tusb_error_t osal_task_create(osal_task_t *task);
|
||||
|
||||
#define OSAL_TASK_DEF(code, stack_depth, prio) \
|
||||
osal_task_t variable
|
||||
#define OSAL_TASK_DEF(code, stack_depth, prio) osal_task_t variable
|
||||
|
||||
#define OSAL_TASK_REF(name) (&name)
|
||||
|
||||
#define OSAL_TASK_FUNCTION(task_name) \
|
||||
void task_name
|
||||
#define OSAL_TASK_FUNCTION(task_name) void task_name
|
||||
|
||||
void osal_task_delay(uint32_t msec);
|
||||
|
||||
@@ -135,16 +124,13 @@ void osal_task_delay(uint32_t msec);
|
||||
#define SUBTASK_EXIT(error) return error;
|
||||
|
||||
//------------- Sub Task -------------//
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
|
||||
status = subtask
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
|
||||
|
||||
#define OSAL_SUBTASK_BEGIN
|
||||
#define OSAL_SUBTASK_END \
|
||||
return TUSB_ERROR_NONE;
|
||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
|
||||
func_call; return error
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) func_call; return error
|
||||
|
||||
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
|
||||
|
||||
@@ -158,18 +144,14 @@ void osal_task_delay(uint32_t msec);
|
||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
|
||||
condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Semaphore API
|
||||
//--------------------------------------------------------------------+
|
||||
typedef volatile uint8_t osal_semaphore_t;
|
||||
typedef osal_semaphore_t * osal_semaphore_handle_t;
|
||||
|
||||
#define OSAL_SEM_DEF(name)\
|
||||
osal_semaphore_t name
|
||||
|
||||
#define OSAL_SEM_REF(name)\
|
||||
&name
|
||||
#define OSAL_SEM_DEF(name) osal_semaphore_t name
|
||||
#define OSAL_SEM_REF(name) &name
|
||||
|
||||
osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem);
|
||||
void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec, tusb_error_t *p_error);
|
||||
@@ -179,11 +161,8 @@ void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl);
|
||||
//--------------------------------------------------------------------+
|
||||
// MUTEX API (priority inheritance)
|
||||
//--------------------------------------------------------------------+
|
||||
#define OSAL_MUTEX_DEF(name)\
|
||||
osal_mutex_t name
|
||||
|
||||
#define OSAL_MUTEX_REF(name)\
|
||||
&name
|
||||
#define OSAL_MUTEX_DEF(name) osal_mutex_t name
|
||||
#define OSAL_MUTEX_REF(name) &name
|
||||
|
||||
typedef osal_semaphore_t osal_mutex_t;
|
||||
typedef osal_semaphore_handle_t osal_mutex_handle_t;
|
||||
@@ -205,9 +184,7 @@ typedef struct{
|
||||
|
||||
typedef osal_queue_t * osal_queue_handle_t;
|
||||
|
||||
#define OSAL_QUEUE_DEF(name, queue_depth, type) \
|
||||
osal_queue_t name
|
||||
|
||||
#define OSAL_QUEUE_DEF(name, queue_depth, type) osal_queue_t name
|
||||
#define OSAL_QUEUE_REF(name) (&name)
|
||||
|
||||
osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue);
|
||||
|
||||
Reference in New Issue
Block a user