uint8_t Pipe_Discard_Stream(uint16_t Length #if !defined(NO_STREAM_CALLBACKS) , uint8_t (* const Callback)(void) #endif ) { uint8_t ErrorCode; if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; while (Length--) { if (!(Pipe_ReadWriteAllowed())) { Pipe_ClearCurrentBank(); #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) return PIPE_RWSTREAM_ERROR_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; } Pipe_Discard_Byte(); } return PIPE_RWSTREAM_ERROR_NoError; }
uint8_t Pipe_Discard_Stream(uint16_t Length, uint16_t* const BytesProcessed) { uint8_t ErrorCode; uint16_t BytesInTransfer = 0; Pipe_SetPipeToken(PIPE_TOKEN_IN); if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; if (BytesProcessed != NULL) Length -= *BytesProcessed; while (Length) { if (!(Pipe_IsReadWriteAllowed())) { Pipe_ClearIN(); if (BytesProcessed != NULL) { *BytesProcessed += BytesInTransfer; return PIPE_RWSTREAM_IncompleteTransfer; } if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; } else { Pipe_Discard_Byte(); Length--; BytesInTransfer++; } } return PIPE_RWSTREAM_NoError; }
uint8_t Pipe_Discard_Stream(uint16_t Length #if !defined(NO_STREAM_CALLBACKS) , StreamCallbackPtr_t Callback #endif ) { uint8_t ErrorCode; Pipe_SetPipeToken(PIPE_TOKEN_IN); if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; #if defined(FAST_STREAM_TRANSFERS) uint8_t BytesRemToAlignment = (Pipe_BytesInPipe() & 0x07); if (Length >= 8) { Length -= BytesRemToAlignment; switch (BytesRemToAlignment) { default: do { if (!(Pipe_IsReadWriteAllowed())) { Pipe_ClearIN(); #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; } Length -= 8; Pipe_Discard_Byte(); case 7: Pipe_Discard_Byte(); case 6: Pipe_Discard_Byte(); case 5: Pipe_Discard_Byte(); case 4: Pipe_Discard_Byte(); case 3: Pipe_Discard_Byte(); case 2: Pipe_Discard_Byte(); case 1: Pipe_Discard_Byte(); } while (Length >= 8); } } #endif while (Length) { if (!(Pipe_IsReadWriteAllowed())) { Pipe_ClearIN(); #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; } else { Pipe_Discard_Byte(); Length--; } } return PIPE_RWSTREAM_NoError; }