diff options
Diffstat (limited to 'os/hal/src')
-rw-r--r-- | os/hal/src/usb.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c index a84702b5b..9b292b7d9 100644 --- a/os/hal/src/usb.c +++ b/os/hal/src/usb.c @@ -623,7 +623,12 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { return;
}
}
-
+#if (USB_SET_ADDRESS_ACK_HANDLING == USB_SET_ADDRESS_ACK_HW)
+ if (usbp->setup[1] == USB_REQ_SET_ADDRESS) {
+ /* Zero-length packet sent by hardware */
+ return;
+ }
+#endif
/* Transfer preparation. The request handler must have populated
correctly the fields ep0next, ep0n and ep0endcb using the macro
usbSetupTransfer().*/
@@ -645,10 +650,14 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { /* No transmission phase, directly receiving the zero sized status
packet.*/
usbp->ep0state = USB_EP0_WAITING_STS;
+#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareReceive(usbp, 0, NULL, 0);
osalSysLockFromISR();
usbStartReceiveI(usbp, 0);
osalSysUnlockFromISR();
+#else
+ usb_lld_end_setup(usbp, ep);
+#endif
}
}
else {
@@ -665,10 +674,14 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { /* No receive phase, directly sending the zero sized status
packet.*/
usbp->ep0state = USB_EP0_SENDING_STS;
+#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareTransmit(usbp, 0, NULL, 0);
osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
osalSysUnlockFromISR();
+#else
+ usb_lld_end_setup(usbp, ep);
+#endif
}
}
}
@@ -705,10 +718,14 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { case USB_EP0_WAITING_TX0:
/* Transmit phase over, receiving the zero sized status packet.*/
usbp->ep0state = USB_EP0_WAITING_STS;
+#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareReceive(usbp, 0, NULL, 0);
osalSysLockFromISR();
usbStartReceiveI(usbp, 0);
osalSysUnlockFromISR();
+#else
+ usb_lld_end_setup(usbp, ep);
+#endif
return;
case USB_EP0_SENDING_STS:
/* Status packet sent, invoking the callback if defined.*/
@@ -745,16 +762,22 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) { case USB_EP0_RX:
/* Receive phase over, sending the zero sized status packet.*/
usbp->ep0state = USB_EP0_SENDING_STS;
+#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
usbPrepareTransmit(usbp, 0, NULL, 0);
osalSysLockFromISR();
usbStartTransmitI(usbp, 0);
osalSysUnlockFromISR();
+#else
+ usb_lld_end_setup(usbp, ep);
+#endif
return;
case USB_EP0_WAITING_STS:
/* Status packet received, it must be zero sized, invoking the callback
if defined.*/
+#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
if (usbGetReceiveTransactionSizeI(usbp, 0) != 0)
break;
+#endif
if (usbp->ep0endcb != NULL)
usbp->ep0endcb(usbp);
usbp->ep0state = USB_EP0_WAITING_SETUP;
|