aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB/LowLevel/Pipe.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/Pipe.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/Pipe.c')
-rw-r--r--LUFA/Drivers/USB/LowLevel/Pipe.c200
1 files changed, 200 insertions, 0 deletions
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c
index 1376de495..ab092796c 100644
--- a/LUFA/Drivers/USB/LowLevel/Pipe.c
+++ b/LUFA/Drivers/USB/LowLevel/Pipe.c
@@ -120,6 +120,46 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length
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_ClearOUT();
+
+ #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_Write_Byte(*(DataStream++));
+ case 7: Pipe_Write_Byte(*(DataStream++));
+ case 6: Pipe_Write_Byte(*(DataStream++));
+ case 5: Pipe_Write_Byte(*(DataStream++));
+ case 4: Pipe_Write_Byte(*(DataStream++));
+ case 3: Pipe_Write_Byte(*(DataStream++));
+ case 2: Pipe_Write_Byte(*(DataStream++));
+ case 1: Pipe_Write_Byte(*(DataStream++));
+ } while (Length >= 8);
+ }
+ }
+ #endif
+
while (Length)
{
if (!(Pipe_IsReadWriteAllowed()))
@@ -158,6 +198,46 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length
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_ClearOUT();
+
+ #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_Write_Byte(*(DataStream--));
+ case 7: Pipe_Write_Byte(*(DataStream--));
+ case 6: Pipe_Write_Byte(*(DataStream--));
+ case 5: Pipe_Write_Byte(*(DataStream--));
+ case 4: Pipe_Write_Byte(*(DataStream--));
+ case 3: Pipe_Write_Byte(*(DataStream--));
+ case 2: Pipe_Write_Byte(*(DataStream--));
+ case 1: Pipe_Write_Byte(*(DataStream--));
+ } while (Length >= 8);
+ }
+ }
+ #endif
+
while (Length)
{
if (!(Pipe_IsReadWriteAllowed()))
@@ -195,6 +275,46 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
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()))
@@ -233,6 +353,46 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length
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;
+
+ *(DataStream++) = Pipe_Read_Byte();
+ case 7: *(DataStream++) = Pipe_Read_Byte();
+ case 6: *(DataStream++) = Pipe_Read_Byte();
+ case 5: *(DataStream++) = Pipe_Read_Byte();
+ case 4: *(DataStream++) = Pipe_Read_Byte();
+ case 3: *(DataStream++) = Pipe_Read_Byte();
+ case 2: *(DataStream++) = Pipe_Read_Byte();
+ case 1: *(DataStream++) = Pipe_Read_Byte();
+ } while (Length >= 8);
+ }
+ }
+ #endif
+
while (Length)
{
if (!(Pipe_IsReadWriteAllowed()))
@@ -271,6 +431,46 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length
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;
+
+ *(DataStream--) = Pipe_Read_Byte();
+ case 7: *(DataStream--) = Pipe_Read_Byte();
+ case 6: *(DataStream--) = Pipe_Read_Byte();
+ case 5: *(DataStream--) = Pipe_Read_Byte();
+ case 4: *(DataStream--) = Pipe_Read_Byte();
+ case 3: *(DataStream--) = Pipe_Read_Byte();
+ case 2: *(DataStream--) = Pipe_Read_Byte();
+ case 1: *(DataStream--) = Pipe_Read_Byte();
+ } while (Length >= 8);
+ }
+ }
+ #endif
+
while (Length)
{
if (!(Pipe_IsReadWriteAllowed()))