Oops - with new changes to the way the device Configuration Descriptor is retrieved...
[pub/USBasp.git] / LUFA / Drivers / USB / LowLevel / Template / Template_Endpoint_Control_R.c
1 uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
2 {
3 uint8_t* DataStream = (uint8_t*)(Buffer + TEMPLATE_BUFFER_OFFSET(Length));
4
5 while (Length)
6 {
7 if (Endpoint_IsSETUPReceived())
8 return ENDPOINT_RWCSTREAM_HostAborted;
9
10 if (USB_DeviceState == DEVICE_STATE_Unattached)
11 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
12
13 if (Endpoint_IsOUTReceived())
14 {
15 while (Length && Endpoint_BytesInEndpoint())
16 {
17 TEMPLATE_TRANSFER_BYTE(DataStream);
18 Length--;
19 }
20
21 Endpoint_ClearOUT();
22 }
23 }
24
25 while (!(Endpoint_IsINReady()))
26 {
27 if (USB_DeviceState == DEVICE_STATE_Unattached)
28 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
29 }
30
31 return ENDPOINT_RWCSTREAM_NoError;
32 }
33
34
35 #undef TEMPLATE_BUFFER_OFFSET
36 #undef TEMPLATE_FUNC_NAME
37 #undef TEMPLATE_TRANSFER_BYTE