From 0ef7edb44677b2c55536bd010fa03f708d690cb2 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 1 May 2019 01:46:39 +0700 Subject: [PATCH] osal clean up --- src/osal/osal.h | 67 ++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/src/osal/osal.h b/src/osal/osal.h index cdeaa2974..7304fdbd2 100644 --- a/src/osal/osal.h +++ b/src/osal/osal.h @@ -47,56 +47,49 @@ enum typedef void (*osal_task_func_t)( void * ); +#if CFG_TUSB_OS == OPT_OS_NONE + #include "osal_none.h" +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + #include "osal_freertos.h" +#elif CFG_TUSB_OS == OPT_OS_MYNEWT + #include "osal_mynewt.h" +#else + #error OS is not supported yet +#endif + //--------------------------------------------------------------------+ // OSAL Porting API //--------------------------------------------------------------------+ -#if 0 -void osal_task_delay(uint32_t msec); +static inline void osal_task_delay(uint32_t msec); //------------- Semaphore -------------// -osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); -bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); -bool osal_semaphore_wait (osal_semaphore_t sem_hdl, uint32_t msec); +static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semdef); +static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr); +static inline bool osal_semaphore_wait(osal_semaphore_t sem_hdl, uint32_t msec); -void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed +static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl); // TODO removed //------------- Mutex -------------// -osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); -bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); -bool osal_mutex_unlock(osal_mutex_t mutex_hdl); +static inline osal_mutex_t osal_mutex_create(osal_mutex_def_t* mdef); +static inline bool osal_mutex_lock (osal_mutex_t sem_hdl, uint32_t msec); +static inline bool osal_mutex_unlock(osal_mutex_t mutex_hdl); //------------- Queue -------------// -osal_queue_t osal_queue_create(osal_queue_def_t* qdef); -bool osal_queue_receive(osal_queue_t const qhdl, void* data); -bool osal_queue_send(osal_queue_t const qhdl, void const * data, bool in_isr); -#endif +static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef); +static inline bool osal_queue_receive(osal_queue_t const qhdl, void* data); +static inline bool osal_queue_send(osal_queue_t const qhdl, void const * data, bool in_isr); -#if CFG_TUSB_OS == OPT_OS_NONE - #include "osal_none.h" -#else - #if CFG_TUSB_OS == OPT_OS_FREERTOS - #include "osal_freertos.h" - #elif CFG_TUSB_OS == OPT_OS_MYNEWT - #include "osal_mynewt.h" - #else - #error CFG_TUSB_OS is not defined or OS is not supported yet - #endif +#if 0 // TODO remove subtask related macros later +// Sub Task +#define OSAL_SUBTASK_BEGIN +#define OSAL_SUBTASK_END return TUSB_ERROR_NONE; - // TODO remove subtask related macros later +#define STASK_RETURN(_error) return _error; +#define STASK_INVOKE(_subtask, _status) (_status) = _subtask - //------------- Sub Task -------------// - #define OSAL_SUBTASK_BEGIN - #define OSAL_SUBTASK_END return TUSB_ERROR_NONE; - - #define STASK_RETURN(_error) return _error; - #define STASK_INVOKE(_subtask, _status) (_status) = _subtask - - //------------- Sub Task Assert -------------// - #define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR(_err) - #define STASK_ASSERT_ERR_HDLR(_err, _func) TU_VERIFY_ERR_HDLR(_err, _func) - - #define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED) - #define STASK_ASSERT_HDLR(_cond, _func) TU_VERIFY_HDLR(_cond, _func) +// Sub Task Assert +#define STASK_ASSERT_ERR(_err) TU_VERIFY_ERR(_err) +#define STASK_ASSERT(_cond) TU_VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED) #endif #ifdef __cplusplus