From d9d29d3c68dcf662920493cd1f585730710b1a24 Mon Sep 17 00:00:00 2001 From: sago35 Date: Fri, 13 May 2022 20:28:05 +0900 Subject: [PATCH] add Interface Association Descriptor --- src/machine/usb/desc-cdc.go | 17 ++++++++++++++--- src/machine/usb/desc.go | 26 ++++++++++++++++---------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/machine/usb/desc-cdc.go b/src/machine/usb/desc-cdc.go index f4a526e31..ad13d8039 100644 --- a/src/machine/usb/desc-cdc.go +++ b/src/machine/usb/desc-cdc.go @@ -159,6 +159,7 @@ const ( descCDCConfigSize = uint16( descLengthConfigure + // Configuration Header descLengthInterface + // CDC Interface Descriptor + descLengthInterfaceAssociation + // IAD descCDCFuncLengthHeader + // CDC Header descCDCFuncLengthCallManagement + // CDC Call Management Func Descriptor descCDCFuncLengthAbstractControl + // CDC Abstract Control Func Descriptor @@ -282,9 +283,9 @@ var descCDC = [dcdCount]descCDCClass{ descTypeDevice, // Descriptor Type lsU8(descUSBSpecVersion), // USB Specification Release Number in BCD (low) msU8(descUSBSpecVersion), // USB Specification Release Number in BCD (high) - 0, // Class code (assigned by the USB-IF). - 0, // Subclass code (assigned by the USB-IF). - 0, // Protocol code (assigned by the USB-IF). + descDeviceClassCodeMisc, // Class code (assigned by the USB-IF). + descDeviceSubClassCommon, // Subclass code (assigned by the USB-IF). + descDeviceProtocolIAD, // Protocol code (assigned by the USB-IF). descEndptMaxPktSize, // Maximum packet size for endpoint zero (8, 16, 32, or 64) lsU8(descCommonVendorID), // Vendor ID (low) (assigned by the USB-IF) msU8(descCommonVendorID), // Vendor ID (high) (assigned by the USB-IF) @@ -320,6 +321,16 @@ var descCDC = [dcdCount]descCDCClass{ descEndptConfigAttr, // Configuration attributes descCDCMaxPowerMa >> 1, // Max power consumption when fully-operational (2 mA units) + // Interface Association Descriptor + descLengthInterfaceAssociation, // Size of this descriptor in bytes + descTypeInterfaceAssociation, // Descriptor Type + 0x00, // bFirstInterface + descCDCInterfaceCount, // bInterfaceCount + 0x02, // bFunctionClass : Communications and CDC Control (0x02) + 0x02, // bFunctionSubClass + 0x00, // bFunctionProtocol + 0x00, // iFunction + // Communication/Control Interface Descriptor descLengthInterface, // Descriptor length descTypeInterface, // Descriptor type diff --git a/src/machine/usb/desc.go b/src/machine/usb/desc.go index a75e8d143..5c4285676 100644 --- a/src/machine/usb/desc.go +++ b/src/machine/usb/desc.go @@ -8,16 +8,17 @@ const descLanguageEnglish = uint16(0x0409) // (US) English const ( // Descriptor length - descLengthDevice = 18 - descLengthConfigure = 9 - descLengthInterface = 9 - descLengthEndpoint = 7 - descLengthQualification = 10 - descLengthOTG = 5 - descLengthBOS = 5 - descLengthEndpointCompanion = 6 - descLengthUSB20Extension = 7 - descLengthSuperspeed = 10 + descLengthDevice = 18 + descLengthConfigure = 9 + descLengthInterface = 9 + descLengthInterfaceAssociation = 8 + descLengthEndpoint = 7 + descLengthQualification = 10 + descLengthOTG = 5 + descLengthBOS = 5 + descLengthEndpointCompanion = 6 + descLengthUSB20Extension = 7 + descLengthSuperspeed = 10 // Descriptor type descTypeDevice = 0x01 @@ -133,6 +134,11 @@ const ( descDeviceCapExtAttrLPMPos = 1 descDeviceCapExtAttrBESLMsk = 0x04 descDeviceCapExtAttrBESLPos = 2 + + // Device class + descDeviceClassCodeMisc = 0xEF + descDeviceSubClassCommon = 0x02 + descDeviceProtocolIAD = 0x01 ) // descEndpointInvalid represents an invalid endpoint address.