I'm currently evaluating how to support 2 configuration descriptors using an xCORE-200 USB sliceKIT with the lib_usb 3.1.1. What I'm trying to accomplish is to have my dev board enumerate as one USB class with it's default configuration descriptor (1), but when the host sends a control transfer of SET_CONFIGURATION with wValue set to 2 (the number of the other configuration) the dev board will enumerate as a different USB class. According to the USB spec, this should be possible and the whole purpose of multiple configuration descriptors.
After snooping around the source code for the USB library, I saw some interesting comments in usb_device.xc stating that only one configuration descriptor is supported (line 227):
Code: Select all
/* Configuration Descriptor */
case (USB_DESCTYPE_CONFIGURATION << 8):
/* Currently only 1 configuration descriptor supported */
/* TODO We currently return the same for all configs */
//if((sp.wValue & 0xff) == 0)
{
if((usbBusSpeed == XUD_SPEED_FS) && (cfgDescLength_fs != 0))
{
/* Return full-speed configuration descriptor */
cfgDesc_fs[1] = USB_DESCTYPE_CONFIGURATION;
return XUD_DoGetRequest(ep_out, ep_in, cfgDesc_fs, cfgDescLength_fs, sp.wLength);
}
else if(cfgDescLength_hs != 0)
{
/* Do get request (send descriptor then 0 length status stage) */
cfgDesc_hs[1] = USB_DESCTYPE_CONFIGURATION;
return XUD_DoGetRequest(ep_out, ep_in, cfgDesc_hs, cfgDescLength_hs, sp.wLength);
}
}
break;
I'm sure I'm making this sound easier than it really is. This is something I will attempt to do in the next day or two, but before I dug in too deep I wanted to see if there was any other limitation I'm not aware of that would warrant this as a futile exercise.
Maybe someone has already done this or has some experience they can share?
Thanks!