Add first draft of the TPI NVM commands for reading, writing and erasing a target...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / RNDIS.c
index e44d05f..af88721 100644 (file)
@@ -9,13 +9,13 @@
 /*\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
+  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
@@ -207,7 +207,7 @@ static uint8_t DComp_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDe
 \r
 void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
 {\r
-\r
+       (void)RNDISInterfaceInfo;\r
 }\r
 \r
 static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
@@ -443,4 +443,47 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
        return PIPE_RWSTREAM_NoError;\r
 }\r
 \r
+uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo, void* Buffer, uint16_t PacketLength)\r
+{\r
+       uint8_t ErrorCode;\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
+       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
+       \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
+       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
 #endif\r