From d615ac19dbba7b34d6ae9b87ada5f184a7b7054f Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 28 Feb 2016 08:42:01 +0000 Subject: [PATCH] Fixed bug #714. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/stable_16.1.x@8971 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/usb.c | 14 ++++++++++++++ readme.txt | 2 ++ 2 files changed, 16 insertions(+) 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).