correct dcd_pipe_is_busy to use list_qtd_idx[] instead of qtd_overlay
flush usbd_queue_hdl when bus_reset add assert check for osal_queue_send increase ENUM_QUEUE_DEPTH for usbh change osal_freeRTOS.h implementation to - correctly waiting forever for semaphore wait, queue & mutex - not use ISR safe version since it is not as generic as we want
This commit is contained in:
@@ -103,28 +103,26 @@ static inline void osal_task_delay(uint32_t msec)
|
||||
typedef xSemaphoreHandle osal_semaphore_handle_t;
|
||||
|
||||
// create FreeRTOS binary semaphore with zero as init value TODO: omit semaphore take from vSemaphoreCreateBinary API, should double checks this
|
||||
#define osal_semaphore_create(x) \
|
||||
xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )
|
||||
#define osal_semaphore_create(x) xSemaphoreCreateBinary()
|
||||
|
||||
// TODO add timeout (with instant return from ISR option) for semaphore post & queue send
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const sem_hdl)
|
||||
{
|
||||
portBASE_TYPE task_waken;
|
||||
return (xSemaphoreGiveFromISR(sem_hdl, &task_waken) == pdTRUE) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
|
||||
return (xSemaphoreGive(sem_hdl) == pdTRUE) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_SEMAPHORE_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_semaphore_wait(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( xSemaphoreTake(sem_hdl, osal_tick_from_msec(msec)) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
|
||||
(*p_error) = ( xSemaphoreTake(sem_hdl, ticks) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl)
|
||||
{
|
||||
portBASE_TYPE task_waken;
|
||||
xSemaphoreTakeFromISR(sem_hdl, &task_waken);
|
||||
(void) xSemaphoreTake(sem_hdl, 0);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -144,7 +142,8 @@ static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_h
|
||||
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;
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
|
||||
(*p_error) = ( xSemaphoreTake(mutex_hdl, ticks) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline void osal_mutex_reset(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
|
||||
@@ -176,14 +175,14 @@ typedef xQueueHandle osal_queue_handle_t;
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
|
||||
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error)
|
||||
{
|
||||
(*p_error) = ( xQueueReceive(queue_hdl, p_data, osal_tick_from_msec(msec)) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : osal_tick_from_msec(msec);
|
||||
(*p_error) = ( xQueueReceive(queue_hdl, p_data, ticks) == pdPASS ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT;
|
||||
}
|
||||
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data) ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, void const * data)
|
||||
{
|
||||
portBASE_TYPE taskWaken;
|
||||
return ( xQueueSendFromISR(queue_hdl, data, &taskWaken) == pdTRUE ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_QUEUE_FAILED;
|
||||
return ( xQueueSend(queue_hdl, data, 0) == pdTRUE ) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_QUEUE_FAILED;
|
||||
}
|
||||
|
||||
static inline void osal_queue_flush(osal_queue_handle_t const queue_hdl) ATTR_ALWAYS_INLINE;
|
||||
|
||||
Reference in New Issue
Block a user