diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-01-25 04:13:44 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-01-25 04:13:44 +0000 |
commit | 74b6993d66d70c323beb4d7eccf5b8f45bf6d31f (patch) | |
tree | 0912f8438fb816ce6a66d37f5306e0ae9507fa49 /LUFA | |
parent | 857381185d60eed2ccee7dc7b88d49d90546f8a2 (diff) | |
download | lufa-74b6993d66d70c323beb4d7eccf5b8f45bf6d31f.tar.gz lufa-74b6993d66d70c323beb4d7eccf5b8f45bf6d31f.tar.bz2 lufa-74b6993d66d70c323beb4d7eccf5b8f45bf6d31f.zip |
Cleanup and partially fix AVRISP-MKII project's TPI programming support.
Diffstat (limited to 'LUFA')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/RNDIS.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/RNDIS.c b/LUFA/Drivers/USB/Class/Host/RNDIS.c index 46aeb9850..fac569e9c 100644 --- a/LUFA/Drivers/USB/Class/Host/RNDIS.c +++ b/LUFA/Drivers/USB/Class/Host/RNDIS.c @@ -392,7 +392,7 @@ bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfac Pipe_Unfreeze();
- PacketWaiting = Pipe_IsINReceived();
+ PacketWaiting = (Pipe_IsINReceived() && Pipe_BytesInPipe());
Pipe_Freeze();
@@ -412,6 +412,9 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn if (!(Pipe_IsReadWriteAllowed()))
{
+ if (Pipe_IsINReceived())
+ Pipe_ClearIN();
+
*PacketLength = 0;
Pipe_Freeze();
return PIPE_RWSTREAM_NoError;
@@ -419,11 +422,27 @@ 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;
@@ -431,7 +450,9 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn NO_STREAM_CALLBACK);
Pipe_Read_Stream_LE(Buffer, *PacketLength, NO_STREAM_CALLBACK);
- Pipe_ClearIN();
+
+ if (!(Pipe_BytesInPipe()))
+ Pipe_ClearIN();
Pipe_Freeze();
@@ -455,21 +476,25 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
}
- Pipe_Unfreeze();
-
RNDIS_Packet_Message_t DeviceMessage;
-
- DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG;
+
+ memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));
+ DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG;
DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength);
- DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));
- DeviceMessage.DataLength = PacketLength;
+ DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));
+ DeviceMessage.DataLength = PacketLength;
+ 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;
}
-
+
Pipe_Write_Stream_LE(Buffer, PacketLength, NO_STREAM_CALLBACK);
Pipe_ClearOUT();
|