Simplified Host mode Mass Storage Class driver to reduce compiled program size.
authorDean Camera <dean@fourwalledcubicle.com>
Thu, 27 Aug 2009 08:17:06 +0000 (08:17 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Thu, 27 Aug 2009 08:17:06 +0000 (08:17 +0000)
LUFA/Drivers/USB/Class/Host/MassStorage.c
LUFA/Drivers/USB/Class/Host/MassStorage.h

index 3db4aaf..1f66aa8 100644 (file)
@@ -129,11 +129,14 @@ void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
        \r
 }\r
 \r
        \r
 }\r
 \r
-static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_CommandBlockWrapper_t* SCSICommandBlock)\r
+static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_CommandBlockWrapper_t* SCSICommandBlock,\r
+                                   void* BufferPtr)\r
 {\r
        uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
 \r
 {\r
        uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
 \r
-       if (++MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)\r
+       SCSICommandBlock->Tag = MSInterfaceInfo->State.TransactionTag++;\r
+\r
+       if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)\r
          MSInterfaceInfo->State.TransactionTag = 1;\r
 \r
        Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);\r
          MSInterfaceInfo->State.TransactionTag = 1;\r
 \r
        Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);\r
@@ -143,11 +146,18 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_
          return ErrorCode;\r
 \r
        Pipe_ClearOUT();\r
          return ErrorCode;\r
 \r
        Pipe_ClearOUT();\r
-       while(!(Pipe_IsOUTReady()));\r
+       Pipe_WaitUntilReady();\r
 \r
        Pipe_Freeze();\r
 \r
        Pipe_Freeze();\r
+\r
+       if ((BufferPtr != NULL) &&\r
+           ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, BufferPtr)) != PIPE_RWSTREAM_NoError))\r
+       {\r
+               Pipe_Freeze();\r
+               return ErrorCode;\r
+       }\r
        \r
        \r
-       return PIPE_RWSTREAM_NoError;\r
+       return ErrorCode;\r
 }\r
 \r
 static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
 }\r
 \r
 static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
@@ -204,13 +214,19 @@ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceI
 }\r
 \r
 static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
 }\r
 \r
 static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
-                                         MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr)\r
+                                       MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr)\r
 {\r
        uint8_t  ErrorCode = PIPE_RWSTREAM_NoError;\r
        uint16_t BytesRem  = SCSICommandBlock->DataTransferLength;\r
 \r
        if (SCSICommandBlock->Flags & COMMAND_DIRECTION_DATA_IN)\r
        {\r
 {\r
        uint8_t  ErrorCode = PIPE_RWSTREAM_NoError;\r
        uint16_t BytesRem  = SCSICommandBlock->DataTransferLength;\r
 \r
        if (SCSICommandBlock->Flags & COMMAND_DIRECTION_DATA_IN)\r
        {\r
+               if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
+               {\r
+                       Pipe_Freeze();\r
+                       return ErrorCode;\r
+               }\r
+\r
                Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);\r
                Pipe_Unfreeze();\r
                \r
                Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);\r
                Pipe_Unfreeze();\r
                \r
@@ -238,7 +254,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
 \r
        Pipe_Freeze();\r
 \r
 \r
        Pipe_Freeze();\r
 \r
-       return PIPE_RWSTREAM_NoError;\r
+       return ErrorCode;\r
 }\r
 \r
 static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
 }\r
 \r
 static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
@@ -258,7 +274,10 @@ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInf
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
        \r
        Pipe_ClearIN();\r
        Pipe_Freeze();\r
        \r
-       return PIPE_RWSTREAM_NoError;\r
+       if (SCSICommandStatus->Status != SCSI_Command_Pass)\r
+         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
 uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
 }\r
 \r
 uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)\r
@@ -318,7 +337,6 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = sizeof(SCSI_Inquiry_Response_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = sizeof(SCSI_Inquiry_Response_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
@@ -334,33 +352,19 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
                                }\r
                };\r
        \r
                                }\r
                };\r
        \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;       \r
        }\r
        \r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;       \r
        }\r
        \r
-       if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
-\r
-       if ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, &SCSICommandBlock, InquiryData)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }       \r
-       \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -375,7 +379,6 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = 0,\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = 0,\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
@@ -391,21 +394,19 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t
                                }\r
                };\r
        \r
                                }\r
                };\r
        \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;       \r
        }\r
        \r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;       \r
        }\r
        \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -421,7 +422,6 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uin
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = sizeof(SCSI_Capacity_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = sizeof(SCSI_Capacity_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
@@ -441,36 +441,22 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uin
                                }\r
                };\r
        \r
                                }\r
                };\r
        \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
 \r
-       if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
 \r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
 \r
-       if ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
-         \r
        DeviceCapacity->Blocks    = SwapEndian_32(DeviceCapacity->Blocks);\r
        DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize);\r
        \r
        DeviceCapacity->Blocks    = SwapEndian_32(DeviceCapacity->Blocks);\r
        DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize);\r
        \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -486,7 +472,6 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t L
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = sizeof(SCSI_Request_Sense_Response_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = sizeof(SCSI_Request_Sense_Response_t),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
@@ -502,33 +487,19 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t L
                                }\r
                };\r
        \r
                                }\r
                };\r
        \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
-       \r
-       if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
 \r
-       if ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -543,7 +514,6 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceIn
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = 0,\r
                        .Flags              = COMMAND_DIRECTION_DATA_OUT,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = 0,\r
                        .Flags              = COMMAND_DIRECTION_DATA_OUT,\r
                        .LUN                = LUNIndex,\r
@@ -559,21 +529,19 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceIn
                                }\r
                };\r
        \r
                                }\r
                };\r
        \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        \r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -589,7 +557,6 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = ((uint32_t)Blocks * BlockSize),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = ((uint32_t)Blocks * BlockSize),\r
                        .Flags              = COMMAND_DIRECTION_DATA_IN,\r
                        .LUN                = LUNIndex,\r
@@ -609,33 +576,19 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8
                                }\r
                };\r
 \r
                                }\r
                };\r
 \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
-       \r
-       if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
 \r
-       if ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
@@ -651,7 +604,6 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
        MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
                {\r
                        .Signature          = CBW_SIGNATURE,\r
-                       .Tag                = MSInterfaceInfo->State.TransactionTag,\r
                        .DataTransferLength = ((uint32_t)Blocks * BlockSize),\r
                        .Flags              = COMMAND_DIRECTION_DATA_OUT,\r
                        .LUN                = LUNIndex,\r
                        .DataTransferLength = ((uint32_t)Blocks * BlockSize),\r
                        .Flags              = COMMAND_DIRECTION_DATA_OUT,\r
                        .LUN                = LUNIndex,\r
@@ -671,27 +623,19 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint
                                }\r
                };\r
 \r
                                }\r
                };\r
 \r
-       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock)) != PIPE_RWSTREAM_NoError)\r
-       {\r
-               Pipe_Freeze();\r
-               return ErrorCode;\r
-       }\r
+       MS_CommandStatusWrapper_t SCSICommandStatus;\r
 \r
 \r
-       if ((ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
+       if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        \r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        \r
-       MS_CommandStatusWrapper_t SCSICommandStatus;\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
        if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
        {\r
                Pipe_Freeze();\r
                return ErrorCode;\r
        }\r
-       \r
-       if (SCSICommandStatus.Status != SCSI_Command_Pass)\r
-         ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
 \r
        return ErrorCode;\r
 }\r
 \r
        return ErrorCode;\r
 }\r
index f347b19..30969c4 100644 (file)
                                static uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor);\r
                                \r
                                static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
                                static uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor);\r
                                \r
                                static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,\r
-                                                                  MS_CommandBlockWrapper_t* SCSICommandBlock);\r
+                                                                  MS_CommandBlockWrapper_t* SCSICommandBlock,\r
+                                                                  void* BufferPtr);\r
                                static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo);\r
                                static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, \r
                                                        MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr);\r
                                static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo);\r
                                static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, \r
                                                        MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr);\r