|
|
@ -290,7 +290,9 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t* DataStream = (uint8_t*)Buffer;
|
|
|
|
uint8_t* DataStream = (uint8_t*)Buffer;
|
|
|
|
bool LastPacketFull = false;
|
|
|
|
bool LastPacketFull = false;
|
|
|
|
bool ShortTransfer = (Length < USB_ControlRequest.wLength);
|
|
|
|
|
|
|
|
|
|
|
|
if (Length > USB_ControlRequest.wLength)
|
|
|
|
|
|
|
|
Length = USB_ControlRequest.wLength;
|
|
|
|
|
|
|
|
|
|
|
|
while (Length && !(Endpoint_IsOUTReceived()))
|
|
|
|
while (Length && !(Endpoint_IsOUTReceived()))
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -309,7 +311,7 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
|
|
|
|
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
|
|
|
|
|
|
|
|
|
|
|
|
if (LastPacketFull || ShortTransfer)
|
|
|
|
if (LastPacketFull)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
Endpoint_ClearIN();
|
|
|
@ -324,12 +326,14 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);
|
|
|
|
uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);
|
|
|
|
bool LastPacketFull = false;
|
|
|
|
bool LastPacketFull = false;
|
|
|
|
bool ShortTransfer = (Length < USB_ControlRequest.wLength);
|
|
|
|
|
|
|
|
|
|
|
|
if (Length > USB_ControlRequest.wLength)
|
|
|
|
|
|
|
|
Length = USB_ControlRequest.wLength;
|
|
|
|
|
|
|
|
|
|
|
|
while (Length && !(Endpoint_IsOUTReceived()))
|
|
|
|
while (Length && !(Endpoint_IsOUTReceived()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
if (Endpoint_IsINReady())
|
|
|
|
|
|
|
|
{
|
|
|
|
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
|
|
|
|
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Endpoint_Write_Byte(*(DataStream--));
|
|
|
|
Endpoint_Write_Byte(*(DataStream--));
|
|
|
@ -339,11 +343,12 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
|
|
|
|
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
|
|
|
|
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
|
|
|
|
return ENDPOINT_RWCSTREAM_ERROR_HostAborted;
|
|
|
|
|
|
|
|
|
|
|
|
if (LastPacketFull || ShortTransfer)
|
|
|
|
if (LastPacketFull)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
Endpoint_ClearIN();
|
|
|
|
Endpoint_ClearIN();
|
|
|
@ -360,8 +365,8 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
|
|
|
|
|
|
|
|
|
|
|
|
while (Length)
|
|
|
|
while (Length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!(Endpoint_IsOUTReceived()));
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
|
|
|
|
{
|
|
|
|
while (Length && Endpoint_BytesInEndpoint())
|
|
|
|
while (Length && Endpoint_BytesInEndpoint())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*(DataStream++) = Endpoint_Read_Byte();
|
|
|
|
*(DataStream++) = Endpoint_Read_Byte();
|
|
|
@ -370,6 +375,7 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
|
|
|
|
|
|
|
@ -382,8 +388,8 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
|
|
|
|
|
|
|
|
|
|
|
|
while (Length)
|
|
|
|
while (Length)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (!(Endpoint_IsOUTReceived()));
|
|
|
|
if (Endpoint_IsOUTReceived())
|
|
|
|
|
|
|
|
{
|
|
|
|
while (Length && Endpoint_BytesInEndpoint())
|
|
|
|
while (Length && Endpoint_BytesInEndpoint())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
*(DataStream--) = Endpoint_Read_Byte();
|
|
|
|
*(DataStream--) = Endpoint_Read_Byte();
|
|
|
@ -392,6 +398,7 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
Endpoint_ClearOUT();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
while (!(Endpoint_IsINReady()));
|
|
|
|
|
|
|
|
|
|
|
|