Usbconfigurationdescriptor – Comtrol eCos User Manual
Page 685

USB Enumeration Data
example mass-storage devices and human-interface devices. If a peripheral implements one of the standard classes
then a standard existing host-side device driver may exist, eliminating the need to write a custom driver. The
value
0xFF
(
VENDOR
) is reserved for peripherals that implement a vendor-specific protocol rather than a standard
one. Such peripherals will require a custom host-side device driver. The value
0x00
(
INTERFACE
) is reserved and
indicates that the protocol used by the peripheral is defined at the interface level rather than for the peripheral as a
whole.
The
max_package_size
field specifies the maximum length of a control message. There is a lower bound of
eight bytes, and typical hardware will not support anything larger because control messages are usually small and
not performance-critical.
The
vendor_lo
and
vendor_hi
fields specify a vendor id, which must be obtained from the USB Implemen-
tor’s Forum. The numbers used in the code fragment above are examples only and must not be used in real USB
peripherals. The product identifier is determined by the vendor, and different USB peripherals should use different
identifiers. The device identifier field should indicate a release number in binary-coded decimal.
The above fields are all numerical in nature. A USB peripheral can also provide a number of strings as described
, for example the name of the vendor can be provided. The various
_str
fields act as indices into an array
of strings, with index 0 indicating that no string is available.
A typical USB peripheral involves just a single configuration. However more complicated peripherals can support
multiple configurations. Only one configuration will be active at any one time, and the host will switch between
them as appropriate. If a peripheral does involve multiple configurations then typically it will be the responsibility
of application code to
the standard set-configuration control message.
usb_configuration_descriptor
A USB peripheral involves at least one and possible several different configurations. The usbs_enumeration_data
structure requires a pointer to an array, possibly of length 1, of usb_configuration_descriptor structures. Usually a
single structure suffices:
const usb_configuration_descriptor usb_configuration = {
length:
USB_CONFIGURATION_DESCRIPTOR_LENGTH,
type:
USB_CONFIGURATION_DESCRIPTOR_TYPE,
total_length_lo:
USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH_LO(1, 2),
total_length_hi:
USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH_HI(1, 2),
number_interfaces:
1,
configuration_id:
1,
configuration_str:
0,
attributes:
USB_CONFIGURATION_DESCRIPTOR_ATTR_REQUIRED |
USB_CONFIGURATION_DESCRIPTOR_ATTR_SELF_POWERED,
max_power:
50
};
const usbs_enumeration_data usb_enum_data = {
...
configurations:
&usb_configuration,
...
};
The values for the
length
and
type
fields are determined by the standard. The
total_length
field depends
on the number of interfaces and endpoints used by this configuration, and convenience macros are provided to
581