Add SCSICodes.h to the Class Driver Common folder, and automatically include it in...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / MassStorage.c
index a0b3461..1610e42 100644 (file)
@@ -310,11 +310,53 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* Max
        return ErrorCode;\r
 }\r
 \r
-uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, SCSI_Inquiry_Response_t* InquiryData)\r
+uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, SCSI_Inquiry_Response_t* InquiryData)\r
 {\r
        if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))\r
          return HOST_SENDCONTROL_DeviceDisconnect;\r
+         \r
+       uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+\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
+                       .SCSICommandLength  = 6,\r
+                       .SCSICommandData    =\r
+                               {\r
+                                       SCSI_CMD_INQUIRY,\r
+                                       0x00,                   // Reserved\r
+                                       0x00,                   // Reserved\r
+                                       0x00,                   // Reserved\r
+                                       sizeof(SCSI_Inquiry_Response_t), // Allocation Length\r
+                                       0x00                    // Unused (control)\r
+                               }\r
+               };\r
+       \r
+       MassStore_SendCommand(MSInterfaceInfo, &SCSICommandBlock);\r
+\r
+       if ((ErrorCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError)\r
+       {\r
+               Pipe_Freeze();\r
+               return ErrorCode;\r
+       }\r
 \r
+       if ((ErrorCode = MassStore_SendReceiveData(MSInterfaceInfo, (uint8_t*)InquiryPtr)) != PIPE_RWSTREAM_NoError)\r
+       {\r
+               Pipe_Freeze();\r
+               return ErrorCode;\r
+       }       \r
+       \r
+       if ((ErrorCode = MassStore_GetReturnedStatus(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
+       {\r
+               Pipe_Freeze();\r
+               return ErrorCode;\r
+       }\r
+       \r
+       return ErrorCode;\r
 }\r
 \r
 uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool* DeviceReady);\r