From 10bf41f718ea867a3621e11b4c49e72605bbcc89 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 14 Nov 2018 16:31:28 +0700 Subject: change osal_queue_receive() signature - fix build issue with freertos --- src/device/dcd.h | 2 -- src/device/usbd.c | 23 ++++++++++++----------- src/host/usbh.c | 10 ++++++++-- src/osal/osal.h | 7 +------ src/osal/osal_freertos.h | 5 ++--- src/osal/osal_none.h | 11 ++++++----- 6 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/device/dcd.h b/src/device/dcd.h index 0c976edec..ff836f405 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -125,8 +125,6 @@ void dcd_event_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_ /*------------------------------------------------------------------*/ /* Endpoint API *------------------------------------------------------------------*/ - -//------------- Non-control Endpoints -------------// bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc); bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes); bool dcd_edpt_busy (uint8_t rhport, uint8_t ep_addr); diff --git a/src/device/usbd.c b/src/device/usbd.c index c9d5e5642..4a9b13a25 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -245,24 +245,25 @@ void usbd_task( void* param) { (void) param; - OSAL_TASK_BEGIN +#if CFG_TUSB_OS != OPT_OS_NONE + while (1) { +#endif + usbd_main_st(); - OSAL_TASK_END + +#if CFG_TUSB_OS != OPT_OS_NONE + } +#endif } static tusb_error_t usbd_main_st(void) { dcd_event_t event; - tusb_error_t err = TUSB_ERROR_NONE; + // Loop until there is no more events in the queue - while (_usbd_q->count > 0) + while (1) { - tu_memclr(&event, sizeof(dcd_event_t)); - - err = osal_queue_receive(_usbd_q, &event); - if (err != TUSB_ERROR_NONE) { - break; - } + if ( !osal_queue_receive(_usbd_q, &event) ) return TUSB_ERROR_NONE; if ( DCD_EVENT_SETUP_RECEIVED == event.event_id ) { @@ -312,7 +313,7 @@ static tusb_error_t usbd_main_st(void) } } - return err; + return TUSB_ERROR_NONE; } void tud_control_interface_control_complete_cb(uint8_t rhport, uint8_t interface, tusb_control_request_t const * const p_request) { diff --git a/src/host/usbh.c b/src/host/usbh.c index b849de9b9..f996d7a70 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -361,9 +361,15 @@ void usbh_enumeration_task(void* param) { (void) param; - OSAL_TASK_BEGIN +#if CFG_TUSB_OS != OPT_OS_NONE + while (1) { +#endif + enumeration_body_subtask(); - OSAL_TASK_END + +#if CFG_TUSB_OS != OPT_OS_NONE + } +#endif } tusb_error_t enumeration_body_subtask(void) diff --git a/src/osal/osal.h b/src/osal/osal.h index 2ca06f66e..6846b5757 100644 --- a/src/osal/osal.h +++ b/src/osal/osal.h @@ -62,10 +62,6 @@ typedef void (*osal_task_func_t)( void * ); #if CFG_TUSB_OS == OPT_OS_NONE #include "osal_none.h" - - #define OSAL_TASK_BEGIN - #define OSAL_TASK_END - #else /* RTOS Porting API * @@ -105,8 +101,7 @@ typedef void (*osal_task_func_t)( void * ); #error CFG_TUSB_OS is not defined or OS is not supported yet #endif - #define OSAL_TASK_BEGIN while(1) { - #define OSAL_TASK_END } + // TODO remove subtask related macros later //------------- Sub Task -------------// #define OSAL_SUBTASK_BEGIN diff --git a/src/osal/osal_freertos.h b/src/osal/osal_freertos.h index f29759225..52cadd798 100644 --- a/src/osal/osal_freertos.h +++ b/src/osal/osal_freertos.h @@ -159,10 +159,9 @@ static inline osal_queue_t osal_queue_create(osal_queue_def_t* qdef) return xQueueCreateStatic(qdef->depth, qdef->item_sz, (uint8_t*) qdef->buf, &qdef->sq); } -static inline void osal_queue_receive (osal_queue_t const queue_hdl, void *p_data, uint32_t msec, uint32_t *err) +static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data) { - uint32_t const ticks = (msec == OSAL_TIMEOUT_WAIT_FOREVER) ? portMAX_DELAY : pdMS_TO_TICKS(msec); - (*err) = ( xQueueReceive(queue_hdl, p_data, ticks) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TIMEOUT); + return xQueueReceive(queue_hdl, data, portMAX_DELAY); } static inline bool osal_queue_send(osal_queue_t const queue_hdl, void const * data, bool in_isr) diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 383809180..5ba246d5f 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -89,6 +89,7 @@ static inline osal_semaphore_t osal_semaphore_create(osal_semaphore_def_t* semde static inline bool osal_semaphore_post(osal_semaphore_t sem_hdl, bool in_isr) { + (void) in_isr; sem_hdl->count++; return true; } @@ -157,11 +158,11 @@ static inline void osal_queue_reset(osal_queue_t const queue_hdl) queue_hdl->count = queue_hdl->rd_idx = queue_hdl->wr_idx = 0; } -static inline tusb_error_t osal_queue_receive(osal_queue_t const queue_hdl, void* data) { - if (!tu_fifo_read(queue_hdl, data)) { - return TUSB_ERROR_OSAL_WAITING; - } - return TUSB_ERROR_NONE; + +static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data) +{ + // osal none return immediately without blocking + return tu_fifo_read(queue_hdl, data); } -- cgit v1.3.1