diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-27 11:12:09 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-27 11:12:09 +0000 |
commit | d93fdcd424c049078009119940d0042bb229ed38 (patch) | |
tree | 52201084180b40246ced4918e47936bbaaff0d97 /os/hal/src | |
parent | ef8ef298b95d0ea9c8807b36b7ae939f2dbab510 (diff) | |
download | ChibiOS-d93fdcd424c049078009119940d0042bb229ed38.tar.gz ChibiOS-d93fdcd424c049078009119940d0042bb229ed38.tar.bz2 ChibiOS-d93fdcd424c049078009119940d0042bb229ed38.zip |
Fixed stability problems in OTGv1.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8651 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/usb.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index 2075cd7a2..b6813c381 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -380,6 +380,19 @@ void usbDisableEndpointsI(USBDriver *usbp) { usbp->transmitting &= ~1U;
usbp->receiving &= ~1U;
for (i = 1; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
+#if USB_USE_WAIT == TRUE
+ /* Signaling the event to threads waiting on endpoints.*/
+ if (usbp->epc[i] != NULL) {
+ osalSysLockFromISR();
+ 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);
+ }
+ osalSysUnlockFromISR();
+ }
+#endif
usbp->epc[i] = NULL;
}
@@ -638,12 +651,14 @@ void _usb_reset(USBDriver *usbp) { #if USB_USE_WAIT == TRUE
/* Signaling the event to threads waiting on endpoints.*/
if (usbp->epc[i] != NULL) {
+ osalSysLockFromISR();
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);
}
+ osalSysUnlockFromISR();
}
#endif
usbp->epc[i] = NULL;
@@ -671,7 +686,7 @@ void _usb_reset(USBDriver *usbp) { void _usb_suspend(USBDriver *usbp) {
/* State transition.*/
- usbp->state = USB_SUSPENDED;
+ usbp->state = USB_SUSPENDED;
/* Notification of suspend event.*/
_usb_isr_invoke_event_cb(usbp, USB_EVENT_SUSPEND);
@@ -683,12 +698,14 @@ void _usb_suspend(USBDriver *usbp) { for (i = 0; i <= (unsigned)USB_MAX_ENDPOINTS; i++) {
if (usbp->epc[i] != NULL) {
+ osalSysLockFromISR();
if (usbp->epc[i]->in_state != NULL) {
osalThreadResumeI(&usbp->epc[i]->in_state->thread, MSG_TIMEOUT);
}
if (usbp->epc[i]->out_state != NULL) {
osalThreadResumeI(&usbp->epc[i]->out_state->thread, MSG_TIMEOUT);
}
+ osalSysUnlockFromISR();
}
}
}
|