Oops - fix type preventing compilation of demos using the class drivers.
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / Template / Template_Endpoint_RW.c
1 uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE Buffer,
2 uint16_t Length
3 __CALLBACK_PARAM)
4 {
5 uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
6 uint8_t ErrorCode;
7
8 if ((ErrorCode = Endpoint_WaitUntilReady()))
9 return ErrorCode;
10
11 while (Length)
12 {
13 if (!(Endpoint_IsReadWriteAllowed()))
14 {
15 TEMPLATE_CLEAR_ENDPOINT();
16
17 #if !defined(NO_STREAM_CALLBACKS)
18 if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
19 return ENDPOINT_RWSTREAM_CallbackAborted;
20 #endif
21
22 if ((ErrorCode = Endpoint_WaitUntilReady()))
23 return ErrorCode;
24 }
25 else
26 {
27 TEMPLATE_TRANSFER_BYTE(DataStream);
28 Length--;
29 }
30 }
31
32 return ENDPOINT_RWSTREAM_NoError;
33 }
34
35 #undef TEMPLATE_FUNC_NAME
36 #undef TEMPLATE_BUFFER_TYPE
37 #undef TEMPLATE_TRANSFER_BYTE
38 #undef TEMPLATE_CLEAR_ENDPOINT
39 #undef TEMPLATE_BUFFER_OFFSET