aboutsummaryrefslogtreecommitdiff
path: root/LUFA/Drivers
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2009-08-05 11:39:28 +0000
committerDean Camera <[email protected]>2009-08-05 11:39:28 +0000
commit4421782b7fb49e160b1c18f2295e6cd1f0b00c04 (patch)
treed6b5007b2644ee9bf5c8bf588375158f0bab5f07 /LUFA/Drivers
parenta9d5e129b76449c73a853af450d7d353512cd3a0 (diff)
downloadqmk_firmware-4421782b7fb49e160b1c18f2295e6cd1f0b00c04.tar.gz
qmk_firmware-4421782b7fb49e160b1c18f2295e6cd1f0b00c04.zip
Make Control Endpoint stream transfers more reliable by adding in early aborts for unexpected new SETUP tokens, or unexpected status stage during control stream writes.
Fix corruption in Device RNDIS demos TCP stack when too many connections attempted simultaneously, freezing the device when a page was re-fetched before the first connection was closed. Fix incorrect model compatibility information in the Host LowLevel demo overview text files.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Endpoint.c2
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c11
-rw-r--r--LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c44
3 files changed, 26 insertions, 31 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c
index e4d01404dd..8b3922a4a8 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.c
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c
@@ -76,7 +76,7 @@ void Endpoint_ClearStatusStage(void)
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
{
while (!(Endpoint_IsOUTReceived()))
- {
+ {
if (USB_DeviceState == DEVICE_STATE_Unattached)
return;
}
diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
index b85705c226..a2a0c3bd59 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_R.c
@@ -4,6 +4,12 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
while (Length)
{
+ if (Endpoint_IsSETUPReceived())
+ return ENDPOINT_RWCSTREAM_HostAborted;
+
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+
if (Endpoint_IsOUTReceived())
{
while (Length && Endpoint_BytesInEndpoint())
@@ -13,10 +19,7 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
}
Endpoint_ClearOUT();
- }
-
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ }
}
while (!(Endpoint_IsINReady()))
diff --git a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
index 43a9f3d42c..6c1445ee0c 100644
--- a/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
+++ b/LUFA/Drivers/USB/LowLevel/Template/Template_Endpoint_Control_W.c
@@ -6,36 +6,28 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
- while (Length && !(Endpoint_IsOUTReceived()))
+ while (Length || LastPacketFull)
{
- while (!(Endpoint_IsINReady()))
- {
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
- }
-
- while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
- {
- TEMPLATE_TRANSFER_BYTE(DataStream);
- Length--;
- }
+ if (Endpoint_IsSETUPReceived())
+ return ENDPOINT_RWCSTREAM_HostAborted;
+
+ if (Endpoint_IsOUTReceived())
+ break;
- LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
- Endpoint_ClearIN();
- }
-
- if (Endpoint_IsOUTReceived())
- return ENDPOINT_RWCSTREAM_HostAborted;
-
- if (LastPacketFull)
- {
- while (!(Endpoint_IsINReady()))
+ if (USB_DeviceState == DEVICE_STATE_Unattached)
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+
+ if (Endpoint_IsINReady())
{
- if (USB_DeviceState == DEVICE_STATE_Unattached)
- return ENDPOINT_RWCSTREAM_DeviceDisconnected;
+ while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
+ {
+ TEMPLATE_TRANSFER_BYTE(DataStream);
+ Length--;
+ }
+
+ LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
+ Endpoint_ClearIN();
}
-
- Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()))