osal clean up

- task create, task def macros
This commit is contained in:
hathach
2018-02-28 14:21:31 +07:00
parent 5efad7412f
commit 9b7cd608aa
20 changed files with 360 additions and 287 deletions

View File

@@ -56,9 +56,15 @@
/** @} */
#include "tusb_option.h"
#include "common/common.h"
#ifndef _TEST_
typedef void (*osal_func_t)(void *param);
typedef void* osal_task_t;
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl);
#if TUSB_CFG_OS == TUSB_OS_NONE
#include "osal_none.h"

View File

@@ -66,13 +66,6 @@ extern "C" {
//--------------------------------------------------------------------+
#define OSAL_TASK_FUNCTION portTASK_FUNCTION
typedef struct {
char const * name;
pdTASK_CODE code;
unsigned portSHORT stack_depth;
unsigned portBASE_TYPE prio;
} osal_task_t;
#define OSAL_TASK_DEF(task_code, task_stack_depth, task_prio) \
osal_task_t osal_task_def_##task_code = {\
.name = #task_code , \
@@ -83,11 +76,9 @@ typedef struct {
#define OSAL_TASK_REF(name) (&osal_task_def_##name)
static inline tusb_error_t osal_task_create(osal_task_t *task) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline tusb_error_t osal_task_create(osal_task_t *task)
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl)
{
return pdPASS == xTaskCreate(task->code, (signed portCHAR const *) task->name, task->stack_depth, NULL, task->prio, NULL) ?
TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TASK_CREATE_FAILED;
return xTaskCreate(code, (const signed char*) name, stack_size, param, prio, task_hdl);
}
static inline void osal_task_delay(uint32_t msec) ATTR_ALWAYS_INLINE;

View File

@@ -70,8 +70,13 @@ uint32_t tusb_tick_get(void);
// }
//--------------------------------------------------------------------+
#define OSAL_TASK_DEF(code, stack_depth, prio)
#define OSAL_TASK_REF
#define osal_task_create(x) TUSB_ERROR_NONE
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl)
{
(void) code; (void) name; (void) stack_size; (void) param; (void) prio; (void) task_hdl;
return true;
}
#define OSAL_TASK_FUNCTION(task_func, p_para) tusb_error_t task_func(void * p_para)
@@ -89,7 +94,7 @@ uint32_t tusb_tick_get(void);
default:\
TASK_RESTART;\
}}\
return TUSB_ERROR_NONE;
return /*TUSB_ERROR_NONE*/;
#define osal_task_delay(msec) \