【USB笔记】端点描述符Endpoint Descriptor

USB笔记 端点描述符 (Endpoint Descriptor)

端点描述符 (Endpoint Descriptor)描述了USB规范定义的端点信息,包含有端点的带宽等信息。每一个端点都有自己的端点描述符。主机端获取端点描述符 (Endpoint Descriptor),总是作为配置描述符(Configuration Descriptor)的一部分返回,不能直接用Get Descriptor或者Set Descriptor请求访问。

Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength1Number以字节为单位的描述符大小
1bDescriptorType1Constant端点描述符类型
2bEndpointAddress1Endpoint设备的端点地址
3bmAttributes1Bitmap端点的属性
4wMaxPacketSize2Number端点能发送或接收的最大数据包大小
6bInterval1Number查询端点进行数据传输的间隔

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

bDescriptorType端点描述符类型,为ENDPOINT (0x05)。

bEndpointAddress 设备的端点地址。

Bits 3…0是端点号,低速设备(Low-speed devices)最多拥有3个端点号(0–2),其他设备则最多拥有16个端点号(0–15)。

Bits 6…4 未使用,保留,必须为0。

Bit 7是方向,OUT = 0 ,IN = 1,控制端点(control endpoints)忽略这个位。

bmAttributes端点的属性。

Bits 1…0表示传输类型,00b表示控制(control),01b表示等时(isochronous), 10b表示批量(bulk),11b表示中断(interrupt)。

Bits 7…6 未使用,保留,必须为0。

Bits 5…2的功能会随端点的类型和速度而改变:

如果是等时端点(isochronous endpoint),Bits 5…2表示同步类型和数据或反馈的使用类型:

Bits 3…2 同步类型(Synchronization Type),00b表示非同步(No Synchronization),01b表示异步(Asynchronous), 10b表示自适应(Adaptive),11b表示同步(Synchronous)。

Bits 5…4 使用类型(Usage Type),00b表示数据端点(Data endpoint),01b表示反馈端点(Feedback endpoint), 10b表示隐式反馈数据端点(Implicit feedback Data endpoint),11b保留(Reserved)。

如果Bits 5…4等于01b,是反馈端点(Feedback endpoint),那么Bits 1…0的传输类型必须为01b,设为等时(isochronous),Bits 3…2的同步类型(Synchronization Type)必须为00b,设为非同步(No Synchronization)。

如果是增强型超高速中断端点(Enhanced SuperSpeed interrupt endpoint),Bits 5…2表示使用类型(Usage Type):

Bits 3…2未使用,保留。

Bits 5…4 使用类型(Usage Type),00b表示周期(Periodic),01b表示通知(Notification), 10b和11b保留(Reserved)。

如果是其他端点,Bits 5…2未使用,保留,必须为0。

wMaxPacketSize端点能发送或接收的最大数据包大小。不同的速度与传输类型,值的含义不同。

在USB2.0协议中,bits 10…0规定了最大数据包大小,范围0–1024。

对于高速(high-speed)等时(isochronous)和中断(interrupt)端点,Bits 12…11表示每个微帧(microframe)所支持的额外事务数目,00b表明没有额外事务(每个微帧1个事务),01b表示有1个额外事务(每个微帧2个事务),10b表示2个额外事务(每个微帧3个事务),11b表示保留。

其他传输速度与传输类型端点,Bits 12…11未使用。

Bits 15…13未使用,保留,必须为0。

在USB1.x协议中,范围是0–1023。

Bits 12…11保留且必须为0。

Bits 15…13未使用,保留,必须为0。

在USB3.x协议中,对于增强型超高速传输(Enhanced SuperSpeed)

对于控制端点(control endpoints),这个字段必须设为512。

对于批量端点(bulk endpoint),这个字段必须设为1024。

对于中断(interrupt)和等时端点(isochronous endpoints),这个字段的值的大小决定于超高速端点伙伴描述符(SuperSpeed Endpoint Companion Descriptor)中bMaxBurst 的值。如果bMaxBurst 大于0,那么这个字段的值为1024。如果bMaxBurst 等于0,那么对于等时端点 (isochronous endpoint),取值范围是0-1024,对于中断端点(interrupt endpoint),取值范围是1-1024。

bInterval查询端点进行数据传输的间隔。不同的速度与传输类型,值的含义不同。

这个间隔周期以帧(frames)或者微型帧(microframes)为单位进行表示,也就是单位为1ms或者125us。

对于中断端点(interrupt endpoints),在这个间隔周期里面,主机必须安排端点事务。

对于全速(full-speed)/低速(low-speed)中断端点,该字段为最大等待时间,主机必须在这个周期里安排端点事务。单位为ms,取值范围是1-255。全速端点速度限定为1ms-255ms,低速端点速度限定为10ms-255ms。

对于高速(high-speed)中断端点,这个字段bInterval 的值是作为 2 b I n t e r v a l − 1 2^{bInterval - 1} 2bInterval1的指数,例如bInterval是4,那就表示周期为8( 2 4 − 1 2^{4 - 1} 241),8个微型帧(microframes),也就是125us×8=1ms。这个值的取值范围为1-16。

对于等时端点(isochronous endpoints),在这个间隔周期里面,主机必须安排端点事务。这个字段bInterval 的值是作为 2 b I n t e r v a l − 1 2^{bInterval - 1} 2bInterval1的指数,例如bInterval是4,那就表示周期为8( 2 4 − 1 2^{4 - 1} 241)。

对于全速(full-speed)/高速(high-speed)/增强型超高速端点(Enhanced SuperSpeed endpoints)等时端点,这个值的取值范围为1-16。全速端点的时间范围是1ms-32.768s,高速和超高速端点的时间范围是125us-4.096s

对于USB1.x的等时端点,这个值必须为1。

对于高速(high-speed)批量和控制(bulk/control)OUT端点,此字段表示最大NAK速率,传输中要符合这个字段的要求。值为0表示端点从不发出NAK;其他值表示在用NAK响应OUT处理之后,下一次重试是在bInterval个微型帧之后。这个值的范围为0-255。设备通常设置为0。

对于其他批量和控制端点,此值未使用,被保留。

获取端点描述符

主机通过发送Get Descriptor请求,取得配置描述符,接口描述符,端点描述符及其附属描述符。端点描述符 (Endpoint Descriptor)总是作为配置描述符的一部分返回。

Get DescriptorValue
bmRequestType0x80
  bmRequestType.Recipient0b00000(Device)
  bmRequestType.Type0b00(Standard)
  bmRequestType.Direction0b1(Device-to-Host)
bRequest0x06(Get Descriptor)
wValue0x0200(Configuration #0)
wIndex0x0000
wLength0x???(wTotalLength)

下面举例说明一个获取端点描述符的过程。
获取一个键盘的端点描述符,该键盘的端点描述符如下所示:
在这里插入图片描述

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

端点描述符Endpoint Descriptor的获取过程如下:
2

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

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

一开始的setup包过程:
5

setup data:
6

IN包过程
7

OUT包过程:
8

完成整个端点描述符Endpoint Descriptor的获取。


描述符示例

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

Device Descriptor

OffsetFieldSizeValueDescription
0bLength10x12
1bDescriptorType10x01DEVICE
2bcdUSB20x01101.10
4bDeviceClass10x00
5bDeviceSubClass10x00
6bDeviceProtocol10x00
7bMaxPacketSize010x08
8idVendor20x046d
10idProduct20xc31c
12bcdDevice20x640064.00
14iManufacturer10x01
15iProduct10x02
16iSerialNumber10x00
17bNumConfigurations10x01

Configuration Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x02CONFIGURATION
2wTotalLength20x003b
4bNumInterfaces10x02
5bConfigurationValue10x01
6iConfiguration10x03
7bmAttributes10xa0
8bMaxPower10x2d

Interface Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x04INTERFACE
2bInterfaceNumber10x00
3bAlternateSetting10x00
4bNumEndpoints10x01
5bInterfaceClass10x03Human Interface Device
6bInterfaceSubClass10x01Boot Interface
7bInterfaceProtocol10x01Keyboard
8iInterface10x02

HID Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x21HID
2bcdHID20x01101.10
4bCountryCode10x00
5bNumDescriptors10x01
6bDescriptorType10x22REPORT
7wDescriptorLength20x0041

Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength10x07
1bDescriptorType10x05ENDPOINT
2bEndpointAddress10x811 IN
3bmAttributes10x03Interrupt
4wMaxPacketSize20x0008
6bInterval10x0a

Interface Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x04INTERFACE
2bInterfaceNumber10x01
3bAlternateSetting10x00
4bNumEndpoints10x01
5bInterfaceClass10x03Human Interface Device
6bInterfaceSubClass10x00
7bInterfaceProtocol10x00
8iInterface10x02

HID Descriptor

OffsetFieldSizeValueDescription
0bLength10x09
1bDescriptorType10x21HID
2bcdHID20x01101.10
4bCountryCode10x00
5bNumDescriptors10x01
6bDescriptorType10x22REPORT
7wDescriptorLength20x009f

Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength10x07
1bDescriptorType10x05ENDPOINT
2bEndpointAddress10x822 IN
3bmAttributes10x03Interrupt
4wMaxPacketSize20x0004
6bInterval10xff

附录

USB 2.0 Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength1NumberSize of this descriptor in bytes
1bDescriptorType1ConstantENDPOINT Descriptor Type
2bEndpointAddress1EndpointThe address of the endpoint on the USB device described by this descriptor. The address is encoded as follows:
 Bit 3…0: The endpoint number
 Bit 6…4: Reserved, reset to zero
 Bit 7: Direction, ignored for control endpoints
   0 = OUT endpoint
   1 = IN endpoint
3bmAttributes1BitmapThis field describes the endpoint’s attributes when it is configured using the bConfigurationValue.
Bits 1…0: Transfer Type
 00 = Control
 01 = Isochronous
 10 = Bulk
 11 = Interrupt

If not an isochronous endpoint, bits 5…2 are reserved and must be set to zero. If isochronous, they are defined as follows:
Bits 3…2: Synchronization Type
 00 = No Synchronization
 01 = Asynchronous
 10 = Adaptive
 11 = Synchronous

Bits 5…4: Usage Type
 00 = Data endpoint
 01 = Feedback endpoint
 10 = Implicit feedback Data endpoint
 11 = Reserved

All other bits are reserved and must be reset to zero.
Reserved bits must be ignored by the host.
4wMaxPacketSize2NumberMaximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-(micro)frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms.
For all endpoints, bits 10…0 specify the maximum packet size (in bytes).
For high-speed isochronous and interrupt endpoints:
Bits 12…11 specify the number of additional transaction opportunities per microframe:
 00 = None (1 transaction per microframe)
 01 = 1 additional (2 per microframe)
 10 = 2 additional (3 per microframe)
 11 = Reserved
Bits 15…13 are reserved and must be set to zero.
6bInterval1NumberInterval for polling endpoint for data transfers.
Expressed in frames or microframes depending on the device operating speed (i.e., either 1 millisecond or 125 µs units).
For full-/high-speed isochronous endpoints, this value must be in the range from 1 to 16. The bInterval value is used as the exponent for a 2 b I n t e r v a l − 1 2^{bInterval-1} 2bInterval1 value; e.g., a bInterval of 4 means a period of 8 ( 2 4 − 1 2^{4-1} 241).
For full-/low-speed interrupt endpoints, the value of this field may be from 1 to 255.
For high-speed interrupt endpoints, the bInterval value is used as the exponent for a 2 b I n t e r v a l − 1 2^{bInterval-1} 2bInterval1 value; e.g., a bInterval of 4 means a period of 8 ( 2 4 − 1 2^{4-1} 241). This value must be from 1 to 16.
For high-speed bulk/control OUT endpoints, the bInterval must specify the maximum NAK rate of the endpoint. A value of 0 indicates the endpoint never NAKs. Other values indicate at most 1 NAK each bInterval number of microframes. This value must be in the range from 0 to 255.

USB 3.x Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength1NumberSize of this descriptor in bytes
1bDescriptorType1ConstantENDPOINT Descriptor Type
2bEndpointAddress1EndpointThe address of the endpoint on the USB device described by this descriptor. The address is encoded as follows:
 Bit 3…0: The endpoint number
 Bit 6…4: Reserved, reset to zero
 Bit 7: Direction, ignored for control endpoints
   0 = OUT endpoint
   1 = IN endpoint
3bmAttributes1BitmapThis field describes the endpoint’s attributes when it is configured using the bConfigurationValue.
 Bits 1…0: Transfer Type
   00 = Control
   01 = Isochronous
   10 = Bulk
   11 = Interrupt

If an interrupt endpoint, bits 5…2 are defined as follows:
 Bits 3…2: Reserved
 Bits 5…4: Usage Type
  00 = Periodic
  01 = Notification
  10 = Reserved
  11 = Reserved
If isochronous, they are defined as follows:
 Bits 3…2: Synchronization Type
   00 = No Synchronization
   01 = Asynchronous
   10 = Adaptive
   11 = Synchronous

Bits 5…4: Usage Type
 00 = Data endpoint
 01 = Feedback endpoint
 10 = Implicit feedback Data endpoint
 11 = Reserved

If not an isochronous or interrupt endpoint, bits 5…2 are reserved and shall be set to zero.
All other bits are reserved and shall be reset to zero. Reserved bits
shall be ignored by the host.
4wMaxPacketSize2NumberMaximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
For control endpoints this field shall be set to 512. For bulk endpoint types this field shall be set to 1024.
For interrupt and isochronous endpoints this field shall be set to 1024 if this endpoint defines a value in the bMaxBurst field greater than zero.
If the value in the bMaxBurst field is set to zero then this field can
have any value from 0 to 1024 for an isochronous endpoint and 1 to 1024 for an interrupt endpoint.
6bInterval1NumberInterval for servicing the endpoint for data transfers. Expressed in 125-µs units.
For Enhanced SuperSpeed isochronous and interrupt endpoints, this value shall be in the range from 1 to 16. However, the valid ranges are 8 to 16 for Notification type Interrupt endpoints. The bInterval value is used as the exponent for a KaTeX parse error: Expected 'EOF', got '}' at position 18: …{}(bInterval-1)}̲ value; e.g., a bInterval of 4 means a period of 8 ( 2 ( 4 − 1 ) 2^{(4-1)} 2(41) 2 3 2^3 23 → 8).
This field is reserved and shall not be used for Enhanced SuperSpeed bulk or control endpoints.

USB 1.x Endpoint Descriptor

OffsetFieldSizeValueDescription
0bLength1NumberSize of this descriptor in bytes
1bDescriptorType1ConstantENDPOINT Descriptor Type
2bEndpointAddress1EndpointThe address of the endpoint on the USB device described by this descriptor. The address is encoded as follows:
 Bit 3…0: The endpoint number
 Bit 6…4: Reserved, reset to zero
 Bit 7: Direction, ignored for control endpoints
   0 = OUT endpoint
   1 = IN endpoint
3bmAttributes1BitmapThis field describes the endpoint’s attributes when it is configured using the bConfigurationValue.
 Bits 1…0: Transfer Type
   00 = Control
   01 = Isochronous
   10 = Bulk
   11 = Interrupt

All other bits are reserved.
4wMaxPacketSize2NumberMaximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
For isochronous endpoints, this value is used to reserve the bus time in the schedule, required for the per-frame data payloads. The pipe may, on an ongoing basis, actually use less bandwidth than that reserved. The device reports, if necessary, the actual bandwidth used via its normal, non-USB defined mechanisms.
For interrupt, bulk, and control endpoints, smaller data payloads may be sent, but will terminate the transfer and may or may not require intervention to restart.
6bInterval1NumberInterval for polling endpoint for data transfers. Expressed in milliseconds.
This field is ignored for bulk and control endpoints. For isochronous endpoints this field must be set to 1. For interrupt endpoints, this field may range from 1 to 255.

[参考资料]

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/109689169

  • 8
    点赞
  • 43
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
USB音频设备描述符是用于描述USB音频设备的一种特殊类型的USB设备描述符。它提供了关于音频设备的重要信息,如设备的功能、接口、端点等。 高速USB音频设备描述符通常包括以下几个方面的描述: 1. 设备描述符(Device Descriptor):包含了有关设备的基本信息,如供应商ID、产品ID、设备版本号等。 2. 配置描述符(Configuration Descriptor):描述了设备的配置信息,包括配置值、最大功率消耗、接口数量等。 3. 接口描述符(Interface Descriptor):描述了设备的接口信息,包括接口号、接口类别、接口子类别、接口协议等。 4. 端点描述符Endpoint Descriptor):描述了设备的端点信息,包括端点地址、传输类型、同步类型、端点大小等。在音频设备中,通常会有输入端点和输出端点用于音频数据的传输。 5. 音频控制接口描述符(Audio Control Interface Descriptor):针对音频控制接口提供了额外的描述信息,如控制接口的子类型、特性等。 6. 音频流接口描述符(Audio Streaming Interface Descriptor):针对音频流接口提供了额外的描述信息,如流接口的格式、采样率、通道数等。 高速USB音频设备描述符的具体内容和格式遵循USB规范中针对音频设备的描述符定义。这些描述符的信息可以被操作系统和应用程序用来识别、配置和控制USB音频设备,确保音频数据的正确传输和处理。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值