More XMEGA USB AVR device port work - re-add missing Endpoint stream functions, remov...
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 14 Jul 2011 07:28:32 +0000 (07:28 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 14 Jul 2011 07:28:32 +0000 (07:28 +0000)
LUFA/Drivers/USB/Core/XMEGA/Device_XMEGA.c
LUFA/Drivers/USB/Core/XMEGA/EndpointStream_XMEGA.c
LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h

index 1294814..55598ff 100644 (file)
@@ -37,7 +37,7 @@
 \r
 void USB_Device_SendRemoteWakeup(void)\r
 {\r
-       // TODO\r
+       USB.CTRLB |= USB_RWAKEUP_bm;\r
 }\r
 \r
 #endif\r
index 9a0a195..b1b05bf 100644 (file)
 uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
                                 uint16_t* const BytesProcessed)\r
 {\r
-       return 0; // TODO\r
+       uint8_t  ErrorCode;\r
+       uint16_t BytesInTransfer = 0;\r
+       \r
+       if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+         return ErrorCode;\r
+         \r
+       if (BytesProcessed != NULL)\r
+         Length -= *BytesProcessed;\r
+\r
+       while (Length)\r
+       {\r
+               if (!(Endpoint_IsReadWriteAllowed()))\r
+               {\r
+                       Endpoint_ClearOUT();\r
+\r
+                       if (BytesProcessed != NULL)\r
+                       {\r
+                               *BytesProcessed += BytesInTransfer;\r
+                               return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+                       }\r
+\r
+                       if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                         return ErrorCode;\r
+               }\r
+               else\r
+               {\r
+                       Endpoint_Discard_8();\r
+\r
+                       Length--;\r
+                       BytesInTransfer++;\r
+               }\r
+       }\r
+       \r
+       return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 \r
 uint8_t Endpoint_Null_Stream(uint16_t Length,\r
                              uint16_t* const BytesProcessed)\r
 {\r
-       return 0; // TODO\r
+       uint8_t  ErrorCode;\r
+       uint16_t BytesInTransfer = 0;\r
+       \r
+       if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+         return ErrorCode;\r
+         \r
+       if (BytesProcessed != NULL)\r
+         Length -= *BytesProcessed;\r
+\r
+       while (Length)\r
+       {\r
+               if (!(Endpoint_IsReadWriteAllowed()))\r
+               {\r
+                       Endpoint_ClearIN();\r
+\r
+                       if (BytesProcessed != NULL)\r
+                       {\r
+                               *BytesProcessed += BytesInTransfer;\r
+                               return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+                       }\r
+\r
+                       if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+                         return ErrorCode;\r
+               }\r
+               else\r
+               {\r
+                       Endpoint_Write_8(0);\r
+\r
+                       Length--;\r
+                       BytesInTransfer++;\r
+               }\r
+       }\r
+       \r
+       return ENDPOINT_RWSTREAM_NoError;\r
 }\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Stream_LE\r
index c444433..3ed603d 100644 (file)
 \r
                        #define ENDPOINT_DETAILS_MAXEP                 16\r
 \r
-               /* Inline Functions: */\r
-                       static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
-                                                                                              ATTR_ALWAYS_INLINE;\r
-                       static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
-                       {\r
-                               return 0; // TODO\r
-                       }\r
-\r
                /* Function Prototypes: */\r
                        void Endpoint_ClearEndpoints(void);\r
                        bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r