aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/usb.c
diff options
context:
space:
mode:
authorlbednarz <lbednarz@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-04-02 18:26:14 +0000
committerlbednarz <lbednarz@35acf78f-673a-0410-8e92-d51de3d6d3f4>2014-04-02 18:26:14 +0000
commit56f18ed54da774cf8c7527545812be6a7cdb28fa (patch)
tree693eb920e73c4c0b4b03026b4c81fa995fd6ac77 /os/hal/src/usb.c
parent6a62119514c225b0d26e4c356c45dd4ea6466e9f (diff)
downloadChibiOS-56f18ed54da774cf8c7527545812be6a7cdb28fa.tar.gz
ChibiOS-56f18ed54da774cf8c7527545812be6a7cdb28fa.tar.bz2
ChibiOS-56f18ed54da774cf8c7527545812be6a7cdb28fa.zip
merged RX stuff
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@6831 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/usb.c')
-rw-r--r--os/hal/src/usb.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/os/hal/src/usb.c b/os/hal/src/usb.c
index 1da532abf..55ae89d84 100644
--- a/os/hal/src/usb.c
+++ b/os/hal/src/usb.c
@@ -627,7 +627,13 @@ 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().*/
@@ -649,10 +655,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);
chSysLockFromIsr();
usbStartReceiveI(usbp, 0);
chSysUnlockFromIsr();
+#else
+ usbSetupEnd(usbp, ep);
+#endif
}
}
else {
@@ -669,10 +679,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);
chSysLockFromIsr();
usbStartTransmitI(usbp, 0);
chSysUnlockFromIsr();
+#else
+ usbSetupEnd(usbp, ep);
+#endif
}
}
}
@@ -709,10 +723,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);
chSysLockFromIsr();
usbStartReceiveI(usbp, 0);
chSysUnlockFromIsr();
+#else
+ usbSetupEnd(usbp, ep);
+#endif
return;
case USB_EP0_SENDING_STS:
/* Status packet sent, invoking the callback if defined.*/
@@ -749,16 +767,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);
chSysLockFromIsr();
usbStartTransmitI(usbp, 0);
chSysUnlockFromIsr();
+#else
+ usbSetupEnd(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;