1 uint8_t TEMPLATE_FUNC_NAME (const 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
;
11 while (Length
|| LastPacketFull
)
13 if (Endpoint_IsSETUPReceived())
14 return ENDPOINT_RWCSTREAM_HostAborted
;
16 if (Endpoint_IsOUTReceived())
19 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
20 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
22 if (Endpoint_IsINReady())
24 while (Length
&& (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize
))
26 TEMPLATE_TRANSFER_BYTE(DataStream
);
30 LastPacketFull
= (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize
);
35 while (!(Endpoint_IsOUTReceived()))
37 if (USB_DeviceState
== DEVICE_STATE_Unattached
)
38 return ENDPOINT_RWCSTREAM_DeviceDisconnected
;
41 return ENDPOINT_RWCSTREAM_NoError
;
44 #undef TEMPLATE_BUFFER_OFFSET
45 #undef TEMPLATE_FUNC_NAME
46 #undef TEMPLATE_TRANSFER_BYTE