PKP
VS1000 P
ROGRAMMER
’
S
G
UIDE
VSMPG
7.5
Setting your own USB descriptors
Each USB device has a Vendor ID and a Product ID, which are 16-bit numbers that
the operating system uses for determining which device driver to load for the device.
Additionally most USB devices have a vendor name and model name strings that the
operating system can display to the user. All USB string descriptors are 16-bit Unicode
strings (UTF-16).
VS1000’s ROM code holds VLSI’s Vendor ID and Product ID. For prototyping you can
use an unused Vendor ID and Product ID, but when you ship products to customers, you
must use your own Vendor ID and Product ID. A Vendor ID can be obtained from the
USB Implementers Forum, Inc.’s web site,
http://www.usb.org
.
To comply with USB Mass Storage Specification, each device that is shipped out to
customers should have a unique serial number in the USB descriptors. Windows uses
this serial number e.g. for storing device parameters in the system registry.
VS1000’s ROM is written so that it’s easy to change these descriptors without having to
touch the rest of the USB code. This example shows how you can change the Device
Descriptor, which holds the Vendor ID and Product ID, and the Vendor/Model/SerialNumber
string descriptors.
USB.descriptorTable[6]
holds pointers to the descriptors. A system hook vector called
InitUSBDescriptors
can be used to set your own descriptors.
7.5.1
Descriptor data format
Mostly because the USB has its roots in the 8-bit oriented PC (80x86) architecture, all
USB traffic is transmitted byte by byte. When values that have more than 8 bits, such as
16-bit integers or 32-bit integers, are transmitted, they are transmitted in the little-endian
(“Little End First”) format, where the least significant (last) byte of a multi-byte value is
sent first.
VS_DSP, however, is a natively 16-bit architecture that only handles 16-bit values. Thus
all data in VS_DSP must be stored as signed or unsigned 16 (or 32) bit values. To
maintain USB compatibility, care must be taken to transmit descriptors in the correct
byte order. In practice this means that descriptors should be stored in tables of byte-
swapped 16-bit unsigned integers as in the example below.
The serial number is a string of (at least) 12 characters from set {“0123456789ABCDEF”}.
All strings are stored in 16-bit Unicode format. The example code creates a new serial
number string descriptor
mySerialNumberStr
. The last 8 characters are generated in
the
main()
function from
u_int32 mySerialNumber
, which should be unique for each
device. You could generate it from e.g. the serial number of the storage memory your
product has. The first 4 characters (“1234” in the descriptor) could be fixed for a specific
program version etc.
Rev. 0.20
2011-10-04
Page