Driver Structure
MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1
Freescale Semiconductor
25
6.2.4 Example of Command Block Wrapper
Table 6-8
shows a USB CBW issued to the device number 0 (byte 12 of the CBW) with effective SCSI
command length of 10 (byte 14). The expected transfer length is 0x1000 [ie: Byte 11 (MSB) to Byte 8
(LSB)].
The byte 15 of the CBW “2A” means it is a SCSI Write_10 command. The command requests the device
to write 8 block of data to the LBA 0x9C4637. In this example one block of data equals 512 bytes.
Therefore, 8 blocks of data equal 4K bytes which match the expected transfer length of 0x1000 bytes of
data length requested in the CBW.
6.3 Driver Structure
The driver handles and responses to the commands included in the USB Command Block Wrapper, and
the Class Specific Requests.
6.3.1 Handling of USB Command Block Wrapper
Figure 6-2
and
Figure 6-3
show the handling of the USB Command Block Wrapper. There are only three
kinds of commands to handle. As shown in
Figure 6-3
, there are commands that:
•
do not require any data transfer
•
require host to send out data to storage device
•
require host to receive data from storage device
After decoding the SCSI command from the CBW, the driver will either:
•
handle the command without interfere with the individual storage device driver, or
•
translate the command and call individual routines of the storage device driver.
After receiving a 31 byte CBW and all data has been transferred, the UF32 will return a 13 byte CSW to
the host with either a result of pass or failed which depends on the global variable gUSBMSResult. Pass
result only happens if the command is supported and the storage device has successfully executed the
command.
Each card has its individual mass storage processor file. For example, the “CFMS_Processor.c” handles
the USB command block wrapper for CompactFlash card. The “USBMS_Process.c” contains common
routines that are used for all the card mass storage processors.
Table 6-8. Example of a CBW containing SCSI Write_10 Command
USB CBW
SCSI Command
Bytes
Data (HEX)
Bytes
Data (HEX)
Meaning
0 — 3
55 53 42 43 (Signature)
0
2A
Write_10
4 — 7
A8 1A A4 FF (Tag)
1
00
Not used
8 — 11
00 10 00 00 (Length)
2 — 5
00 9C 46 37
Logical Block Ad-
dress
12
00 (Device Number)
13
00 (Reserved)
6 — 9
00 00 00 08
Number of block to
transfer
14
0A (Command Length)
15 — 30
2A
00 00 9C 46 37 00 00
00 08 00 00 00 00 00 00
10 — 15
00 00 00
00 00 00
Not used