Information Technology Reference
In-Depth Information
while (TransferLength._word > 0) {
// Read data received from the USB host and write the contents to the media
// until TransferLength = 0.
// Set dCSWDataResidue to the media's block size.
msd_csw.dCSWDataResidue = 512;
while (msd_csw.dCSWDataResidue > 0)
// The MSDDataOut function reads data from the USB host.
// dCSWDataResidue is decremented as the data is read.
// Continue until dCSWDataResidue = 0.
MSDDataOut();
if (IsWriteProtected()) {
// If the media is write protected, set the sense data
// and bCSWStatus in the CSW.
gblSenseData.SenseKey = S_NOT_READY;
gblSenseData.ASC = ASC_WRITE_PROTECTED;
gblSenseData.ASCQ = ASCQ_WRITE_PROTECTED;
msd_csw.bCSWStatus = 0x01; // Command failed.
} else {
// The received data is in msd_buffer.
// Write the data to the media beginning at the LBA specified in the CBW.
status = SectorWrite((LBA._dword), (byte*)&msd_buffer[0]);
}
Search WWH ::




Custom Search