git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9636 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
Giovanni Di Sirio 2016-06-17 09:46:53 +00:00
parent d041c5a901
commit 371d3c186a
1 changed files with 10 additions and 6 deletions

View File

@ -141,19 +141,23 @@ static bool default_handler(USBDriver *usbp) {
usbSetupTransfer(usbp, &usbp->configuration, 1, NULL); usbSetupTransfer(usbp, &usbp->configuration, 1, NULL);
return true; return true;
case (uint32_t)USB_RTYPE_RECIPIENT_DEVICE | ((uint32_t)USB_REQ_SET_CONFIGURATION << 8): case (uint32_t)USB_RTYPE_RECIPIENT_DEVICE | ((uint32_t)USB_REQ_SET_CONFIGURATION << 8):
/* Handling configuration selection from the host.*/ /* Handling configuration selection from the host only if it is different
usbp->configuration = usbp->setup[2]; from the current configuration.*/
if (usbp->configuration == 0U) { 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) { if (usbp->state == USB_ACTIVE) {
/* Current configuration cleared.*/
chSysLockFromISR (); chSysLockFromISR ();
usbDisableEndpointsI(usbp); usbDisableEndpointsI(usbp);
chSysUnlockFromISR (); chSysUnlockFromISR ();
usbp->configuration = 0U;
usbp->state = USB_SELECTED; usbp->state = USB_SELECTED;
_usb_isr_invoke_event_cb(usbp, USB_EVENT_UNCONFIGURED); _usb_isr_invoke_event_cb(usbp, USB_EVENT_UNCONFIGURED);
} }
} if (usbp->setup[2] != 0U) {
else { /* New configuration.*/
if (usbp->state != USB_ACTIVE) { usbp->configuration = usbp->setup[2];
usbp->state = USB_ACTIVE; usbp->state = USB_ACTIVE;
_usb_isr_invoke_event_cb(usbp, USB_EVENT_CONFIGURED); _usb_isr_invoke_event_cb(usbp, USB_EVENT_CONFIGURED);
} }