Oops - fix type preventing compilation of demos using the class drivers.
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / Template / Template_Pipe_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 Pipe_SetPipeToken(TEMPLATE_TOKEN);
9
10 if ((ErrorCode = Pipe_WaitUntilReady()))
11 return ErrorCode;
12
13 while (Length)
14 {
15 if (!(Pipe_IsReadWriteAllowed()))
16 {
17 TEMPLATE_CLEAR_PIPE();
18
19 #if !defined(NO_STREAM_CALLBACKS)
20 if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))
21 return PIPE_RWSTREAM_CallbackAborted;
22 #endif
23
24 if ((ErrorCode = Pipe_WaitUntilReady()))
25 return ErrorCode;
26 }
27 else
28 {
29 TEMPLATE_TRANSFER_BYTE(DataStream);
30 Length--;
31 }
32 }
33
34 return PIPE_RWSTREAM_NoError;
35 }
36
37 #undef TEMPLATE_FUNC_NAME
38 #undef TEMPLATE_BUFFER_TYPE
39 #undef TEMPLATE_TOKEN
40 #undef TEMPLATE_TRANSFER_BYTE
41 #undef TEMPLATE_CLEAR_PIPE
42 #undef TEMPLATE_BUFFER_OFFSET
43