Chapter 9 USB Device Framework

9.3 USB Device Requests


All USB devices respond to requests from the host on the device’s Default Control Pipe.
所有USB设备都会响应设备默认控制管道上来自主机的请求。


These requests are made using control transfers.
这些请求使用控制传输


The request and the request’s parameters are sent to the device in the Setup packet.
请求和请求的参数在Setup数据包中发送到设备。


The host is responsible for establishing the values passed in the fields listed in Table 9-2.


Every Setup packet has eight bytes.
每一个设置包有8个字节。


21 09 81 03 06 00 02 00 
81 01


0 bmRequestType  传输的类型  21
1 bRequest                   09
2 wValue                     81 03     81是传输的ID 03猜测是CLASS
4 wIndex                     06 00     06为interface 
6 wLength                    02 00     02 发送值的长度
81 01  






   


ble4.2
DA14681
8852


9.4 Standard Device Requests


USB devices must respond to standard device requests, even if the device has not yet been assigned an
address or has not been configured.
USB设备必须响应标准的设备请求,即使设备尚未分配地址或尚未配置。


9.4.1 Clear Feature


This request is used to clear or disable a specific feature.
此请求用于清除或禁用特定功能。


9.4.2 Get Configuration


This request returns the current device configuration value.
该请求返回当前设备的配置值。


9.4.3 Get Descriptor


This request returns the specified descriptor if the descriptor exists.
该请求返回详细的描述符,如果描述符存在。


9.4.4 Get Interface


This request returns the selected alternate setting for the specified interface.
该请求返回指定接口的选定备用设置。


9.4.5 Get Status


This request returns status for the specified recipient.
此请求返回指定收件人的状态。


9.4.6 Set Address


This request sets the device address for all future device accesses.
该请求为所有未来的设备访问设置设备地址。


9.4.7 Set Configuration


This request sets the device configuration.
该请求设置设备的配置。


9.4.8 Set Descriptor


This request is optional and may be used to update existing descriptors or new descriptors may be added.
该请求是可选的,可用于更新现有的描述符或添加新的描述符。


9.4.9 Set Feature


This request is used to set or enable a specific feature.
此请求用于设置或启用特定功能。


9.4.10 Set Interface


This request allows the host to select an alternate setting for the specified interface.
该请求允许主机为指定的接口选择备用设置。


9.4.11 Synch Frame


This request is used to set and then report an endpoint’s synchronization frame.
该请求用于设置并报告端点的同步帧。




9.5 Descriptors


USB devices report their attributes using descriptors.
USB使用描述符报告其属性。


A descriptor is a data structure with a defined format.
Each descriptor begins with a byte-wide field that contains the total number of bytes in the descriptor
followed by a byte-wide field that identifies the descriptor type.
描述符是一个定义好的数据结构。每一种描述都有它的长度紧接着是描述符的类型。


If a device does not support string descriptors, string
reference fields must be reset to zero to indicate no string descriptor is available.
如果设备不支持字符串描述符,则必须将字符串引用字段重置为零以指示没有可用的字符串描述符。






9.6 Standard USB Descriptor Definitions


9.6.1 Device


A device descriptor describes general information about a USB device.
设备描述符描述有关USB设备的一般信息。


It includes information that applies
globally to the device and all of the device’s configurations. A USB device has only one device descriptor.
它包含全局适用于设备和所有设备配置的信息。 USB设备只有一个设备描述符。




The bNumConfigurations field indicates the number of configurations at the current operating speed.
bNumConfigurations字段表示当前运行速度下的配置数量。


If the device is operating at high-speed, the bMaxPacketSize0 field must be 64 indicating a 64 byte
maximum packet.
如果设备以高速运行,则bMaxPacketSize0字段必须为64,表示最多64字节的数据包。


app_usbd_core.c






0x1616
0001
0110
0001
0110


9.6.1 Device
发送的第一包描述符,对设备的描述包括pid vid 以及0端点的最大长度


9.6.2 Device_Qualifier


The device_qualifier descriptor describes information about a high-speed capable device that would
change if the device were operating at the other speed.
device_qualifier描述符描述有关高速设备的信息,如果设备以另一种速度运行,该信息将会改变。


For example, if the device is currently operating
at full-speed, the device_qualifier returns information about how it would operate at high-speed and
vice-versa.
例如,如果设备当前正在运行
全速时,device_qualifier会返回有关它如何在高速下运行的信息,反之亦然。


9.6.3 Configuration
第2个大段描述的开始
The configuration descriptor describes information about a specific device configuration.
配置描述符描述了关于特定设备配置的信息。




The descriptor describes the number of interfaces provided by the configuration. Each interface may
operate independently. For example, an ISDN device might be configured with two interfaces, each
providing 64 Kb/s bi-directional channels that have separate data sources or sinks on the host. Another
configuration might present the ISDN device as a single interface, bonding the two channels into one
128 Kb/s bi-directional channel.
描述符描述配置提供的接口数量。 每个界面都可以独立运作。 例如,一个ISDN设备可能配置有两个接口,每个接口
提供64 Kb / s双向通道,在主机上具有独立的数据源或接收器。 另一个
配置可以将ISDN设备呈现为单个接口,将两个通道绑定为一个
128 Kb / s双向通道。




9.6.5 Interface


The interface descriptor describes a specific interface within a configuration.
接口描述符描述配置中的特定接口。


A configuration provides one or more interfaces, each with zero or more endpoint descriptors describing a unique set of endpoints within
the configuration.
配置提供了一个或多个接口,每个接口都有零个或多个端点描述符,用于描述配置中的一组唯一端点。


When a configuration supports more than one interface, the endpoint descriptors for a
particular interface follow the interface descriptor in the data returned by the GetConfiguration() request.
当配置支持多个接口时,特定接口的端点描述符将遵循GetConfiguration()请求返回的数据中的接口描述符。


If a configuration has alternate settings for one or more of its interfaces, a separate interface
descriptor and its associated endpoints are included for each setting.
如果一个配置具有一个或多个接口的备用设置,则每个设置都包含一个单独的接口描述符及其关联的端点。


If an interface uses only endpoint zero, no endpoint descriptors follow the interface descriptor.
In this case,the bNumEndpoints field must be set to zero.
如果一个接口只使用端点0,则没有端点描述符在接口描述符之后。
在这种情况下,bNumEndpoints字段必须设置为零。


An interface descriptor never includes endpoint zero in the number of endpoints.
接口描述符从不包括端点数量中的端点零。

猜你喜欢

转载自blog.csdn.net/baiyibin0530/article/details/79798442