1 uint8_t TEMPLATE_FUNC_NAME (void* Buffer
, uint16_t Length
)
3 uint8_t* DataStream
= (uint8_t*)(Buffer
+ TEMPLATE_BUFFER_OFFSET(Length
));
4 bool LastPacketFull
= false;
6 if (Length
> USB_ControlRequest
.wLength
)
7 Length
= USB_ControlRequest
.wLength
;
9 while (Length
|| LastPacketFull
)
11 if (Endpoint_IsSETUPReceived())
12 return ENDPOINT_RWCSTREAM_HostAborted
;
14 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
15 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
17 if (Endpoint_IsOUTReceived())
19 LastPacketFull
= (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize
);
21 while (Length
&& Endpoint_BytesInEndpoint())
23 TEMPLATE_TRANSFER_BYTE(DataStream
);
29 if (!(LastPacketFull
))
34 while (!(Endpoint_IsINReady()))
36 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
37 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
40 return ENDPOINT_RWCSTREAM_NoError
;
44 #undef TEMPLATE_BUFFER_OFFSET
45 #undef TEMPLATE_FUNC_NAME
46 #undef TEMPLATE_TRANSFER_BYTE