Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should...
authorDean Camera <dean@fourwalledcubicle.com>
Mon, 25 Jan 2010 11:50:41 +0000 (11:50 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Mon, 25 Jan 2010 11:50:41 +0000 (11:50 +0000)
Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c
Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c
Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c
LUFA/Drivers/USB/Class/Host/CDC.c
LUFA/Drivers/USB/Class/Host/CDC.h
LUFA/Drivers/USB/Class/Host/RNDIS.c
LUFA/Drivers/USB/Class/Host/RNDIS.h
LUFA/ManPages/ChangeLog.txt
Projects/Incomplete/Webserver/Lib/WebserverApp.c
Projects/Incomplete/Webserver/Webserver.c

index 7078f5e..5a173d6 100644 (file)
@@ -145,10 +145,6 @@ uint8_t ProcessConfigurationDescriptor(void)
                        /* Check if the endpoint is a bulk IN or bulk OUT endpoint */\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {\r
-                               /* Kill the configured OUT pipe if the data endpoints are bidirectional */\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                                 Pipe_DisablePipe();\r
-\r
                                /* Configure the data IN pipe */\r
                                Pipe_ConfigurePipe(RNDIS_DATAPIPE_IN, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
                                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
@@ -158,13 +154,9 @@ uint8_t ProcessConfigurationDescriptor(void)
                        }\r
                        else\r
                        {\r
-                               /* Only configure the OUT data pipe if the data endpoints have not shown to be bidirectional */\r
-                               if (!(Pipe_IsEndpointBound(EndpointData->EndpointAddress)))\r
-                               {\r
-                                       /* Configure the data OUT pipe */\r
-                                       Pipe_ConfigurePipe(RNDIS_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
-                                                                          EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
-                               }\r
+                               /* Configure the data OUT pipe */\r
+                               Pipe_ConfigurePipe(RNDIS_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
+                                                                  EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
                                \r
                                /* Set the flag indicating that the data OUT pipe has been found */\r
                                FoundEndpoints |= (1 << RNDIS_DATAPIPE_OUT);\r
index c42cc0f..853ad37 100644 (file)
@@ -145,10 +145,6 @@ uint8_t ProcessConfigurationDescriptor(void)
                        /* Check if the endpoint is a bulk IN or bulk OUT endpoint */\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {\r
-                               /* Kill the configured OUT pipe if the data endpoints are bidirectional */\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                                 Pipe_DisablePipe();\r
-\r
                                /* Configure the data IN pipe */\r
                                Pipe_ConfigurePipe(CDC_DATAPIPE_IN, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
                                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
@@ -158,13 +154,9 @@ uint8_t ProcessConfigurationDescriptor(void)
                        }\r
                        else\r
                        {\r
-                               /* Only configure the OUT data pipe if the data endpoints have not shown to be bidirectional */\r
-                               if (!(Pipe_IsEndpointBound(EndpointData->EndpointAddress)))\r
-                               {\r
-                                       /* Configure the data OUT pipe */\r
-                                       Pipe_ConfigurePipe(CDC_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
-                                                                          EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
-                               }\r
+                               /* Configure the data OUT pipe */\r
+                               Pipe_ConfigurePipe(CDC_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
+                                                                  EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);\r
                                \r
                                /* Set the flag indicating that the data OUT pipe has been found */\r
                                FoundEndpoints |= (1 << CDC_DATAPIPE_OUT);\r
index 98980e8..4c521a4 100644 (file)
@@ -218,7 +218,6 @@ void CDC_Host_Task(void)
                case HOST_STATE_Configured:\r
                        /* Select the data IN pipe */\r
                        Pipe_SelectPipe(CDC_DATAPIPE_IN);\r
-                       Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
                        Pipe_Unfreeze();\r
 \r
                        /* Check to see if a packet has been received */\r
index 7f5bcb9..8ad37de 100644 (file)
@@ -110,32 +110,20 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
                {\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                               {\r
-                                       CDCInterfaceInfo->State.BidirectionalDataEndpoints = true;\r
-                                       Pipe_DisablePipe();\r
-                               }\r
-\r
                                Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
                                                   CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
+\r
                                CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;\r
 \r
                                FoundEndpoints |= CDC_FOUND_DATAPIPE_IN;\r
                        }\r
                        else\r
                        {\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                               {\r
-                                       CDCInterfaceInfo->State.BidirectionalDataEndpoints = true;\r
-                               }\r
-                               else\r
-                               {\r
-                                       Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
-                                                          EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
-                                                          CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
-                               }\r
-                               \r
+                               Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
+                                                                  EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
+                                                                  CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
+                       \r
                                CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;\r
                                \r
                                FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT;\r
@@ -277,22 +265,11 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, ch
 \r
        uint8_t ErrorCode;\r
 \r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);\r
-               Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
-       }\r
-       else\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
-       }\r
+       Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
 \r
        Pipe_Unfreeze();\r
        ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);\r
        Pipe_Freeze();\r
-\r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-         Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
        \r
        return ErrorCode;\r
 }\r
@@ -304,16 +281,7 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, cons
          \r
        uint8_t ErrorCode;\r
 \r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);\r
-               Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
-       }\r
-       else\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
-       }\r
-       \r
+       Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
        \r
        if (!(Pipe_IsReadWriteAllowed()))\r
@@ -326,9 +294,6 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, cons
 \r
        Pipe_Write_Byte(Data);  \r
        Pipe_Freeze();\r
-\r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-         Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
        \r
        return PIPE_READYWAIT_NoError;\r
 }\r
@@ -381,16 +346,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
          \r
        uint8_t ErrorCode;\r
 \r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);\r
-               Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
-       }\r
-       else\r
-       {\r
-               Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
-       }\r
-       \r
+       Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);    \r
        Pipe_Unfreeze();\r
        \r
        if (!(Pipe_BytesInPipe()))\r
@@ -409,9 +365,6 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
        }\r
 \r
        Pipe_Freeze();\r
-\r
-       if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)\r
-         Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
        \r
        return PIPE_READYWAIT_NoError;\r
 }\r
index dbc1f9e..466f141 100644 (file)
                                        uint16_t DataOUTPipeSize;  /**< Size in bytes of the CDC interface's OUT data pipe */\r
                                        uint16_t NotificationPipeSize;  /**< Size in bytes of the CDC interface's IN notification pipe, if used */\r
                                        \r
-                                       bool BidirectionalDataEndpoints; /**< Indicates if the attached CDC interface uses bidirectional data endpoints,\r
-                                                                         *   and this has only the IN pipe configured (with \ref Pipe_SetPipeToken()\r
-                                                                         *   used to switch the pipe's direction)\r
-                                                                         */\r
-\r
                                        struct\r
                                        {\r
                                                uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_*\r
index fac569e..5966ed8 100644 (file)
@@ -110,12 +110,6 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
                {\r
                        if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)\r
                        {\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                               {\r
-                                       RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;\r
-                                       Pipe_DisablePipe();\r
-                               }\r
-\r
                                Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,\r
                                                   EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
                                                   RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
@@ -125,17 +119,10 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
                        }\r
                        else\r
                        {\r
-                               if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))\r
-                               {\r
-                                       RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;\r
-                               }\r
-                               else\r
-                               {\r
-                                       Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
-                                                          EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
-                                                          RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
-                               }\r
-                               \r
+                               Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,\r
+                                                  EndpointData->EndpointAddress, EndpointData->EndpointSize, \r
+                                                  RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);\r
+\r
                                RNDISInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;\r
                                \r
                                FoundEndpoints |= RNDIS_FOUND_DATAPIPE_OUT;\r
@@ -422,27 +409,11 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
 \r
        RNDIS_Packet_Message_t DeviceMessage;\r
        \r
-       if (Pipe_BytesInPipe() < sizeof(RNDIS_Packet_Message_t))\r
-       {\r
-               printf("*SIZE YARG: %d*\r\n", Pipe_BytesInPipe());\r
-               *PacketLength = 0;\r
-               Pipe_ClearIN();\r
-               return RNDIS_COMMAND_FAILED;    \r
-       }\r
-       \r
        if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),\r
                                             NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)\r
        {\r
                return ErrorCode;\r
        }\r
-       \r
-       if (DeviceMessage.MessageType != REMOTE_NDIS_PACKET_MSG)\r
-       {\r
-               printf("****YARG****\r\n");\r
-               *PacketLength = 0;\r
-               Pipe_ClearIN();\r
-               return RNDIS_COMMAND_FAILED;\r
-       }\r
 \r
        *PacketLength = (uint16_t)DeviceMessage.DataLength;\r
        \r
@@ -466,16 +437,6 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
        if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))\r
          return PIPE_READYWAIT_DeviceDisconnected;\r
 \r
-       if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)\r
-       {\r
-               Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);\r
-               Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
-       }\r
-       else\r
-       {\r
-               Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);  \r
-       }\r
-\r
        RNDIS_Packet_Message_t DeviceMessage;\r
 \r
        memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));\r
@@ -484,14 +445,12 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
        DeviceMessage.DataOffset    = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));\r
        DeviceMessage.DataLength    = PacketLength;\r
        \r
+       Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);\r
        Pipe_Unfreeze();\r
 \r
        if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),\r
                                              NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)\r
        {\r
-               if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)\r
-                 Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
-\r
                return ErrorCode;\r
        }\r
 \r
@@ -500,9 +459,6 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
 \r
        Pipe_Freeze();\r
        \r
-       if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)\r
-         Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
-       \r
        return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
index fc9b4b3..0110b5a 100644 (file)
                                \r
                                        uint16_t DataINPipeSize; /**< Size in bytes of the RNDIS interface's IN data pipe */\r
                                        uint16_t DataOUTPipeSize;  /**< Size in bytes of the RNDIS interface's OUT data pipe */\r
-                                       uint16_t NotificationPipeSize;  /**< Size in bytes of the RNDIS interface's IN notification pipe, if used */\r
-                                       \r
-                                       bool BidirectionalDataEndpoints; /**< Indicates if the attached RNDIS interface uses bidirectional data endpoints,\r
-                                                                         *   and this has only the IN pipe configured (with \ref Pipe_SetPipeToken()\r
-                                                                         *   used to switch the pipe's direction)\r
-                                                                         */\r
+                                       uint16_t NotificationPipeSize;  /**< Size in bytes of the RNDIS interface's IN notification pipe, if used */                                    \r
+\r
                                        uint32_t DeviceMaxPacketSize; /**< Maximum size of a packet which can be buffered by the attached RNDIS device */\r
                                        \r
                                        uint32_t RequestID; /**< Request ID counter to give a unique ID for each command/response pair */\r
index 8a46a5a..cf37fa5 100644 (file)
@@ -45,6 +45,7 @@
   *  - Fixed Benito project not resetting the target AVR automatically when programming has completed\r
   *  - Fixed DFU bootloader programming not discarding the correct number of filler bytes from the host when non-aligned programming\r
   *    ranges are specified (thanks to Thomas Bleeker)\r
+  *  - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two seperate pipes, not one half-duplex pipe\r
   *\r
   *  \section Sec_ChangeLog091223 Version 091223\r
   *\r
index 97218b2..11acec4 100644 (file)
@@ -65,7 +65,8 @@ char PROGMEM HTTPPage[]   =
                "       <body>"\r
                "               <h1>Hello from your USB AVR!</h1>"\r
                "               <p>"\r
-               "                       Hello! Welcome to the LUFA RNDIS Demo Webserver test page, running on your USB AVR via the LUFA library. This demonstrates the HTTP webserver, TCP/IP stack and RNDIS demo all running atop the LUFA USB stack."\r
+               "                       Hello! Welcome to the LUFA RNDIS Demo Webserver test page, running on your USB AVR via the LUFA library and uIP TCP/IP network stack. This"\r
+               "           demonstrates a simple HTTP webserver serving out pages to HTTP clients."\r
                "                       <br /><br />"\r
                "                       <small>Project Information: <a href=\"http://www.fourwalledcubicle.com/LUFA.php\">http://www.fourwalledcubicle.com/LUFA.php</a>.</small>"\r
                "                       <hr />"\r
index 74636b8..c0ceeed 100644 (file)
@@ -174,7 +174,7 @@ void ProcessIncommingPacket(void)
                LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
 \r
                /* Read the incomming packet straight into the UIP packet buffer */\r
-               printf("L=%d R=%d\r\n", uip_len, RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], &uip_len));\r
+               RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], &uip_len);\r
 \r
                if (uip_len > 0)\r
                {\r