Closed trusktr closed 10 years ago
This is defined by the USB specification; the host will first request the single Device Descriptor from the attached USB device, and read its contents. From the NumberOfConfigurations
field, it can determine how many distinct configurations the device supports, and thus the total number of Configuration Descriptors it contains.
To retrieve the Configuration Descriptor(s), the host will issue a GetDescriptor control request to the device, with the lower 8-bits of the wValue
request parameter indicating which descriptor it is interested in receiving. A host will typically retrieve all Configuration Descriptor(s) in sequence, then issue a SetConfiguration
control request to choose the one it wishes to use.
It is your responsibility to map the wValue
index to each of the Configuration Descriptor(s) in your device via the CALLBACK_USB_GetDescriptor()
function -- look at the way to the String descriptors are mapped as an example.
Note that it is extremely uncommon for USB devices to have more than one configuration - typically devices only have one configuration which exposes multiple features (such as a combined keyboard and mouse).
That was so helpful. Thank you Dean!
I see that
USB_Descriptor_Device_t
has a field calledNumberOfConfigurations
, and I see theUSB_Descriptor_Configuration_t
stuct, but I'm not sure how I specify that aUSB_Descriptor_Configuration_t
belongs to aUSB_Descriptor_Device_t
.Does the compiler or the running program somehow automatically associate
NumberOfConfigurations
USB_Descriptor_Configuration_t
s with aUSB_Descriptor_Device_t
? If so, do they get associated in the order defined?Maybe I just don't know enough about USB yet, but I was expecting
USB_Descriptor_Device_t
to containUSB_Descriptor_Configuration_t
s (or an array of pointers to them).