MPLAB Harmony USB Stack
|
Microsoft provides a set of proprietary device classes and USB descriptors, which are called Microsoft OS Descriptors (MODs).
The MPLAB Harmony USB Device Library allows the application to support the Microsoft OS Descriptors requests. To enable Microsoft OS Descriptors, follow below procedure.
/* Extended Compat ID Feature Descriptor */ const uint8_t microsoftExtendedCompatIdDescriptor[] = { 0x28, 0x00, 0x00, 0x00, /* dwLength Length of this descriptor */ 0x00, 0x01, /* bcdVersion = Version 1.0 */ 0x04, 0x00, /* wIndex = 0x0004 */ 0x01, /* bCount = 1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Reserved */ 0x00, /* Interface number = 0 */ 0x01, /* Reserved */ 0x57, 0x49, 0x4E, 0x55, 0x53, 0x42, 0x00, 0x00, /* compatibleID */ //WINUSB 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* subCompatibleID */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* Reserved */ };
case USB_DEVICE_EVENT_CONTROL_TRANSFER_SETUP_REQUEST: { uint16_t length = 0; USB_SETUP_PACKET *setupPacket = (USB_SETUP_PACKET *)pData; if(setupPacket->bRequest == USB_DEVICE_MICROSOFT_OS_DESCRIPTOR_VENDOR_CODE) { if ((setupPacket->bmRequestType == 0xC0) && (setupPacket->W_Index.Val == 0x0004)) { length = setupPacket->wLength; if (length > sizeof(microsoftExtendedCompatIdDescriptor)) { length = sizeof(microsoftExtendedCompatIdDescriptor); } USB_DEVICE_ControlSend(appData.usbDevHandle, (uint8_t*)µsoftExtendedCompatIdDescriptor, length); } else { USB_DEVICE_ControlStatus(appData.usbDevHandle, USB_DEVICE_CONTROL_STATUS_ERROR); } } else { USB_DEVICE_ControlStatus(appData.usbDevHandle, USB_DEVICE_CONTROL_STATUS_ERROR); } break; }
MPLAB Harmony USB Stack
|