Specifications
18
6263A–ATARM–10-Oct-06
Application Note
Again, those are very generic values. For the interface descriptor, most of them are zeroed. This
is because this example does not implement any functionality other than doing the USB
enumeration.
5.2.2.3 String Descriptors
Only one structure is provided by the USB framework to declare string descriptors: for the lan-
guage ID. This is because those descriptors have a variable size, and can most of the time be
declared as a character array.
Declaring the language ID is very straightforward:
// Language ID
static const S_usb_language_id sLanguageID = {
USB_STRING_DESCRIPTOR_SIZE(1),
USB_STRING_DESCRIPTOR,
USB_LANGUAGE_ENGLISH_US
};
The USB_STRING_DESCRIPTOR_SIZE macro is used to calculate the size of a string descrip-
tor given its content. Since USB string descriptors must be in unicode format, each character
takes up two bytes; the macro takes the number of characters in the string as an argument, mul-
tiplies it by two and adds the size of the string descriptor header.
Other descriptors are simply defined like this:
// Manufacturer description
static const char pManufacturer[] = {
USB_STRING_DESCRIPTOR_SIZE(5),
USB_STRING_DESCRIPTOR,
USB_UNICODE('A'),
USB_UNICODE('T'),
USB_UNICODE('M'),
USB_UNICODE('E'),
USB_UNICODE('L')
};
The USB_UNICODE macro simply appends a zero (0) to the array in order to convert a standard
ACSCII character to a UNICODE one.
5.2.3 Class Driver
The demonstration program is going to use the standard request handler discussed in Section
3.5 on page 11 to perform the USB enumeration. To be able to do that, several structures must
be declared.
5.2.3.1 Descriptors List
The S_std_class object needs a pointer to a list of descriptors. This is necessary to be able to
answer the GET_DESCRIPTOR request. An S_std_descriptors instance can be used to do that.
Since it needs a list of string descriptors, this must be created first:
// List of string descriptors
static const char *pStringDescriptors[] = {