【USB笔记】接口描述符Interface Descriptor

您所在的位置:网站首页 x90j的usb接口 【USB笔记】接口描述符Interface Descriptor

【USB笔记】接口描述符Interface Descriptor

2024-07-11 15:41:24| 来源: 网络整理| 查看: 265

USB笔记 接口描述符 (Interface Descriptor)

接口描述符(Interface Descriptor)描述了配置中一个特定的接口。配置提供了一个或多个接口,每个接口都含有类(Class),子类(SubClass)和协议(Protocol)的信息,以及接口所使用的端点(Endpoint)数目。

接口描述符(Interface Descriptor)总是作为配置描述符的一部分返回,不能直接用Get Descriptor或者Set Descriptor请求访问。

一个配置可含有多个同时活跃的接口。这些接口可能联合于某个功能,也可能并不相关。

每个接口都有它自己的接口描述符(Interface Descriptor)和附属描述符(subordinate descriptor)。

所有这些接口也都可拥有一个或多个替代的接口设置(alternate interface settings)。这些设置是相互排他的,每次只能有一个被激活。每个设置含有一个接口描述符(Interface Descriptor)及所的附属描述符(subordinate descriptor)。使用等时传输(isochronous transfers)的设备必须有替代接口设置(alternate interface settings),因为缺省的接口不能请求等时带宽(isochronous bandwidth)。

Interface Descriptor OffsetFieldSizeValueDescription0bLength1Number以字节为单位的描述符大小1bDescriptorType1Constant接口描述符类型2bInterfaceNumber1Number接口的编号3bAlternateSetting1Number用来确认bInterfaceNumber的替代设置的编号4bNumEndpoints1Number接口使用的端点数量5bInterfaceClass1Class类码6bInterfaceSubClass1SubClass子类码7bInterfaceProtocol1Protocol协议码8iInterface1Index接口字符串描述符的索引

bLength以字节为单位的描述符大小(0x09)。

bDescriptorType接口描述符类型,为INTERFACE(0x04)。

bInterfaceNumber接口的编号。表示该配置同时支持的接口序列索引。编号的值从0开始,缺省值为0x00。每个接口描述符中,该字段取值必须唯一。在组合设备(composite device )的配置中拥有多个同时活动的接口。

bAlternateSetting用来确认bInterfaceNumber的替代设置的编号。对于每个bInterfaceNumber ,设备将提供一个bAlternateSetting 字段为0x00的接口描述字,这是缺省的设置。替代设置的描述符bInterfaceNumber字段与缺省设备的值是相同的,但是bAlternateSetting的值不同,然后替代设置的描述符的最后5个字节的取值也会根据实际情况而不同。

对于每个bInterfaceNumber,每次只有一个bAlternateSetting 可被激活。替代设置可使主机能够请求带有不同带宽或其他要求和性能的接口。Get Interface请求会取得当前被激活的bAlternateSetting。Set Interface请求可选择特定bInterfaceNumber所应当使用的bAlternateSetting。

bNumEndpoints这个接口使用的端点数量(不包括端点0)。如果这个值为0,那么这个接口使用默认的控制管道(Control Pipe),既只使用端点0。

bInterfaceClass类码(Class code),这个类码(Class code)由USB-IF分配。除了用于由接口规定的设备外,其他与设备描述符(Device Descriptor)中bDeviceClass 字段相同。

值0x00为保留值,从0x01 – 0xFE的值保留给USB定义的类,0xFF作为厂商定义的类。

Class CodeDescription0x00保留(Reserved)0x01音频(Audio)0x02通讯设备:通讯接口(Communications device: communication interface)0x03人机接口设备(Human interface device)0x05物理(Physical)0x06图像(Image)bInterfaceSubclass = 0x01bInterfaceProtocol = 0x01: Imaging device0x07打印机(Printer)0x08大容量存储(Mass storage)0x09集线器(Hub) (还必须在设备描述符(device descriptor)中声明 )0x0A通讯设备:数据接口(Communications device: data interface)0x0B智能卡(Smart Card)0x0D内容安全(Content Security)bInterfaceSubclass = 0x01bInterfaceProtocol = 0x01: Content security device0x0E视频(Video)0x0F个人健康设备(Personal healthcare device) (can instead be declared at the device level)0x10Audio/Video (AV):bInterfaceSubclass = 0x01bInterfaceProtocol = 0x00: AVControl InterfacebInterfaceSubclass = 0x02bInterfaceProtocol = 0x00: AVData Video Streaming InterfacebInterfaceSubclass = 0x03bInterfaceProtocol = 0x00: AVData Audio Streaming Interface0xDC诊断设备Diagnostic device (can instead be declared at the device level)bInterfaceSubclass= 0x01bInterfaceProtocol = 0x01: USB2 compliance device0xE0无线控制器Wireless controllerbInterfaceSubclass = 0x01bInterfaceProtocol = 0x01: Bluetooth programming interface (should also bedeclared at the device level)bInterfaceProtocol = 0x02: UWB Radio control interface (Wireless USB)bInterfaceProtocol = 0x03: RNDISbInterfaceProtocol = 0x04: Bluetooth AMP controller (should also be declared at the device level)bInterfaceSubclass = 0x02: Host and device wire adapters (Wireless USB)bInterfaceProtocol = 0x01: Host wire adapter control/data interfacebInterfaceProtocol = 0x02: Device wire adapter control/data interfacebInterfaceProtocol = 0x03: Device wire adapter isochronous interface0xEF各种各样的MiscellaneousbInterfaceSubclass = 0x01bInterfaceProtocol = 0x01: active syncbInterfaceProtocol = 0x02: Palm syncbInterfaceSubclass = 0x02bInterfaceProtocol = 0x01: Interface Association DescriptorbInterfaceProtocol = 0x02: Wire Adapter Multifunction Peripheral programminginterfacebInterfaceSubclass = 0x03: Cable based association framework (Wireless USB)bInterfaceProtocol = 0x01: Cable based association framework devicebInterfaceSubclass = 0x04bInterfaceProtocol = 0x01: RNDIS over EthernetbInterfaceProtocol = 0x02: RNDIS over WiFibInterfaceProtocol = 0x03: RNDIS over MaximbInterfaceProtocol = 0x04: RNDIS over WWANbInterfaceProtocol = 0x05: RNDIS for Raw IPv4bInterfaceProtocol = 0x06: RNDIS for Raw IPv6bInterfaceProtocol = 0x07: RNDIS for GPRSbInterfaceSubclass = 0x05: Machine vision device (USB3 Vision)bInterfaceProtocol = 0x00: USB3 Vision Control InterfacebInterfaceProtocol = 0x01: USB0 Vision Event InterfacebInterfaceProtocol = 0x02: USB3 Vision Streaming Interface0xFE应用程序专属Application specificbInterfaceSubclass = 0x01: Device firmware upgradebInterfaceSubclass = 0x02: IrDA bridgebInterfaceSubclass = 0x03: Test and measurement (USBTMC)bInterfaceProtocol = 0x00: Complies with USBTMC specbInterfaceProtocol = 0x01: Complies with USBTMC USB488 subclass0xFF厂商专属Vendor specific (can instead be declared at the device level)

bInterfaceSubClass子类码(SubClass code),这个子类码(SubClass code)由USB-IF分配。这个值由bInterfaceClass字段所限定。除了带有由接口定义的类的设备之外,此字段与设备描述符(Device Descriptor)中的bDeviceSubClass字段相同。如果bInterfaceClass等于0x00,则bInterfaceSubClass也必须等于0x00。如果bIntefaceClass是0x01–0xFE范围的值,则bInterfaceSubClass等于0x00或等于一个为接口的类定义的码。0xFF表明为厂商定义的子类(SubClass)。

bInterfaceProtocol协议码(Protocol code),这个协议码(Protocol code)由USB-IF分配。这个值由bInterfaceClass字段和bInterfaceSubClass字段所限定。如果接口支持专用的类型请求,这个协议码能识别出由协议类型规范定义、设备使用的协议。如果bInterfaceClass等于0x00,设备在这个接口不使用专门的类协议。如果为0xFF,设备在这个接口使用专用的厂商协议。除了带有由接口定义的类的设备之外,此字段与设备描述符(Device Descriptor)中的bDeviceProtocol字段相同。如果bIntefaceClass 是0x01–0xFE范围的值,则bInterfaceProtocol 等于0x00或等于一个为接口的类定义的码。

iInterface描述这个接口的字符串描述符的索引。如果没有字符串描述符的话则此值为0。

获取接口描述符

主机通过发送Get Descriptor请求,取得配置描述符,接口描述符,端点描述符及其附属描述符。

接口描述符(Interface Descriptor)总是作为配置描述符Configuration Descriptor的一部分返回,不能单独获取。

Get DescriptorValuebmRequestType0x80  bmRequestType.Recipient0b00000(Device)  bmRequestType.Type0b00(Standard)  bmRequestType.Direction0b1(Device-to-Host)bRequest0x06(Get Descriptor)wValue0x0200(Configuration #0)wIndex0x0000wLength0x???(wTotalLength)

下面举例说明一个获取接口描述符的过程。 获取一个键盘的接口描述符,该键盘的接口描述符如下所示: 0

使用USB分析仪抓包可以看到,获取配置描述符Configuration Descriptor,而接口描述符Interface Descriptor就包含在其中: 1

接口描述符Interface Descriptor的获取过程如下: 2

再展开看到详细的过程: 3

接下来详细看整个获取过程的各个字段含义: 4

一开始的setup包过程: 5

setup data: 6

IN包过程 7

OUT包过程: 8

完成整个接口描述符Interface Descriptor的获取。

描述符示例

这里举例一个带有该描述符的示例设备,这是一个键盘Keyboard的完整描述符信息。

Device Descriptor OffsetFieldSizeValueDescription0bLength10x121bDescriptorType10x01DEVICE2bcdUSB20x01101.104bDeviceClass10x005bDeviceSubClass10x006bDeviceProtocol10x007bMaxPacketSize010x088idVendor20x046d10idProduct20xc31c12bcdDevice20x640064.0014iManufacturer10x0115iProduct10x0216iSerialNumber10x0017bNumConfigurations10x01 Configuration Descriptor OffsetFieldSizeValueDescription0bLength10x091bDescriptorType10x02CONFIGURATION2wTotalLength20x003b4bNumInterfaces10x025bConfigurationValue10x016iConfiguration10x037bmAttributes10xa08bMaxPower10x2d Interface Descriptor OffsetFieldSizeValueDescription0bLength10x091bDescriptorType10x04INTERFACE2bInterfaceNumber10x003bAlternateSetting10x004bNumEndpoints10x015bInterfaceClass10x03Human Interface Device6bInterfaceSubClass10x01Boot Interface7bInterfaceProtocol10x01Keyboard8iInterface10x02 HID Descriptor OffsetFieldSizeValueDescription0bLength10x091bDescriptorType10x21HID2bcdHID20x01101.104bCountryCode10x005bNumDescriptors10x016bDescriptorType10x22REPORT7wDescriptorLength20x0041 Endpoint Descriptor OffsetFieldSizeValueDescription0bLength10x071bDescriptorType10x05ENDPOINT2bEndpointAddress10x811 IN3bmAttributes10x03Interrupt4wMaxPacketSize20x00086bInterval10x0a Interface Descriptor OffsetFieldSizeValueDescription0bLength10x091bDescriptorType10x04INTERFACE2bInterfaceNumber10x013bAlternateSetting10x004bNumEndpoints10x015bInterfaceClass10x03Human Interface Device6bInterfaceSubClass10x007bInterfaceProtocol10x008iInterface10x02 HID Descriptor OffsetFieldSizeValueDescription0bLength10x091bDescriptorType10x21HID2bcdHID20x01101.104bCountryCode10x005bNumDescriptors10x016bDescriptorType10x22REPORT7wDescriptorLength20x009f Endpoint Descriptor OffsetFieldSizeValueDescription0bLength10x071bDescriptorType10x05ENDPOINT2bEndpointAddress10x822 IN3bmAttributes10x03Interrupt4wMaxPacketSize20x00046bInterval10xff 附录 USB1.x/USB 2.0/USB 3.x Interface Descriptor OffsetFieldSizeValueDescription0bLength1NumberSize of this descriptor in bytes1bDescriptorType1ConstantINTERFACE Descriptor Type2bInterfaceNumber1NumberNumber of this interface. Zero-based value identifying the index in the array of concurrent interfaces supported by this configuration.3bAlternateSetting1NumberValue used to select this alternate setting for the interface identified in the prior field.4bNumEndpoints1NumberNumber of endpoints used by this interface (excluding endpoint zero). If this value is zero, this interface only uses the Default Control Pipe.5bInterfaceClass1ClassClass code (assigned by the USB-IF).A value of zero is reserved for future standardization.If this field is set to FFH, the interface class is vendor-specific.All other values are reserved for assignment by the USB-IF.6bInterfaceSubClass1SubClassSubclass code (assigned by the USB-IF).These codes are qualified by the value of the bInterfaceClass field.If the bInterfaceClass field is reset to zero, this field must also be reset to zero.If the bInterfaceClass field is not set to FFH, all values are reserved for assignment by the USB-IF.7bInterfaceProtocol1ProtocolProtocol code (assigned by the USB).These codes are qualified by the value of the bInterfaceClass and the bInterfaceSubClass fields. If an interface supports class-specific requests, this code identifies the protocols that the device uses as defined by the specification of the device class.If this field is reset to zero, the device does not use a class-specific protocol on this interface.If this field is set to FFH, the device uses a vendor-specific protocol for this interface.8iInterface1IndexIndex of string descriptor describing this interface. [参考资料]

Universal Serial Bus Specification Revision 1.0

Universal Serial Bus Specification Revision 1.1

Universal Serial Bus Specification Revision 2.0

Universal Serial Bus 3.0 Specification

Universal Serial Bus 3.1 Specification

Universal Serial Bus 3.2 Specification

USB Complete, 5th Edition

USB开发大全

USB2.0与OTG规范及开发指南

本文链接:https://blog.csdn.net/u012028275/article/details/109567196



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭