Added const modifiers to device mode class drivers.
[pub/lufa.git] / LUFA / Drivers / USB / LowLevel / Endpoint.c
index dca7554..1ff66dd 100644 (file)
@@ -119,6 +119,46 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
        if ((ErrorCode = Endpoint_WaitUntilReady()))\r
          return ErrorCode;\r
 \r
+       #if defined(FAST_STREAM_TRANSFERS)\r
+       uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07);\r
+\r
+       if (Length >= 8)\r
+       {\r
+               Length -= BytesRemToAlignment;\r
+\r
+               switch (BytesRemToAlignment)\r
+               {\r
+                       default:\r
+                               do\r
+                               {\r
+                                       if (!(Endpoint_IsReadWriteAllowed()))\r
+                                       {\r
+                                               Endpoint_ClearOUT();\r
+\r
+                                               #if !defined(NO_STREAM_CALLBACKS)\r
+                                               if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+                                                 return ENDPOINT_RWSTREAM_CallbackAborted;\r
+                                               #endif\r
+\r
+                                               if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                                                 return ErrorCode;\r
+                                       }\r
+\r
+                                       Length -= 8;\r
+                                       \r
+                                       Endpoint_Discard_Byte();\r
+                       case 7: Endpoint_Discard_Byte();\r
+                       case 6: Endpoint_Discard_Byte();\r
+                       case 5: Endpoint_Discard_Byte();\r
+                       case 4: Endpoint_Discard_Byte();\r
+                       case 3: Endpoint_Discard_Byte();\r
+                       case 2: Endpoint_Discard_Byte();\r
+                       case 1: Endpoint_Discard_Byte();\r
+                               } while (Length >= 8);  \r
+               }\r
+       }\r
+       #endif\r
+\r
        while (Length)\r
        {\r
                if (!(Endpoint_IsReadWriteAllowed()))\r
@@ -155,6 +195,46 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
        if ((ErrorCode = Endpoint_WaitUntilReady()))\r
          return ErrorCode;\r
 \r
+       #if defined(FAST_STREAM_TRANSFERS)\r
+       uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07);\r
+\r
+       if (Length >= 8)\r
+       {\r
+               Length -= BytesRemToAlignment;\r
+\r
+               switch (BytesRemToAlignment)\r
+               {\r
+                       default:\r
+                               do\r
+                               {\r
+                                       if (!(Endpoint_IsReadWriteAllowed()))\r
+                                       {\r
+                                               Endpoint_ClearIN();\r
+\r
+                                               #if !defined(NO_STREAM_CALLBACKS)\r
+                                               if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+                                                 return ENDPOINT_RWSTREAM_CallbackAborted;\r
+                                               #endif\r
+\r
+                                               if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                                                 return ErrorCode;\r
+                                       }\r
+\r
+                                       Length -= 8;\r
+                                       \r
+                                       Endpoint_Write_Byte(*(DataStream++));\r
+                       case 7: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 6: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 5: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 4: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 3: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 2: Endpoint_Write_Byte(*(DataStream++));\r
+                       case 1: Endpoint_Write_Byte(*(DataStream++));\r
+                               } while (Length >= 8);  \r
+               }\r
+       }\r
+       #endif\r
+\r
        while (Length)\r
        {\r
                if (!(Endpoint_IsReadWriteAllowed()))\r
@@ -175,7 +255,7 @@ uint8_t Endpoint_Write_Stream_LE(const void* Buffer, uint16_t Length
                        Length--;\r
                }\r
        }\r
-       \r
+\r
        return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 \r
@@ -191,6 +271,46 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
        if ((ErrorCode = Endpoint_WaitUntilReady()))\r
          return ErrorCode;\r
 \r
+       #if defined(FAST_STREAM_TRANSFERS)\r
+       uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07);\r
+\r
+       if (Length >= 8)\r
+       {\r
+               Length -= BytesRemToAlignment;\r
+\r
+               switch (BytesRemToAlignment)\r
+               {\r
+                       default:\r
+                               do\r
+                               {\r
+                                       if (!(Endpoint_IsReadWriteAllowed()))\r
+                                       {\r
+                                               Endpoint_ClearIN();\r
+\r
+                                               #if !defined(NO_STREAM_CALLBACKS)\r
+                                               if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+                                                 return ENDPOINT_RWSTREAM_CallbackAborted;\r
+                                               #endif\r
+\r
+                                               if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                                                 return ErrorCode;\r
+                                       }\r
+\r
+                                       Length -= 8;\r
+                                       \r
+                                       Endpoint_Write_Byte(*(DataStream--));\r
+                       case 7: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 6: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 5: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 4: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 3: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 2: Endpoint_Write_Byte(*(DataStream--));\r
+                       case 1: Endpoint_Write_Byte(*(DataStream--));\r
+                               } while (Length >= 8);  \r
+               }\r
+       }\r
+       #endif\r
+\r
        while (Length)\r
        {\r
                if (!(Endpoint_IsReadWriteAllowed()))\r
@@ -211,7 +331,7 @@ uint8_t Endpoint_Write_Stream_BE(const void* Buffer, uint16_t Length
                        Length--;\r
                }\r
        }\r
-       \r
+\r
        return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 \r
@@ -227,6 +347,46 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
        if ((ErrorCode = Endpoint_WaitUntilReady()))\r
          return ErrorCode;\r
 \r
+       #if defined(FAST_STREAM_TRANSFERS)\r
+       uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07);\r
+\r
+       if (Length >= 8)\r
+       {\r
+               Length -= BytesRemToAlignment;\r
+\r
+               switch (BytesRemToAlignment)\r
+               {\r
+                       default:\r
+                               do\r
+                               {\r
+                                       if (!(Endpoint_IsReadWriteAllowed()))\r
+                                       {\r
+                                               Endpoint_ClearOUT();\r
+\r
+                                               #if !defined(NO_STREAM_CALLBACKS)\r
+                                               if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+                                                 return ENDPOINT_RWSTREAM_CallbackAborted;\r
+                                               #endif\r
+\r
+                                               if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                                                 return ErrorCode;\r
+                                       }\r
+\r
+                                       Length -= 8;\r
+                                       \r
+                                       *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 7: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 6: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 5: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 4: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 3: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 2: *(DataStream++) = Endpoint_Read_Byte();\r
+                       case 1: *(DataStream++) = Endpoint_Read_Byte();\r
+                               } while (Length >= 8);  \r
+               }\r
+       }\r
+       #endif\r
+\r
        while (Length)\r
        {\r
                if (!(Endpoint_IsReadWriteAllowed()))\r
@@ -247,7 +407,7 @@ uint8_t Endpoint_Read_Stream_LE(void* Buffer, uint16_t Length
                        Length--;\r
                }\r
        }\r
-       \r
+\r
        return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 \r
@@ -263,6 +423,46 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
        if ((ErrorCode = Endpoint_WaitUntilReady()))\r
          return ErrorCode;\r
 \r
+       #if defined(FAST_STREAM_TRANSFERS)\r
+       uint8_t BytesRemToAlignment = (Endpoint_BytesInEndpoint() & 0x07);\r
+\r
+       if (Length >= 8)\r
+       {\r
+               Length -= BytesRemToAlignment;\r
+\r
+               switch (BytesRemToAlignment)\r
+               {\r
+                       default:\r
+                               do\r
+                               {\r
+                                       if (!(Endpoint_IsReadWriteAllowed()))\r
+                                       {\r
+                                               Endpoint_ClearOUT();\r
+\r
+                                               #if !defined(NO_STREAM_CALLBACKS)\r
+                                               if ((Callback != NULL) && (Callback() == STREAMCALLBACK_Abort))\r
+                                                 return ENDPOINT_RWSTREAM_CallbackAborted;\r
+                                               #endif\r
+\r
+                                               if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                                                 return ErrorCode;\r
+                                       }\r
+\r
+                                       Length -= 8;\r
+                                       \r
+                                       *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 7: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 6: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 5: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 4: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 3: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 2: *(DataStream--) = Endpoint_Read_Byte();\r
+                       case 1: *(DataStream--) = Endpoint_Read_Byte();\r
+                               } while (Length >= 8);  \r
+               }\r
+       }\r
+       #endif\r
+\r
        while (Length)\r
        {\r
                if (!(Endpoint_IsReadWriteAllowed()))\r
@@ -283,7 +483,7 @@ uint8_t Endpoint_Read_Stream_BE(void* Buffer, uint16_t Length
                        Length--;\r
                }\r
        }\r
-       \r
+\r
        return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 #endif\r