Information Technology Reference
In-Depth Information
• The bCBWCBLength and CBWCB fields are valid for the interface's
subclass.
The IsValidCBW function checks a CBW's size and signature. The function
uses the MSD_BD_OUT identifier defined in Chapter 2 for the bulk OUT
endpoint buffer descriptor.
byte gblCBWLength;
USB_MSD_CBW gblCBW;
gblCBWLength = MSD_BD_OUT.Cnt;
byte IsValidCBW()
{
// A valid CBW is 31 bytes and
// its dCBWSignature field contains 0x43425355.
if ((gblCBWLength != MSD_CBW_SIZE) ||
(gblCBW.dCBWSignature != 0x43425355))
return FALSE;
else
return TRUE;
}
The IsMeaningfulCBW function checks for bCBWLUN less than or equal
to 0Fh, bCBWCBLength of 01h to 10h bytes, and bCBWFlags equal to
00h or 80h. Note that a meaningful CBW must have a LUN value that is
valid for the specific device. (Few devices have 16 LUNs.)
byte IsMeaningfulCBW()
{
if ((gblCBW.bCBWLUN <= 0x0f) &&
(gblCBW.bCBWCBLength <= 0x10) &&
(gblCBW.bCBWCBLength >= 0x01) &&
(gblCBW.bCBWFlags == 0x00 | gblCBW.bCBWFlags == 0x80))
return TRUE;
else
return FALSE;
}
Search WWH ::




Custom Search