summaryrefslogtreecommitdiff
path: root/tinyusb/osal
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-07-04 13:24:54 +0700
committerhathach <[email protected]>2013-07-04 13:24:54 +0700
commit97cbb39f6ff3f64f8816830c278c888ffd7a0b18 (patch)
treef06400af6450f7d19dc8e63b7950da92b7eb1083 /tinyusb/osal
parent391e132d6bf37bcbb4211729b3728a85c4f5d174 (diff)
port osal_mutex to freeRTOS, able to mount mouse & cdc device
tinyusb host stack overflow though
Diffstat (limited to 'tinyusb/osal')
-rw-r--r--tinyusb/osal/osal_freeRTOS.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h
index a769853c1..52883126b 100644
--- a/tinyusb/osal/osal_freeRTOS.h
+++ b/tinyusb/osal/osal_freeRTOS.h
@@ -114,6 +114,8 @@ static inline void osal_task_delay(uint32_t msec)
#define OSAL_SUBTASK_END \
return TUSB_ERROR_NONE;
+#define SUBTASK_EXIT(error) return error;
+
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
status = subtask
@@ -165,6 +167,33 @@ static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl)
}
//--------------------------------------------------------------------+
+// MUTEX API (priority inheritance)
+//--------------------------------------------------------------------+
+#define OSAL_MUTEX_DEF OSAL_SEM_DEF
+typedef xSemaphoreHandle osal_mutex_handle_t;
+
+#define osal_mutex_create(x) \
+ xSemaphoreCreateMutex()
+
+static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
+static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl)
+{
+ return (xSemaphoreGive(mutex_hdl) == pdPASS) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
+}
+
+static inline void osal_mutex_wait(osal_mutex_handle_t const mutex_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
+static inline void osal_mutex_wait(osal_mutex_handle_t const mutex_hdl, uint32_t msec, tusb_error_t *p_error)
+{
+ (*p_error) = ( xSemaphoreTake(mutex_hdl, osal_tick_from_msec(msec)) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
+}
+
+static inline void osal_mutex_reset(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
+static inline void osal_mutex_reset(osal_mutex_handle_t const mutex_hdl)
+{
+ xSemaphoreGive(mutex_hdl);
+}
+
+//--------------------------------------------------------------------+
// QUEUE API
//--------------------------------------------------------------------+
typedef struct{