SH7286 Group
USB Function Module: USB Mass Storage Class
When transferring data in the USB Mass Storage Class (Bulk-Only Transport), a series of data transfer starts on the
CBW transport, and returns a series of the transfer result (status) to the host computer on the CSW transport. To return
the status on the CSW transport, create values in two fields; bCSWStatus to indicate the success or failure of the
command, and dCSWDataResidue to indicate the number of bytes of data transfer error.
This sample program uses the following fields;
⎯
dCBWDataTransferLength field of the CBW packet
⎯
dCSWDataTRansferResidue field of the CSW packet
dCBWDataTransferLength field is a variable to store the number of bytes of data specified by the host computer to
process on the Data transport.
dCSWDataTransferResidue field is a variable to store the number of bytes of data processed by the function on the Data
transport.
When the CBW transport is completed, dCBWDataTransferLength and dCSWDataTransferResidue fields store the
number of bytes of data processed on the Data transport.
Data transfer on the Data transport is executed as shown in Figure 8 to Figure 10 flow charts.
When there is no error during the data transfer between the host and function, the sample program subtracts the number
of bytes to transfer from fields dCBWDataTransferLength and dCSWDataTransferResidue every time the data transfer
is executed on the Data transport. Otherwise, the sample program sets the "difference" between the number of bytes of
data the host expects to process on the Data transport and the number of bytes of data processed by the function on the
Data transport to the dCSWDataTransferResidue field of the CSW packet, and transitions to the Status transport.
CBW
IN/OUT
IN/OUT
IN/OUT
CSW
Number of data host expects
Number of data device intends
Number of data host expects
Number of data device intends
Deficiency
Number of data host expects
…
dCBWDataTransferLength
dCSWDataResidue
dCSWDataResidue
dCBWDataTransferLength
dCSWDataResidue
dCBWDataTransferLength
Command transport
Data transport
Status transport
Return 0 as the number of data
device intends is equal to the
number of data host expects.
Return the difference between
the number of data device and
the number of data host expects.
Return the number of data
beyond the number of data host
expects
Number of data device intends
Excess
Figure 11 Stages on Bulk-Only Transport
R01AN0063EJ0100 Rev. 1.00
Page 30 of 32
Oct. 22, 2010