X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/eeba38e343a299e12964aec15fd43108d3dc9130..b462f2d457ec2f0cfa22a1c3db198cb22f6809a1:/LUFA/Drivers/USB/LowLevel/Endpoint.c diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c index 099022c1c..1ff66ddfa 100644 --- a/LUFA/Drivers/USB/LowLevel/Endpoint.c +++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c @@ -80,8 +80,6 @@ uint8_t Endpoint_WaitUntilReady(void) uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS; #endif - USB_INT_Clear(USB_INT_SOFI); - for (;;) { if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN) @@ -121,6 +119,46 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length if ((ErrorCode = Endpoint_WaitUntilReady())) return ErrorCode; + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + Endpoint_Discard_Byte(); + case 7: Endpoint_Discard_Byte(); + case 6: Endpoint_Discard_Byte(); + case 5: Endpoint_Discard_Byte(); + case 4: Endpoint_Discard_Byte(); + case 3: Endpoint_Discard_Byte(); + case 2: Endpoint_Discard_Byte(); + case 1: Endpoint_Discard_Byte(); + } while (Length >= 8); + } + } + #endif + while (Length) { if (!(Endpoint_IsReadWriteAllowed())) @@ -157,6 +195,46 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length if ((ErrorCode = Endpoint_WaitUntilReady())) return ErrorCode; + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + Endpoint_Write_Byte(*(DataStream++)); + case 7: Endpoint_Write_Byte(*(DataStream++)); + case 6: Endpoint_Write_Byte(*(DataStream++)); + case 5: Endpoint_Write_Byte(*(DataStream++)); + case 4: Endpoint_Write_Byte(*(DataStream++)); + case 3: Endpoint_Write_Byte(*(DataStream++)); + case 2: Endpoint_Write_Byte(*(DataStream++)); + case 1: Endpoint_Write_Byte(*(DataStream++)); + } while (Length >= 8); + } + } + #endif + while (Length) { if (!(Endpoint_IsReadWriteAllowed())) @@ -177,7 +255,7 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length Length--; } } - + return ENDPOINT_RWSTREAM_NoError; } @@ -193,6 +271,46 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length if ((ErrorCode = Endpoint_WaitUntilReady())) return ErrorCode; + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearIN(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + Endpoint_Write_Byte(*(DataStream--)); + case 7: Endpoint_Write_Byte(*(DataStream--)); + case 6: Endpoint_Write_Byte(*(DataStream--)); + case 5: Endpoint_Write_Byte(*(DataStream--)); + case 4: Endpoint_Write_Byte(*(DataStream--)); + case 3: Endpoint_Write_Byte(*(DataStream--)); + case 2: Endpoint_Write_Byte(*(DataStream--)); + case 1: Endpoint_Write_Byte(*(DataStream--)); + } while (Length >= 8); + } + } + #endif + while (Length) { if (!(Endpoint_IsReadWriteAllowed())) @@ -213,7 +331,7 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length Length--; } } - + return ENDPOINT_RWSTREAM_NoError; } @@ -229,6 +347,46 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length if ((ErrorCode = Endpoint_WaitUntilReady())) return ErrorCode; + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + *(DataStream++) = Endpoint_Read_Byte(); + case 7: *(DataStream++) = Endpoint_Read_Byte(); + case 6: *(DataStream++) = Endpoint_Read_Byte(); + case 5: *(DataStream++) = Endpoint_Read_Byte(); + case 4: *(DataStream++) = Endpoint_Read_Byte(); + case 3: *(DataStream++) = Endpoint_Read_Byte(); + case 2: *(DataStream++) = Endpoint_Read_Byte(); + case 1: *(DataStream++) = Endpoint_Read_Byte(); + } while (Length >= 8); + } + } + #endif + while (Length) { if (!(Endpoint_IsReadWriteAllowed())) @@ -249,7 +407,7 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length Length--; } } - + return ENDPOINT_RWSTREAM_NoError; } @@ -265,6 +423,46 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length if ((ErrorCode = Endpoint_WaitUntilReady())) return ErrorCode; + #if defined(FAST_STREAM_TRANSFERS) + uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07); + + if (Length >= 8) + { + Length -= BytesRemToAlignment; + + switch (BytesRemToAlignment) + { + default: + do + { + if (!(Endpoint_IsReadWriteAllowed())) + { + Endpoint_ClearOUT(); + + #if !defined(NO_STREAM_CALLBACKS) + if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort)) + return ENDPOINT_RWSTREAM_CallbackAborted; + #endif + + if ((ErrorCode = Endpoint_WaitUntilReady())) + return ErrorCode; + } + + Length -= 8; + + *(DataStream--) = Endpoint_Read_Byte(); + case 7: *(DataStream--) = Endpoint_Read_Byte(); + case 6: *(DataStream--) = Endpoint_Read_Byte(); + case 5: *(DataStream--) = Endpoint_Read_Byte(); + case 4: *(DataStream--) = Endpoint_Read_Byte(); + case 3: *(DataStream--) = Endpoint_Read_Byte(); + case 2: *(DataStream--) = Endpoint_Read_Byte(); + case 1: *(DataStream--) = Endpoint_Read_Byte(); + } while (Length >= 8); + } + } + #endif + while (Length) { if (!(Endpoint_IsReadWriteAllowed())) @@ -285,7 +483,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length Length--; } } - + return ENDPOINT_RWSTREAM_NoError; } #endif