Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(usbh): robustness against unplugging usb device when it is busy #2205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/host/usbh.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,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