Fix documentation glitches from the restructuring changes.
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / Template / Template_Endpoint_Control_R.c
1 uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,
2 uint16_t Length)
3 {
4 uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
5
6 if (!(Length))
7 Endpoint_ClearOUT();
8
9 while (Length)
10 {
11 uint8_t USB_DeviceState_LCL = USB_DeviceState;
12
13 if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
14 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
15 else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
16 return ENDPOINT_RWCSTREAM_BusSuspended;
17 else if (Endpoint_IsSETUPReceived())
18 return ENDPOINT_RWCSTREAM_HostAborted;
19
20 if (Endpoint_IsOUTReceived())
21 {
22 while (Length && Endpoint_BytesInEndpoint())
23 {
24 TEMPLATE_TRANSFER_BYTE(DataStream);
25 TEMPLATE_BUFFER_MOVE(DataStream, 1);
26 Length--;
27 }
28
29 Endpoint_ClearOUT();
30 }
31 }
32
33 while (!(Endpoint_IsINReady()))
34 {
35 uint8_t USB_DeviceState_LCL = USB_DeviceState;
36
37 if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)
38 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
39 else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)
40 return ENDPOINT_RWCSTREAM_BusSuspended;
41 }
42
43 return ENDPOINT_RWCSTREAM_NoError;
44 }
45
46
47 #undef TEMPLATE_BUFFER_OFFSET
48 #undef TEMPLATE_BUFFER_MOVE
49 #undef TEMPLATE_FUNC_NAME
50 #undef TEMPLATE_TRANSFER_BYTE