- Permission to use, copy, modify, distribute, and sell this
+ Permission to use, copy, modify, distribute, and sell this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software without specific, written prior permission.
The author disclaim all warranties with regard to this
/* Send data if any */
if ((BufferPtr != NULL) &&
((ErrorCode = MassStore_SendReceiveData(SCSICommandBlock, BufferPtr)) != PIPE_READYWAIT_NoError))
/* Send data if any */
if ((BufferPtr != NULL) &&
((ErrorCode = MassStore_SendReceiveData(SCSICommandBlock, BufferPtr)) != PIPE_READYWAIT_NoError))
/* Wait until data received in the IN pipe */
while (!(Pipe_IsINReceived()))
{
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
/* Wait until data received in the IN pipe */
while (!(Pipe_IsINReceived()))
{
uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();
/* Check to see if a new frame has been issued (1ms elapsed) */
if (CurrentFrameNumber != PreviousFrameNumber)
{
/* Check to see if a new frame has been issued (1ms elapsed) */
if (CurrentFrameNumber != PreviousFrameNumber)
{
/* Check to see if the device was disconnected, if so exit function */
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
};
/* Check to see if the device was disconnected, if so exit function */
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
};
/* Wait until the device has replied with some data */
if ((ErrorCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError)
return ErrorCode;
/* Wait until the device has replied with some data */
if ((ErrorCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError)
return ErrorCode;
/* Read in the block data from the pipe */
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
/* Read in the block data from the pipe */
if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
while (!(Pipe_IsOUTReady()))
{
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
}
}
while (!(Pipe_IsOUTReady()))
{
if (USB_HostState == HOST_STATE_Unattached)
return PIPE_RWSTREAM_DeviceDisconnected;
}
}
/* Load in the CSW from the attached device */
if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(CommandStatusWrapper_t))) != PIPE_RWSTREAM_NoError)
return ErrorCode;
/* Load in the CSW from the attached device */
if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(CommandStatusWrapper_t))) != PIPE_RWSTREAM_NoError)
return ErrorCode;
/* Check to see if command failed */
if (SCSICommandStatus->Status != Command_Pass)
ErrorCode = MASS_STORE_SCSI_COMMAND_FAILED;
/* Check to see if command failed */
if (SCSICommandStatus->Status != Command_Pass)
ErrorCode = MASS_STORE_SCSI_COMMAND_FAILED;
/* Clear the error, and pretend the request executed correctly if the device STALLed it */
ErrorCode = HOST_SENDCONTROL_Successful;
}
/* Clear the error, and pretend the request executed correctly if the device STALLed it */
ErrorCode = HOST_SENDCONTROL_Successful;
}
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Create a CBW with a SCSI command to issue TEST UNIT READY command */
CommandBlockWrapper_t SCSICommandBlock = (CommandBlockWrapper_t)
/* Create a CBW with a SCSI command to issue TEST UNIT READY command */
CommandBlockWrapper_t SCSICommandBlock = (CommandBlockWrapper_t)
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Endian-correct the read data */
CapacityPtr->Blocks = SwapEndian_32(CapacityPtr->Blocks);
CapacityPtr->BlockSize = SwapEndian_32(CapacityPtr->BlockSize);
/* Endian-correct the read data */
CapacityPtr->Blocks = SwapEndian_32(CapacityPtr->Blocks);
CapacityPtr->BlockSize = SwapEndian_32(CapacityPtr->BlockSize);
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{
/* Retrieve status information from the attached device */
if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
{