All USB devices have a hierarchy of descriptors which describe to the host information such as what device is, who makes it, what version
of USB it supports, how many ways it can be configured, the number of endpoints and their types etc. The more common USB descriptions
are: Device Descriptors, Configurations Descriptors, Interface Descriptors, Endpoint Descriptors, String Descriptors
USB devices can only have one device descriptor. The device descriptor includes information such as what USB revision the device
complies to, the Vendor ID and the Product ID used to load appropriated drivers and the numbers of configurations the device can have.
The number of configurations indicate how many configuration descriptors branches are to follow.
The configuration descriptor specifies values such as the amount of power this particular configuration uses, if the device is self or bus
powered and the number of interfaces it has. When a device is enumerated, the host reads the device descriptors and can make a
decision of which configuration to enable. It can only enable one configuration at a time.
For example, it is possible to have a high power bus powered configuration and a self powered configuration. If the device is plugged into
a host with a mains power supply, the device driver choose to enable high power bus powered configuration enabling the device to be
powered without a connection to the mains, yet it it is connected to a laptop or personal organiser it could enable the 2nd configuration
(self powered) requiring the user to plug your device into the power point. The configuration settings are not limited to power differences.
Each configuration could be powered in the same way and draw the same current, yet have different interface or endpoint combinations.
However it should be noted that changing the configuration requires all activity on each endpoint to stop. While USB offers flexiability,
very few devices have more than 1 configuration.
To enumerate USB devices: usb.h + usb1.c
usb.h >>
usb.c >>
执行结果: