2011-02-13 22:27:24 +01:00
|
|
|
uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,
|
2011-01-10 19:43:34 +01:00
|
|
|
uint16_t Length,
|
|
|
|
uint16_t* const BytesProcessed)
|
2010-05-08 05:12:14 +02:00
|
|
|
{
|
2011-01-10 19:43:34 +01:00
|
|
|
uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));
|
|
|
|
uint16_t BytesInTransfer = 0;
|
2010-05-08 05:12:14 +02:00
|
|
|
uint8_t ErrorCode;
|
2010-10-13 16:05:35 +02:00
|
|
|
|
2010-05-08 05:12:14 +02:00
|
|
|
Pipe_SetPipeToken(TEMPLATE_TOKEN);
|
|
|
|
|
|
|
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
|
|
|
return ErrorCode;
|
|
|
|
|
2011-01-10 19:43:34 +01:00
|
|
|
if (BytesProcessed != NULL)
|
|
|
|
{
|
|
|
|
Length -= *BytesProcessed;
|
|
|
|
TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);
|
|
|
|
}
|
|
|
|
|
2010-05-08 05:12:14 +02:00
|
|
|
while (Length)
|
|
|
|
{
|
|
|
|
if (!(Pipe_IsReadWriteAllowed()))
|
|
|
|
{
|
|
|
|
TEMPLATE_CLEAR_PIPE();
|
|
|
|
|
2011-01-10 19:43:34 +01:00
|
|
|
if (BytesProcessed != NULL)
|
|
|
|
{
|
|
|
|
*BytesProcessed += BytesInTransfer;
|
|
|
|
return PIPE_RWSTREAM_IncompleteTransfer;
|
|
|
|
}
|
2010-05-08 05:12:14 +02:00
|
|
|
|
|
|
|
if ((ErrorCode = Pipe_WaitUntilReady()))
|
|
|
|
return ErrorCode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TEMPLATE_TRANSFER_BYTE(DataStream);
|
2011-01-10 19:43:34 +01:00
|
|
|
TEMPLATE_BUFFER_MOVE(DataStream, 1);
|
2010-05-08 05:12:14 +02:00
|
|
|
Length--;
|
2011-01-10 19:43:34 +01:00
|
|
|
BytesInTransfer++;
|
2010-05-08 05:12:14 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-13 16:05:35 +02:00
|
|
|
|
2010-05-08 05:12:14 +02:00
|
|
|
return PIPE_RWSTREAM_NoError;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef TEMPLATE_FUNC_NAME
|
|
|
|
#undef TEMPLATE_BUFFER_TYPE
|
|
|
|
#undef TEMPLATE_TOKEN
|
|
|
|
#undef TEMPLATE_TRANSFER_BYTE
|
|
|
|
#undef TEMPLATE_CLEAR_PIPE
|
|
|
|
#undef TEMPLATE_BUFFER_OFFSET
|
2011-01-10 19:43:34 +01:00
|
|
|
#undef TEMPLATE_BUFFER_MOVE
|