This fork re-enables FRDM boards and adds WebUSB CDC functionality

Fork of USBDevice_STM32F103 by Devan Lai

Revision:
72:1d8a6665d607
Parent:
67:39396cc073f2
--- a/WebUSBDevice/WebUSBDevice.cpp	Sun Jan 08 12:39:00 2017 +0000
+++ b/WebUSBDevice/WebUSBDevice.cpp	Tue Jul 11 21:02:39 2017 +0200
@@ -1,5 +1,6 @@
 /*
 * Copyright 2016 Devan Lai
+* Modifications copyright 2017 Lars Gunder Knudsen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -21,6 +22,7 @@
 #include "USBDescriptor.h"
 #include "WebUSB.h"
 #include "WebUSBDevice.h"
+#include "../USBDFU/WinUSB.h"
 
 WebUSBDevice::WebUSBDevice(uint16_t vendor_id, uint16_t product_id, uint16_t product_release)
     : USBDevice(vendor_id, product_id, product_release)
@@ -131,7 +133,7 @@
 }
 
 #define WEBUSB_BOS_TOTAL_LENGTH (BINARY_OBJECT_STORE_DESCRIPTOR_LENGTH \
-                                 + WEBUSB_PLATFORM_DESCRIPTOR_LENGTH)
+                                 + WEBUSB_PLATFORM_DESCRIPTOR_LENGTH + 28)
 
 uint8_t * WebUSBDevice::binaryObjectStoreDesc() {
     static uint8_t binaryObjectStoreDescriptor[] = {
@@ -139,7 +141,9 @@
         BINARY_OBJECT_STORE_DESCRIPTOR, /* bDescriptorType */
         LSB(WEBUSB_BOS_TOTAL_LENGTH),   /* wTotalLength (LSB) */
         MSB(WEBUSB_BOS_TOTAL_LENGTH),   /* wTotalLength (MSB) */
-        0x01,                           /* bNumDeviceCaps */
+        0x02,                           /* bNumDeviceCaps (WebUSB + WinUSB) */
+
+        // WebUSB
         WEBUSB_PLATFORM_DESCRIPTOR_LENGTH, /* bLength */
         DEVICE_CAPABILITY_DESCRIPTOR,   /* bDescriptorType */
         USB_DC_PLATFORM,                /* bDevCapabilityType */
@@ -152,6 +156,18 @@
         MSB(WEBUSB_VERSION_1_0),        /* bcdVersion (MSB) */
         WEBUSB_VENDOR_CODE,             /* bVendorCode */
         URL_OFFSET_LANDING_PAGE,        /* iLandingPage */
+
+        // Windows related (to get WinUSB auto-loaded)
+        0x1C, 0x10, 0x05, 0x00, /* Microsoft OS 2.0 Platform Capability Descriptor */
+        
+        0xDF, 0x60, 0xDD, 0xD8,  /* MS OS 2.0 Platform Capability ID */
+        0x89, 0x45, 0xC7, 0x4C,
+        0x9C, 0xD2, 0x65, 0x9D,
+        0x9E, 0x64, 0x8A, 0x9F,
+
+        0x00, 0x00, 0x03, 0x06, /* Windows version */
+        
+        0xB2, 0x00, WINUSB_VENDOR_CODE, 0x00 /* MS OS 2.0 descriptor size (word), vendor code, no alternate enumeration */
     };
     return binaryObjectStoreDescriptor;
 }