/*\r
LUFA Library\r
- Copyright (C) Dean Camera, 2009.\r
+ Copyright (C) Dean Camera, 2010.\r
\r
dean [at] fourwalledcubicle [dot] com\r
www.fourwalledcubicle.com\r
*/\r
\r
/*\r
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
- Permission to use, copy, modify, and distribute this software\r
- and its documentation for any purpose and without fee is hereby\r
- granted, provided that the above copyright notice appear in all\r
- copies and that both that the copyright notice and this\r
- permission notice and warranty disclaimer appear in supporting\r
- documentation, and that the name of the author not be used in\r
- advertising or publicity pertaining to distribution of the\r
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
software without specific, written prior permission.\r
\r
The author disclaim all warranties with regard to this\r
{\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
}\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
return DESCRIPTOR_SEARCH_NotFound;\r
}\r
\r
-void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
-{\r
- (void)RNDISInterfaceInfo;\r
-}\r
-\r
static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
void* Buffer, uint16_t Length)\r
{\r
\r
Pipe_Unfreeze();\r
\r
- PacketWaiting = Pipe_IsINReceived();\r
+ PacketWaiting = (Pipe_IsINReceived() && Pipe_BytesInPipe());\r
\r
Pipe_Freeze();\r
\r
\r
if (!(Pipe_IsReadWriteAllowed()))\r
{\r
+ if (Pipe_IsINReceived())\r
+ Pipe_ClearIN();\r
+ \r
*PacketLength = 0;\r
Pipe_Freeze();\r
return PIPE_RWSTREAM_NoError;\r
NO_STREAM_CALLBACK);\r
\r
Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK);\r
- Pipe_ClearIN();\r
+ \r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
\r
Pipe_Freeze();\r
\r
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
- Pipe_Unfreeze();\r
-\r
RNDIS_Packet_Message_t DeviceMessage;\r
- \r
- DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG;\r
+\r
+ memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));\r
+ DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG;\r
DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength);\r
- DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));\r
- DeviceMessage.DataLength = PacketLength;\r
+ 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
return ErrorCode;\r
}\r
- \r
+\r
Pipe_Write_Stream_LE(Buffer, PacketLength, NO_STREAM_CALLBACK);\r
Pipe_ClearOUT();\r
\r
Pipe_Freeze();\r
\r
- if (RNDISInterfaceInfo->State.BidirectionalDataEndpoints)\r
- Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
- \r
return PIPE_RWSTREAM_NoError;\r
}\r
\r