aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-01-25 11:50:41 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-01-25 11:50:41 +0000
commit431db89b00408197976d653d89d15eeef8172e1b (patch)
tree8900ab7368cdd124b725a65da47407f96fd46053 /LUFA/Drivers/USB
parent74b6993d66d70c323beb4d7eccf5b8f45bf6d31f (diff)
downloadlufa-431db89b00408197976d653d89d15eeef8172e1b.tar.gz
lufa-431db89b00408197976d653d89d15eeef8172e1b.tar.bz2
lufa-431db89b00408197976d653d89d15eeef8172e1b.zip
Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two seperate pipes, not one half-duplex pipe.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.c63
-rw-r--r--LUFA/Drivers/USB/Class/Host/CDC.h5
-rw-r--r--LUFA/Drivers/USB/Class/Host/RNDIS.c54
-rw-r--r--LUFA/Drivers/USB/Class/Host/RNDIS.h8
4 files changed, 15 insertions, 115 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.c b/LUFA/Drivers/USB/Class/Host/CDC.c
index 7f5bcb940..8ad37de73 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.c
+++ b/LUFA/Drivers/USB/Class/Host/CDC.c
@@ -110,32 +110,20 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
{
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
{
- if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
- {
- CDCInterfaceInfo->State.BidirectionalDataEndpoints = true;
- Pipe_DisablePipe();
- }
-
Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
EndpointData->EndpointAddress, EndpointData->EndpointSize,
CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+
CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
FoundEndpoints |= CDC_FOUND_DATAPIPE_IN;
}
else
{
- if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
- {
- CDCInterfaceInfo->State.BidirectionalDataEndpoints = true;
- }
- else
- {
- Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
- EndpointData->EndpointAddress, EndpointData->EndpointSize,
- CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
- }
-
+ Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
+ EndpointData->EndpointAddress, EndpointData->EndpointSize,
+ CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+
CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT;
@@ -277,22 +265,11 @@ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, ch
uint8_t ErrorCode;
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
- Pipe_SetPipeToken(PIPE_TOKEN_OUT);
- }
- else
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
- }
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
ErrorCode = Pipe_Write_Stream_LE(Data, Length, NO_STREAM_CALLBACK);
Pipe_Freeze();
-
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- Pipe_SetPipeToken(PIPE_TOKEN_IN);
return ErrorCode;
}
@@ -304,16 +281,7 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, cons
uint8_t ErrorCode;
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
- Pipe_SetPipeToken(PIPE_TOKEN_OUT);
- }
- else
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
- }
-
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_IsReadWriteAllowed()))
@@ -326,9 +294,6 @@ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, cons
Pipe_Write_Byte(Data);
Pipe_Freeze();
-
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- Pipe_SetPipeToken(PIPE_TOKEN_IN);
return PIPE_READYWAIT_NoError;
}
@@ -381,16 +346,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
uint8_t ErrorCode;
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipeNumber);
- Pipe_SetPipeToken(PIPE_TOKEN_OUT);
- }
- else
- {
- Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
- }
-
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if (!(Pipe_BytesInPipe()))
@@ -409,9 +365,6 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
}
Pipe_Freeze();
-
- if (CDCInterfaceInfo->State.BidirectionalDataEndpoints)
- Pipe_SetPipeToken(PIPE_TOKEN_IN);
return PIPE_READYWAIT_NoError;
}
diff --git a/LUFA/Drivers/USB/Class/Host/CDC.h b/LUFA/Drivers/USB/Class/Host/CDC.h
index dbc1f9e42..466f141db 100644
--- a/LUFA/Drivers/USB/Class/Host/CDC.h
+++ b/LUFA/Drivers/USB/Class/Host/CDC.h
@@ -89,11 +89,6 @@
uint16_t DataOUTPipeSize; /**< Size in bytes of the CDC interface's OUT data pipe */
uint16_t NotificationPipeSize; /**< Size in bytes of the CDC interface's IN notification pipe, if used */
- bool BidirectionalDataEndpoints; /**< Indicates if the attached CDC interface uses bidirectional data endpoints,
- * and this has only the IN pipe configured (with \ref Pipe_SetPipeToken()
- * used to switch the pipe's direction)
- */
-
struct
{
uint8_t HostToDevice; /**< Control line states from the host to device, as a set of CDC_CONTROL_LINE_OUT_*
diff --git a/LUFA/Drivers/USB/Class/Host/RNDIS.c b/LUFA/Drivers/USB/Class/Host/RNDIS.c
index fac569e9c..5966ed851 100644
--- a/LUFA/Drivers/USB/Class/Host/RNDIS.c
+++ b/LUFA/Drivers/USB/Class/Host/RNDIS.c
@@ -110,12 +110,6 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
{
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
{
- if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
- {
- RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;
- Pipe_DisablePipe();
- }
-
Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
EndpointData->EndpointAddress, EndpointData->EndpointSize,
RNDISInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
@@ -125,17 +119,10 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
}
else
{
- if (Pipe_IsEndpointBound(EndpointData->EndpointAddress))
- {
- RNDISInterfaceInfo->State.BidirectionalDataEndpoints = true;
- }
- else
- {
- Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
- EndpointData->EndpointAddress, EndpointData->EndpointSize,
- RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
- }
-
+ Pipe_ConfigurePipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
+ EndpointData->EndpointAddress, EndpointData->EndpointSize,
+ RNDISInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
+
RNDISInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
FoundEndpoints |= RNDIS_FOUND_DATAPIPE_OUT;
@@ -422,27 +409,11 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
RNDIS_Packet_Message_t DeviceMessage;
- if (Pipe_BytesInPipe() < sizeof(RNDIS_Packet_Message_t))
- {
- printf("*SIZE YARG: %d*\r\n", Pipe_BytesInPipe());
- *PacketLength = 0;
- Pipe_ClearIN();
- return RNDIS_COMMAND_FAILED;
- }
-
if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),
NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
{
return ErrorCode;
}
-
- if (DeviceMessage.MessageType != REMOTE_NDIS_PACKET_MSG)
- {
- printf("****YARG****\r\n");
- *PacketLength = 0;
- Pipe_ClearIN();
- return RNDIS_COMMAND_FAILED;
- }
*PacketLength = (uint16_t)DeviceMessage.DataLength;
@@ -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))
return PIPE_READYWAIT_DeviceDisconnected;
- if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)
- {
- Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipeNumber);
- Pipe_SetPipeToken(PIPE_TOKEN_OUT);
- }
- else
- {
- Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
- }
-
RNDIS_Packet_Message_t DeviceMessage;
memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));
@@ -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));
DeviceMessage.DataLength = PacketLength;
+ Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze();
if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),
NO_STREAM_CALLBACK)) != PIPE_RWSTREAM_NoError)
{
- if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)
- Pipe_SetPipeToken(PIPE_TOKEN_IN);
-
return ErrorCode;
}
@@ -500,9 +459,6 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
Pipe_Freeze();
- if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)
- Pipe_SetPipeToken(PIPE_TOKEN_IN);
-
return PIPE_RWSTREAM_NoError;
}
diff --git a/LUFA/Drivers/USB/Class/Host/RNDIS.h b/LUFA/Drivers/USB/Class/Host/RNDIS.h
index fc9b4b325..0110b5a0d 100644
--- a/LUFA/Drivers/USB/Class/Host/RNDIS.h
+++ b/LUFA/Drivers/USB/Class/Host/RNDIS.h
@@ -90,12 +90,8 @@
uint16_t DataINPipeSize; /**< Size in bytes of the RNDIS interface's IN data pipe */
uint16_t DataOUTPipeSize; /**< Size in bytes of the RNDIS interface's OUT data pipe */
- uint16_t NotificationPipeSize; /**< Size in bytes of the RNDIS interface's IN notification pipe, if used */
-
- bool BidirectionalDataEndpoints; /**< Indicates if the attached RNDIS interface uses bidirectional data endpoints,
- * and this has only the IN pipe configured (with \ref Pipe_SetPipeToken()
- * used to switch the pipe's direction)
- */
+ uint16_t NotificationPipeSize; /**< Size in bytes of the RNDIS interface's IN notification pipe, if used */
+
uint32_t DeviceMaxPacketSize; /**< Maximum size of a packet which can be buffered by the attached RNDIS device */
uint32_t RequestID; /**< Request ID counter to give a unique ID for each command/response pair */