summaryrefslogtreecommitdiff
path: root/src/osal/osal.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-05-01 01:46:39 +0700
committerhathach <[email protected]>2019-05-01 01:46:39 +0700
commit0ef7edb44677b2c55536bd010fa03f708d690cb2 (patch)
tree9b1feca8cdc0f26cb561ac535669a1eddc2bb195 /src/osal/osal.h
parent89ace295ba2b509dcb42d3df9501134df968c2f4 (diff)
osal clean up
Diffstat (limited to 'src/osal/osal.h')
-rw-r--r--src/osal/osal.h67
1 files 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
-
-#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
-
- // TODO remove subtask related macros later
-
- //------------- Sub Task -------------//
- #define OSAL_SUBTASK_BEGIN
- #define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
+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);
- #define STASK_RETURN(_error) return _error;
- #define STASK_INVOKE(_subtask, _status) (_status) = _subtask
+#if 0 // TODO remove subtask related macros later
+// Sub Task
+#define OSAL_SUBTASK_BEGIN
+#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
- //------------- 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_RETURN(_error) return _error;
+#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
- #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