+ if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+ \r
+ if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex, const uint32_t BlockAddress,\r
+ const uint8_t Blocks, const uint16_t BlockSize, void* BlockBuffer)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnect;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .Signature = CBW_SIGNATURE,\r
+ .DataTransferLength = ((uint32_t)Blocks * BlockSize),\r
+ .Flags = COMMAND_DIRECTION_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 10,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_READ_10,\r
+ 0x00, // Unused (control bits, all off)\r
+ (BlockAddress >> 24), // MSB of Block Address\r
+ (BlockAddress >> 16),\r
+ (BlockAddress >> 8),\r
+ (BlockAddress & 0xFF), // LSB of Block Address\r
+ 0x00, // Unused (reserved)\r
+ 0x00, // MSB of Total Blocks to Read\r
+ Blocks, // LSB of Total Blocks to Read\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ MS_CommandStatusWrapper_t SCSICommandStatus;\r
+\r
+ if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r