Added incomplete MIDIToneGenerator project.
[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 if (!(Length))
6 Endpoint_ClearOUT();
7
8 while (Length)
9 {
10 if (Endpoint_IsSETUPReceived())
11 return ENDPOINT_RWCSTREAM_HostAborted;
12
13 if (USB_DeviceState == DEVICE_STATE_Unattached)
14 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
15
16 if (Endpoint_IsOUTReceived())
17 {
18 while (Length && Endpoint_BytesInEndpoint())
19 {
20 TEMPLATE_TRANSFER_BYTE(DataStream);
21 Length--;
22 }
23
24 Endpoint_ClearOUT();
25 }
26 }
27
28 while (!(Endpoint_IsINReady()))
29 {
30 if (USB_DeviceState == DEVICE_STATE_Unattached)
31 return ENDPOINT_RWCSTREAM_DeviceDisconnected;
32 }
33
34 return ENDPOINT_RWCSTREAM_NoError;
35 }
36
37
38 #undef TEMPLATE_BUFFER_OFFSET
39 #undef TEMPLATE_FUNC_NAME
40 #undef TEMPLATE_TRANSFER_BYTE