/* Send the data in the OUT pipe to the attached device */\r
Pipe_ClearOUT();\r
\r
+ /* Wait until command has been sent */\r
while(!(Pipe_IsOUTReady()));\r
\r
/* Freeze pipe after use */\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the OUT pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_OUT_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
if (Pipe_IsStalled())\r
{\r
/* Clear the stall condition on the IN pipe */\r
- MassStore_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
+ USB_Host_ClearPipeStall(MASS_STORE_DATA_IN_PIPE);\r
\r
return PIPE_RWSTREAM_PipeStalled;\r
}\r
return PIPE_RWSTREAM_NoError;\r
}\r
\r
-/** Clears the stall condition in the attached device on the nominated endpoint number.\r
- *\r
- * \param EndpointNum Endpoint number in the attached device whose stall condition is to be cleared\r
- *\r
- * \return A value from the USB_Host_SendControlErrorCodes_t enum\r
- */\r
-uint8_t MassStore_ClearPipeStall(const uint8_t EndpointNum)\r
-{\r
- USB_ControlRequest = (USB_Request_Header_t)\r
- {\r
- .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
- .bRequest = REQ_ClearFeature,\r
- .wValue = FEATURE_ENDPOINT_HALT,\r
- .wIndex = EndpointNum,\r
- .wLength = 0,\r
- };\r
- \r
- /* Select the control pipe for the request transfer */\r
- Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
-\r
- return USB_Host_SendControlRequest(NULL);\r
-}\r
-\r
/** Issues a Mass Storage class specific request to reset the attached device's Mass Storage interface,\r
* readying the device for the next CBW.\r
*\r
return ErrorCode;\r
}\r
\r
+/** Issues a SCSI Inquiry command to the attached device, to determine the device's information. This\r
+ * gives information on the device's capabilities.\r
+ *\r
+ * \param LUNIndex Index of the LUN inside the device the command is being addressed to\r
+ * \param InquiryPtr Pointer to the inquiry data structure where the inquiry data from the device is to be stored\r
+ *\r
+ * \return A value from the Pipe_Stream_RW_ErrorCodes_t enum\r
+ */\r
+uint8_t MassStore_Inquiry(const uint8_t LUNIndex, const SCSI_Inquiry_Response_t* const InquiryPtr)\r
+{\r
+ uint8_t ReturnCode = PIPE_RWSTREAM_NoError;\r
+\r
+ /* Create a CBW with a SCSI command to issue INQUIRY command */\r
+ SCSICommandBlock = (CommandBlockWrapper_t)\r
+ {\r
+ .Header =\r
+ {\r
+ .Signature = CBW_SIGNATURE,\r
+ .Tag = MassStore_Tag,\r
+ .DataTransferLength = sizeof(SCSI_Inquiry_Response_t),\r
+ .Flags = COMMAND_DIRECTION_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 6\r
+ },\r
+ \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
+ /* Send SCSI command to the attached device */\r
+ MassStore_SendCommand();\r
+\r
+ /* Wait until data received from the device */\r
+ if ((ReturnCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ReturnCode;\r
+ }\r
+\r
+ /* Read the returned sense data into the buffer */\r
+ if ((ReturnCode = MassStore_SendReceiveData((uint8_t*)InquiryPtr)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ReturnCode;\r
+ } \r
+ \r
+ /* Read in the returned CSW from the device */\r
+ if ((ReturnCode = MassStore_GetReturnedStatus()) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ReturnCode;\r
+ }\r
+ \r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
/** Issues a SCSI Request Sense command to the attached device, to determine the current SCSI sense information. This\r
* gives error codes for the last issued SCSI command to the device.\r
*\r