Browse Source

osal clean up

hathach 6 years ago
parent
commit
0ef7edb446
1 changed files with 30 additions and 37 deletions
  1. 30 37
      src/osal/osal.h

+ 30 - 37
src/osal/osal.h

@@ -47,56 +47,49 @@ enum
 
 
 typedef void (*osal_task_func_t)( void * );
 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
 // OSAL Porting API
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
-#if 0
-void osal_task_delay(uint32_t msec);
+static inline void osal_task_delay(uint32_t msec);
 
 
 //------------- Semaphore -------------//
 //------------- 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 -------------//
 //------------- 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 -------------//
 //------------- 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
 #endif
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus