X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/d860e9e842c05e759214f5170f78783decae9956..e6881fd166586793a5a90effeefe4188092f383b:/LUFA/Drivers/USB/LowLevel/Pipe.c diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index ff4318c99..3c493fe5a 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -70,9 +70,11 @@ void Pipe_ClearPipes(void) uint8_t Pipe_WaitUntilReady(void) { + #if (USB_STREAM_TIMEOUT_MS < 0xFF) + uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; + #else uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; - - USB_INT_Clear(USB_INT_HSOFI); + #endif for (;;) { @@ -104,7 +106,7 @@ uint8_t Pipe_WaitUntilReady(void) uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) - , uint8_t (* const Callback)(void) + , StreamCallbackPtr_t Callback #endif ) { @@ -114,7 +116,7 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; - while (Length--) + while (Length) { if (!(Pipe_IsReadWriteAllowed())) { @@ -122,7 +124,7 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) - return PIPE_RWSTREAM_ERROR_CallbackAborted; + return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) @@ -131,15 +133,16 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length else { Pipe_Write_Byte(*(DataStream++)); + Length--; } } - return PIPE_RWSTREAM_ERROR_NoError; + return PIPE_RWSTREAM_NoError; } uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) - , uint8_t (* const Callback)(void) + , StreamCallbackPtr_t Callback #endif ) { @@ -149,7 +152,7 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; - while (Length--) + while (Length) { if (!(Pipe_IsReadWriteAllowed())) { @@ -157,7 +160,7 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) - return PIPE_RWSTREAM_ERROR_CallbackAborted; + return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) @@ -166,15 +169,16 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length else { Pipe_Write_Byte(*(DataStream--)); + Length--; } } - return PIPE_RWSTREAM_ERROR_NoError; + return PIPE_RWSTREAM_NoError; } uint8_t Pipe_Discard_Stream(uint16_t Length #if !defined(NO_STREAM_CALLBACKS) - , uint8_t (* const Callback)(void) + , StreamCallbackPtr_t Callback #endif ) { @@ -183,7 +187,7 @@ uint8_t Pipe_Discard_Stream(uint16_t Length if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; - while (Length--) + while (Length) { if (!(Pipe_IsReadWriteAllowed())) { @@ -191,7 +195,7 @@ uint8_t Pipe_Discard_Stream(uint16_t Length #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) - return PIPE_RWSTREAM_ERROR_CallbackAborted; + return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) @@ -200,15 +204,16 @@ uint8_t Pipe_Discard_Stream(uint16_t Length else { Pipe_Discard_Byte(); + Length--; } } - return PIPE_RWSTREAM_ERROR_NoError; + return PIPE_RWSTREAM_NoError; } uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) - , uint8_t (* const Callback)(void) + , StreamCallbackPtr_t Callback #endif ) { @@ -218,7 +223,7 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; - while (Length--) + while (Length) { if (!(Pipe_IsReadWriteAllowed())) { @@ -226,7 +231,7 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) - return PIPE_RWSTREAM_ERROR_CallbackAborted; + return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) @@ -235,15 +240,16 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length else { *(DataStream++) = Pipe_Read_Byte(); + Length--; } } - return PIPE_RWSTREAM_ERROR_NoError; + return PIPE_RWSTREAM_NoError; } uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) - , uint8_t (* const Callback)(void) + , StreamCallbackPtr_t Callback #endif ) { @@ -253,7 +259,7 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length if ((ErrorCode = Pipe_WaitUntilReady())) return ErrorCode; - while (Length--) + while (Length) { if (!(Pipe_IsReadWriteAllowed())) { @@ -261,7 +267,7 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length #if !defined(NO_STREAM_CALLBACKS) if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) - return PIPE_RWSTREAM_ERROR_CallbackAborted; + return PIPE_RWSTREAM_CallbackAborted; #endif if ((ErrorCode = Pipe_WaitUntilReady())) @@ -270,10 +276,11 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length else { *(DataStream--) = Pipe_Read_Byte(); + Length--; } } - return PIPE_RWSTREAM_ERROR_NoError; + return PIPE_RWSTREAM_NoError; } #endif