port osal_mutex to freeRTOS, able to mount mouse & cdc device

tinyusb host stack overflow though
This commit is contained in:
hathach 2013-07-04 13:24:54 +07:00
parent 391e132d6b
commit 97cbb39f6f
3 changed files with 35 additions and 4 deletions

View File

@ -90,7 +90,7 @@
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="freertos/freertos/Source/portable/GCC/ARM_CM4F"/>
<entry excluding="heap_2.c|heap_3.c|heap_4.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="freertos/freertos/Source/portable/MemMang"/>
<entry excluding="bsp/boards/embedded_artists/oem_base_board|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="bsp/lpc175x_6x|bsp/boards/embedded_artists/oem_base_board|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
@ -750,8 +750,8 @@
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="freertos/freertos/Source/portable/GCC/ARM_CM4F"/>
<entry excluding="freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="heap_2.c|heap_3.c|heap_4.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="freertos/freertos/Source/portable/MemMang"/>
<entry excluding="bsp/lpc175x_6x|freertos/freertoslpc/FreeRTOS_lpc43xx_m0_Tick.c|freertos/freertos/Source/portable|bsp/boards/EA4357|NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>

View File

@ -57,8 +57,10 @@
extern "C" {
#endif
#define KEYBOARD_APP_TASK_PRIO (TUSB_CFG_OS_TASK_PRIO-1)
#define MOUSE_APP_TASK_PRIO (KEYBOARD_APP_TASK_PRIO-1)
#define KEYBOARD_APP_TASK_PRIO (TUSB_CFG_OS_TASK_PRIO-2)
#define MOUSE_APP_TASK_PRIO KEYBOARD_APP_TASK_PRIO
#define CDC_SERIAL_APP_TASK_PRIO KEYBOARD_APP_TASK_PRIO
#define LED_BLINKING_APP_TASK_PRIO (tskIDLE_PRIORITY+1)
#ifdef __cplusplus

View File

@ -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
@ -164,6 +166,33 @@ static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl)
xSemaphoreTakeFromISR(sem_hdl, &task_waken);
}
//--------------------------------------------------------------------+
// 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
//--------------------------------------------------------------------+