aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-06-17 09:46:53 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-06-17 09:46:53 +0000
commit371d3c186a84809e49a943fb61f998ebe7b5db48 (patch)
tree5f53045c044673afaf9d62e53263bd82b912b2d0 /os/hal
parentd041c5a901d8958fbd05eddfb3d305e158089ce2 (diff)
downloadChibiOS-371d3c186a84809e49a943fb61f998ebe7b5db48.tar.gz
ChibiOS-371d3c186a84809e49a943fb61f998ebe7b5db48.tar.bz2
ChibiOS-371d3c186a84809e49a943fb61f998ebe7b5db48.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9636 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/src/hal_usb.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/os/hal/src/hal_usb.c b/os/hal/src/hal_usb.c
index c10bf0d56..261ff6822 100644
--- a/os/hal/src/hal_usb.c
+++ b/os/hal/src/hal_usb.c
@@ -141,19 +141,23 @@ static bool default_handler(USBDriver *usbp) {
usbSetupTransfer(usbp, &usbp->configuration, 1, NULL);
return true;
case (uint32_t)USB_RTYPE_RECIPIENT_DEVICE | ((uint32_t)USB_REQ_SET_CONFIGURATION << 8):
- /* Handling configuration selection from the host.*/
- usbp->configuration = usbp->setup[2];
- if (usbp->configuration == 0U) {
+ /* Handling configuration selection from the host only if it is different
+ from the current configuration.*/
+ if (usbp->configuration != usbp->setup[2]) {
+ /* If the USB device is already active then we have to perform the clear
+ procedure on the current configuration.*/
if (usbp->state == USB_ACTIVE) {
+ /* Current configuration cleared.*/
chSysLockFromISR ();
usbDisableEndpointsI(usbp);
chSysUnlockFromISR ();
+ usbp->configuration = 0U;
usbp->state = USB_SELECTED;
_usb_isr_invoke_event_cb(usbp, USB_EVENT_UNCONFIGURED);
}
- }
- else {
- if (usbp->state != USB_ACTIVE) {
+ if (usbp->setup[2] != 0U) {
+ /* New configuration.*/
+ usbp->configuration = usbp->setup[2];
usbp->state = USB_ACTIVE;
_usb_isr_invoke_event_cb(usbp, USB_EVENT_CONFIGURED);
}