From 30a552991b81cef1eb5eae1aa3937b960b6e0f08 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 28 Apr 2013 13:27:37 +0000 Subject: [PATCH] Fixed bug #406. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5638 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/usb.h | 3 ++- os/hal/src/usb.c | 7 ++++--- readme.txt | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/os/hal/include/usb.h b/os/hal/include/usb.h index 8d3bcde6b..6f18d7c55 100644 --- a/os/hal/include/usb.h +++ b/os/hal/include/usb.h @@ -249,7 +249,8 @@ typedef enum { */ typedef enum { USB_EP0_WAITING_SETUP, /**< Waiting for SETUP data. */ - USB_EP0_TX, /**< Transmitting. */ + USB_EP0_TX, /**< Trasmitting. */ + USB_EP0_WAITING_TX0, /**< Waiting transmit 0 */ USB_EP0_WAITING_STS, /**< Waiting status. */ USB_EP0_RX, /**< Receiving. */ USB_EP0_SENDING_STS, /**< Sending status. */ diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index 9c3825910..745b2d436 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -693,15 +693,16 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { /* If the transmitted size is less than the requested size and it is a multiple of the maximum packet size then a zero size packet must be transmitted.*/ - if ((usbp->ep0n < max) && - ((usbp->ep0n % usbp->epc[0]->in_maxsize) == 0)) { + if ((usbp->ep0n < max) && ((usbp->ep0n % usbp->epc[0]->in_maxsize) == 0)) { usbPrepareTransmit(usbp, 0, NULL, 0); chSysLockFromIsr(); usbStartTransmitI(usbp, 0); chSysUnlockFromIsr(); + usbp->ep0state = USB_EP0_WAITING_TX0; return; } - + /* Falls into, it is intentional.*/ + case USB_EP0_WAITING_TX0: /* Transmit phase over, receiving the zero sized status packet.*/ usbp->ep0state = USB_EP0_WAITING_STS; usbPrepareReceive(usbp, 0, NULL, 0); diff --git a/readme.txt b/readme.txt index 7b36831e1..9547ba4b9 100644 --- a/readme.txt +++ b/readme.txt @@ -89,6 +89,8 @@ ***************************************************************************** *** 2.5.2 *** +- FIX: Fixed USB driver possible deadlock under certain configurations (bug + #406)(backported to 2.4.4). - FIX: Fixed USB driver cannot be stopped (bug #405)(backported to 2.4.4). - FIX: Fixed several spelling errors (bug #404). - FIX: Fixed serial port in STM32F3 discovery test case (bug #402).