aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Endpoint.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-28 13:39:08 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-28 13:39:08 +0000
commitf1076ac4d6e56bff7fb6d2126746af1108211370 (patch)
tree9a5f31cc5ff9c648d7ce63f1d9e8afab763d2801 /LUFA/Drivers/USB/LowLevel/Endpoint.c
parent3cbdcd36868693cfc1863231a1ec64507ce3d29f (diff)
downloadlufa-f1076ac4d6e56bff7fb6d2126746af1108211370.tar.gz
lufa-f1076ac4d6e56bff7fb6d2126746af1108211370.tar.bz2
lufa-f1076ac4d6e56bff7fb6d2126746af1108211370.zip
Added const modifiers to device mode class drivers.
Added parameter directions to function parameter documentation. Added new experimental FAST_STREAM_FUNCTIONS compile time option to speed up stream transfers at the expense of a higher FLASH consumption (needs testing to verify improved throughput).
Diffstat (limited to 'LUFA/Drivers/USB/LowLevel/Endpoint.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Endpoint.c208
1 files changed, 204 insertions, 4 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Endpoint.c b/LUFA/Drivers/USB/LowLevel/Endpoint.c
index dca755497..1ff66ddfa 100644
--- a/LUFA/Drivers/USB/LowLevel/Endpoint.c
+++ b/LUFA/Drivers/USB/LowLevel/Endpoint.c
@@ -119,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()))
@@ -155,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()))
@@ -175,7 +255,7 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
Length--;
}
}
-
+
return ENDPOINT_RWSTREAM_NoError;
}
@@ -191,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()))
@@ -211,7 +331,7 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
Length--;
}
}
-
+
return ENDPOINT_RWSTREAM_NoError;
}
@@ -227,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()))
@@ -247,7 +407,7 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
Length--;
}
}
-
+
return ENDPOINT_RWSTREAM_NoError;
}
@@ -263,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()))
@@ -283,7 +483,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
Length--;
}
}
-
+
return ENDPOINT_RWSTREAM_NoError;
}
#endif