This fork re-enables FRDM boards and adds WebUSB CDC functionality
Fork of USBDevice_STM32F103 by
Diff: USBDFU/WebUSBDFU.cpp
- Revision:
- 68:c190028858f9
- Parent:
- 67:39396cc073f2
- Child:
- 70:e410de636542
diff -r 39396cc073f2 -r c190028858f9 USBDFU/WebUSBDFU.cpp --- a/USBDFU/WebUSBDFU.cpp Sun Sep 04 03:13:09 2016 +0000 +++ b/USBDFU/WebUSBDFU.cpp Sun Sep 04 09:54:47 2016 +0000 @@ -20,6 +20,7 @@ #include "WebUSBDFU.h" #include "WebUSB.h" #include "DFU.h" +#include "WinUSB.h" #include "USBDescriptor.h" @@ -56,9 +57,54 @@ bool WebUSBDFU::USBCallback_request() { bool success = false; CONTROL_TRANSFER * transfer = getTransferPtr(); - + + // Handle the Microsoft OS Descriptors 1.0 special string descriptor request + if ((transfer->setup.bmRequestType.Type == STANDARD_TYPE) && + (transfer->setup.bRequest == GET_DESCRIPTOR) && + (DESCRIPTOR_TYPE(transfer->setup.wValue) == STRING_DESCRIPTOR) && + (DESCRIPTOR_INDEX(transfer->setup.wValue) == 0xEE)) + { + static uint8_t msftStringDescriptor[] = { + 0x12, /* bLength */ + STRING_DESCRIPTOR, /* bDescriptorType */ + 'M',0,'S',0,'F',0,'T',0,'1',0,'0',0,'0',0, /* qWSignature - MSFT100 */ + WINUSB_VENDOR_CODE, /* bMS_VendorCode */ + 0x00, /* bPad */ + }; + + transfer->remaining = msftStringDescriptor[0]; + transfer->ptr = msftStringDescriptor; + transfer->direction = DEVICE_TO_HOST; + success = true; + } + // Process Microsoft OS Descriptors 1.0 Compatible ID requests + else if ((transfer->setup.bmRequestType.Type == VENDOR_TYPE) && + (transfer->setup.bmRequestType.Recipient == DEVICE_RECIPIENT) && + (transfer->setup.bRequest == WINUSB_VENDOR_CODE) && + (transfer->setup.wIndex == WINUSB_GET_COMPATIBLE_ID_FEATURE_DESCRIPTOR)) + { + static uint8_t msftCompatibleIdDescriptor[] = { + 0x28, 0x00, 0x00, 0x00, /* dwLength */ + LSB(COMPATIBLE_ID_VERSION_1_0), /* bcdVersion (LSB) */ + MSB(COMPATIBLE_ID_VERSION_1_0), /* bcdVersion (MSB) */ + LSB(WINUSB_GET_COMPATIBLE_ID_FEATURE_DESCRIPTOR), /* wIndex (LSB) */ + MSB(WINUSB_GET_COMPATIBLE_ID_FEATURE_DESCRIPTOR), /* wIndex (MSB) */ + 0x01, /* bCount */ + 0, 0, 0, 0, 0, 0, 0, /* reserved */ + DFU_INTERFACE_NUMBER, /* bFirstInterfaceNumber */ + 0x00, /* reserved */ + 'W','I','N','U','S','B',0,0, /* compatible ID - WINUSB */ + 0, 0, 0, 0, 0, 0, 0, 0, /* subCompatibleID */ + 0, 0, 0, 0, 0, 0, /* reserved */ + }; + + transfer->remaining = sizeof(msftCompatibleIdDescriptor); + transfer->ptr = msftCompatibleIdDescriptor; + transfer->direction = DEVICE_TO_HOST; + success = true; + } // Process DFU class-specific requests - if (transfer->setup.bmRequestType.Type == CLASS_TYPE) + else if (transfer->setup.bmRequestType.Type == CLASS_TYPE) { switch (transfer->setup.bRequest) {