diff options
| author | hathach <[email protected]> | 2018-08-28 15:56:43 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-08-28 15:56:43 +0700 |
| commit | c8b72e397e2ed2b1aabe4212c9b29fe06ee537b3 (patch) | |
| tree | 4fa1e7dc3431d58f89da8eb82b921f2f09206b27 /src/device/usbd.c | |
| parent | bb2a8fcebfb424514a5aac97cdf38a83178bd89e (diff) | |
add while loop to usbd task to run until task queue is empty
Diffstat (limited to 'src/device/usbd.c')
| -rw-r--r-- | src/device/usbd.c | 68 |
1 files changed, 36 insertions, 32 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index ea5e24884..8f1f6be90 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -265,45 +265,49 @@ static tusb_error_t usbd_main_st(void) OSAL_SUBTASK_BEGIN
- tusb_error_t err;
- err = TUSB_ERROR_NONE;
-
- memclr_(&event, sizeof(usbd_task_event_t));
+ // Loop until there is no more events in the queue
+ while (1)
+ {
+ tusb_error_t err;
+ err = TUSB_ERROR_NONE;
- osal_queue_receive(_usbd_q, &event, OSAL_TIMEOUT_WAIT_FOREVER, &err);
+ memclr_(&event, sizeof(usbd_task_event_t));
- if ( USBD_EVT_SETUP_RECEIVED == event.event_id )
- {
- STASK_INVOKE( proc_control_request_st(event.rhport, &event.setup_received), err );
- }
- else if (USBD_EVT_XFER_DONE == event.event_id)
- {
- // Invoke the class callback associated with the endpoint address
- uint8_t const ep_addr = event.xfer_done.ep_addr;
- uint8_t const drv_id = _usbd_dev.ep2drv[ edpt_dir(ep_addr) ][ edpt_number(ep_addr) ];
+ osal_queue_receive(_usbd_q, &event, OSAL_TIMEOUT_WAIT_FOREVER, &err);
- if (drv_id < USBD_CLASS_DRIVER_COUNT)
+ if ( USBD_EVT_SETUP_RECEIVED == event.event_id )
{
- usbd_class_drivers[drv_id].xfer_cb( event.rhport, ep_addr, (tusb_event_t) event.xfer_done.result, event.xfer_done.xferred_byte);
+ STASK_INVOKE( proc_control_request_st(event.rhport, &event.setup_received), err );
}
- }
- else if (USBD_EVT_SOF == event.event_id)
- {
- for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+ else if (USBD_EVT_XFER_DONE == event.event_id)
{
- if ( usbd_class_drivers[i].sof )
+ // Invoke the class callback associated with the endpoint address
+ uint8_t const ep_addr = event.xfer_done.ep_addr;
+ uint8_t const drv_id = _usbd_dev.ep2drv[ edpt_dir(ep_addr) ][ edpt_number(ep_addr) ];
+
+ if (drv_id < USBD_CLASS_DRIVER_COUNT)
{
- usbd_class_drivers[i].sof( event.rhport );
+ usbd_class_drivers[drv_id].xfer_cb( event.rhport, ep_addr, (tusb_event_t) event.xfer_done.result, event.xfer_done.xferred_byte);
}
}
- }
- else if ( USBD_EVT_FUNC_CALL == event.event_id )
- {
- if ( event.func_call.func ) event.func_call.func(event.func_call.param);
- }
- else
- {
- STASK_ASSERT(false);
+ else if (USBD_EVT_SOF == event.event_id)
+ {
+ for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
+ {
+ if ( usbd_class_drivers[i].sof )
+ {
+ usbd_class_drivers[i].sof( event.rhport );
+ }
+ }
+ }
+ else if ( USBD_EVT_FUNC_CALL == event.event_id )
+ {
+ if ( event.func_call.func ) event.func_call.func(event.func_call.param);
+ }
+ else
+ {
+ STASK_ASSERT(false);
+ }
}
OSAL_SUBTASK_END
@@ -601,8 +605,8 @@ void dcd_setup_received(uint8_t rhport, uint8_t const* p_request) {
usbd_task_event_t task_event =
{
- .rhport = rhport,
- .event_id = USBD_EVT_SETUP_RECEIVED,
+ .rhport = rhport,
+ .event_id = USBD_EVT_SETUP_RECEIVED,
};
memcpy(&task_event.setup_received, p_request, sizeof(tusb_control_request_t));
|
