USB device request command Detailed

USB device request command: bmRequestType + bRequest + wValue + wIndex + wLength

 Number Value Name

(0) 0 GET_STATUS: returns the status for a particular recipient
(1) 1 CLEAR_FEATURE: used to remove or disable certain features of the recipient

(X) 2 Reserved for future
(2) 3 SET_FEATURE: certain features or activation command to enable the recipient

(X) 2 Reserved for future
(3) 5 SET_ADDRESS: the device used to assign an address
(4) 6 GET_DESCRIPTOR: a host-specific descriptor obtaining device
(5) 7 SET_DESCRIPTOR: modifying device related descriptors, or increase a new descriptor
(6) 8 GET_CONFIGURATION: Get the current configuration values used for the host device apparatus (different note with the above) 
(. 7) a SET_CONFIGURATION. 9: using the pointing device is used to configure the host requirements
(8) 10 GET_INTERFACE: with to obtain a current interface descriptor number
(9) 11 SET_INTERFACE: a host device with a required descriptor to describe the interface
(10) 12 SYNCH_FRAME: frame synchronizing apparatus is provided for one endpoint and reported

The following table lists the standard device request:

2011013110203729.jpg

The following table is a standard request code: 

2011013110253461.jpg

The following table descriptor types:

2011013110270258.jpg

USB devices must respond to standard device request, whether or not whether the device address is assigned or configured.

Selector is the device characteristics when used in setting the characteristics, the following table

2011013111010492.jpg

如果有个未支持或未定义的对USB设备的请求,设备将在Data或Status阶段返回一个STALL。如果设备在SETUP阶段就发现一个错误,那么设备优先在Data或Stauts之前就返回一个STALL。非法请求不会使得设备HALT。如果因为某个原因,设备因为某个错误无法通过缺省控制管道来与主机通信,设备必须被reset来清除错误状态并重启缺省状态。

以下描述参考图9-3

1,Clear Feature。这个请求用来清除或使否某个指定的属性。

wValue必须根据接收者来选择特定的值。接收者是设备就用设备描述符,是接口就用接口描述符,是端口就用端口描述符。一个Clear Feature请求一个不能被清除或不存在的特性,或指的是一个不存在的接口或端口的时候,将返回一个Request Error。如果wLength不为0,则设备响应无定义。

缺省状态下,此时对请求的响应无定义。

地址状态下,此时对请求的响应有定义,但是不能是对接口或者端口的请求,只能是端口0,否则响应为Request Error。

配置状态下,此时对请求的响应有定义。

2,Get Configuration。这个请求用来得到当前设备的配置值。如果wValue,wIndex,wLength不是默认值,那么设备响应无定义。

缺省状态下,设备响应无定义。

地址状态下,返回0值。

配置状态下,非0的bConfiguration值被返回。

3,Get Descriptor。这个请求返回存在的描述符。wValue中高位给出描述符种类,低位给出描述符索引。描述索引符用来给出特定的描述符。wIndex给出0或者Language ID。wLength给出要返回的byte数目。如果描述表长度大于wLegnth,那么只有描述表的初始部分被返回;否则发送一个短包来描述中断传输的完成。在3种状态下,请求都是合法的。

4,Get Interface。这个请求返回选定接口的可选配置。有些USB有接口间互斥设置的配置。这个请求使得主机决定设置。wValue和wLength不是默认数值,设备响应无定义。如果所指的借口不存在,就会返回请求错误。

缺省状态下,此时设备对此请求响应无定义。

地址状态下,设备返回请求错误。

配置状态下,请求合法。

5,Get Status。这个请求返回选定接收者的状态。bmRequestType中的Recipient位指明接收者。返回值是指定接收者的状态。如果wValue和wLength不是默认值或者wIndex在取状态时,设备响应无定义。

缺省状态下,设备响应无定义。

地址状态下,如果所指的是接口或者一个非0的端口,设备返回请求出错。

配置状态下,如果所指的接口或端口不存在,返回请求错误。

6,Set Address。这个请求为将来的设备存取设置设备地址。USB设备只有在status阶段后成功完成后才能改变设备地址。如果设备地址大于127,或者wIndex或者wLength非0,设备响应无定义。设备对SetAddress(0)无响应。

缺省状态下,如果地址值非0,那么设备进入地址态,否则仍位于缺省态。

地址状态下,如果新地址为0,那么设备进入缺省态,否则仍位于地址态。

配置状态下,设备对此请求的响应无定义。

7,Set Configuration。设置配置值。此请求设置设备配置值。wValue的低字节指出指定的配置。这个配置值必须为0或者和配置描述表中的一个配置相配。如果配置值为0,设备为地址状态。wValue的高字节保留。如果wIndex,wLength,wValue的高字节非0,那么设备对此请求响应未定义。

缺省状态下,对此请求响应未定义。

地址状态下,如果指定的配置值为0,那么设备仍然在地址态下。如果所指的配置和配置表中相符,那么就转到相应配置。否则返回请求错误。

配置状态下,如果指定的配置值为0,那么设备进入地址状态下。如果所指的配置和配置表中相符,那么就转到相应配置。否则返回请求错误。

8, Set Descriptor. Set Descriptor. Alternatively this request, in order to add or update a new description. wValue high byte indicates the type of descriptor, the low byte indicating descriptor index. Descriptor index is used to give the correct descriptor. Since one device can have different descriptors. For the can () described in the table set by SetDescriptor, which necessarily descriptor index 0. Descriptor index range from 0 to 1 minus the value range of the descriptor. wIndex string descriptor pointed Language ID, descriptor for the other set to zero. wLength transmission data length specified. Supported by the device descriptor has equipment, three types of configuration and string descriptor. If the device does not support the request, it returns a request error.

By default, the device response to the request is undefined.

Under state address, if the support request is legitimate.

Configuration level, if the support request is legitimate.

9, Set Feature. Set properties to take effect.

Reproduced in: https: //www.cnblogs.com/artechliu/archive/2011/06/20/1945137.html

Guess you like

Origin blog.csdn.net/weixin_34212189/article/details/93275470