diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index 1b4993e49..8e557d14e 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -309,6 +309,7 @@ void usbStart(USBDriver *usbp, const USBConfig *config) { * @api */ void usbStop(USBDriver *usbp) { + unsigned i; osalDbgCheck(usbp != NULL); @@ -319,6 +320,19 @@ void usbStop(USBDriver *usbp) { "invalid state"); usb_lld_stop(usbp); usbp->state = USB_STOP; + + /* Resetting all ongoing synchronous operations.*/ + for (i = 0; i <= (unsigned)USB_MAX_ENDPOINTS; i++) { + if (usbp->epc[i] != NULL) { + if (usbp->epc[i]->in_state != NULL) { + osalThreadResumeI(&usbp->epc[i]->in_state->thread, MSG_RESET); + } + if (usbp->epc[i]->out_state != NULL) { + osalThreadResumeI(&usbp->epc[i]->out_state->thread, MSG_RESET); + } + } + } + osalOsRescheduleS(); osalSysUnlock(); } diff --git a/readme.txt b/readme.txt index 190c31678..377a51e55 100644 --- a/readme.txt +++ b/readme.txt @@ -74,6 +74,8 @@ *** 16.1.4 *** - ALL: Startup files relicensed under Apache 2.0. +- HAL: Fixed usbStop does not resume threads suspended in synchronous calls + to usbTransmit (bug #714). - VAR: Fixed state check in lwIP when SYS_LIGHTWEIGHT_PROT is disabled (bug #713). - RT: Fixed race condition in RT registry (bug #712).