|
Hi,
You are right that the FX3 SDK does not let you set a OS descriptor using the CyU3PUsbSetDesc() API.
However, this does not prevent you from supporting a OS descriptor in your application. You can support do this at the application level by handling the request in your setup callback function. See the below code snippet:
/* Microsoft OS Descriptor. */ const uint8_t CyFxUsbOSDscr[] __attribute__ ((aligned (32))) = { 0x0E, CY_U3P_USB_STRING_DESCR, 'O', 0x00, 'S', 0x00, ' ', 0x00, 'D', 0x00, 'e', 0x00, 's', 0x00, 'c', 0x00 }; /* Callback to handle the USB setup requests. */ CyBool_t CyFxBulkSrcSinkApplnUSBSetupCB ( uint32_t setupdat0, /* SETUP Data 0 */ uint32_t setupdat1 /* SETUP Data 1 */ ) { /* Fast enumeration is used. Only requests addressed to the interface, class, * vendor and unknown control requests are received by this function. * This application does not support any class or vendor requests. */ uint8_t bRequest, bReqType; uint8_t bType, bTarget; uint16_t wValue, wIndex, wLength; CyBool_t isHandled = CyFalse; /* Decode the fields from the setup request. */ bReqType = (setupdat0 & CY_U3P_USB_REQUEST_TYPE_MASK); bType = (bReqType & CY_U3P_USB_TYPE_MASK); bTarget = (bReqType & CY_U3P_USB_TARGET_MASK); bRequest = ((setupdat0 & CY_U3P_USB_REQUEST_MASK) >> CY_U3P_USB_REQUEST_POS); wValue = ((setupdat0 & CY_U3P_USB_VALUE_MASK) >> CY_U3P_USB_VALUE_POS); wIndex = ((setupdat1 & CY_U3P_USB_INDEX_MASK) >> CY_U3P_USB_INDEX_POS); wLength = ((setupdat1 & CY_U3P_USB_LENGTH_MASK) >> CY_U3P_USB_LENGTH_POS); if (bType == CY_U3P_USB_STANDARD_RQT) { /* Handle Microsoft OS String Descriptor request. */ if ((bTarget == CY_U3P_USB_TARGET_DEVICE) && (bRequest == CY_U3P_USB_SC_GET_DESCRIPTOR) && (wValue == ((CY_U3P_USB_STRING_DESCR << 8) | 0xEE))) { /* Make sure we do not send more data than requested. */ if (wLength > CyFxUsbOSDscr[0]) wLength = CyFxUsbOSDscr[0]; CyU3PUsbSendEP0Data (wLength, (uint8_t *)CyFxUsbOSDscr); isHandled = CyTrue; } /* Handle other requests below as required. */ } return isHandled; } For now, please use the above work-around. API level support for registering a OS descriptor
will be added in a later FX3 SDK release.
|