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
&& !(Endpoint_IsOUTReceived()))
11 while (!(Endpoint_IsINReady()))
13 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
14 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
17 while (Length
&& (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize
))
19 TEMPLATE_TRANSFER_BYTE(DataStream
);
23 LastPacketFull
= (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize
);
27 if (Endpoint_IsOUTReceived())
28 return ENDPOINT_RWCSTREAM_HostAborted
;
32 while (!(Endpoint_IsINReady()))
34 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
35 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
41 while (!(Endpoint_IsOUTReceived()))
43 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
44 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
47 return ENDPOINT_RWCSTREAM_NoError
;
50 #undef TEMPLATE_BUFFER_OFFSET
51 #undef TEMPLATE_FUNC_NAME
52 #undef TEMPLATE_TRANSFER_BYTE