\r
uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)\r
{\r
- uint8_t* DataStream = (uint8_t*)Buffer;\r
- bool SendZLP = true;\r
+ uint8_t* DataStream = (uint8_t*)Buffer;\r
+ bool LastPacketFull = false;\r
+ bool ShortTransfer = (Length < USB_ControlRequest.wLength);\r
\r
while (Length && !(Endpoint_IsOUTReceived()))\r
{\r
Length--;\r
}\r
\r
- SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+ LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
Endpoint_ClearIN();\r
}\r
\r
if (Endpoint_IsOUTReceived())\r
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
\r
- if (SendZLP)\r
+ if (LastPacketFull || ShortTransfer)\r
{\r
while (!(Endpoint_IsINReady()));\r
Endpoint_ClearIN();\r
\r
uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)\r
{\r
- uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
- bool SendZLP = true;\r
+ uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);\r
+ bool LastPacketFull = false;\r
+ bool ShortTransfer = (Length < USB_ControlRequest.wLength);\r
\r
while (Length && !(Endpoint_IsOUTReceived()))\r
{\r
Length--;\r
}\r
\r
- SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
+ LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);\r
Endpoint_ClearIN();\r
}\r
\r
if (Endpoint_IsOUTReceived())\r
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;\r
\r
- if (SendZLP)\r
+ if (LastPacketFull || ShortTransfer)\r
{\r
while (!(Endpoint_IsINReady()));\r
Endpoint_ClearIN();\r