Skip to content

Commit

Permalink
fix(usbh): robustness against unplugging usb device when it is busy
Browse files Browse the repository at this point in the history
  • Loading branch information
Aladdin Bakosh committed Jul 31, 2023
1 parent 174c168 commit 7dc8d75
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/host/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,20 @@ TU_ATTR_FAST_FUNC void hcd_event_handler(hcd_event_t const* event, bool in_isr)
{
switch (event->event_id)
{
#if CFG_TUH_HUB
// case HCD_EVENT_DEVICE_REMOVE:
// // mark device as removing to prevent further xfer before the event is processed in usbh task
// break;
#else
/* In case of a single device attached we can clear anything in the queue safely */
/* Reset the enumaration process just in case of immature plugging/unplugging */
case HCD_EVENT_DEVICE_REMOVE:
_dev0.enumerating = 0;
tu_memclr(&_ctrl_xfer, sizeof(_ctrl_xfer));
tu_fifo_clear(&_usbh_q->ff);
osal_queue_send(_usbh_q, event, in_isr);
break;
#endif

default:
osal_queue_send(_usbh_q, event, in_isr);
Expand Down

0 comments on commit 7dc8d75

Please sign in to comment.