当前位置:网站首页>8-byte standard request parsing during USB enumeration

8-byte standard request parsing during USB enumeration

2022-08-11 06:35:00 Emily_rong_2021

请求
Request and descriptor as,With standard equipment request,For different kinds of equipment,Have their own specific request again.First introduces the standard equipment request,对于特殊的请求,Introduce each different type of equipment,再做解析.

1. Standard equipment request data structure
USB协议中规定,The length of the standard request for8个字节.在设备枚举过程中,HostWill be issued a series of standard request,Devices need to parse the standard request(SETUP事务),And make the right response,Equipment to be successful enumeration.After successful enumeration,To call related interface for data communication.

8Byte standard request structure is as follows:

Each domain analysis in the following table

 For a standard request,D6~D5 = 00,USB协议规定了11A standard request,请求码(bRequest)如下表.

Standard request code table

实例:

  • 请求数据为8个字节HEX:80 06 00 01 00 00 12 00 ==> 获取设备描述符

注:This stage of the device address(address)用的0,Of course the default endpoint(endpoint)也是0.

第一个字节0x80Break up can get,This is a host to device(bit0~bit4)的一个标准(bit5~bit6)的请求命令,The result of the request is for equipment toHost返回(bit7 == 1).

第二个字节0x06查看表9-4Can be aGET_DESCRIPTOR,Obtaining the descriptor 的请求.

The third four myself is0x0100 ,View the descriptor table,That high bytes descriptor type,01表示设备,02表示配置;Low byte index.Such as equipment has multiple configuration,When the need to read different configuration through the low byte.Or a configuration has multiple interfaces,Through the index to select different interface.So the high byte here1代表 设备,The low byte in this equipment is useless to.
3.3.1 分配地址

  • 数据为HEX:00 05 03 00 00 00 00 00 ==> 主机给设备分配地址

注:This stage of the device address(address)用的0,Of course the default endpoint(endpoint)也是0.

第一个字节0x0,This is a host to device(bit0~bit4)的一个标准(bit5~bit6)的请求命令,The result of the request is the host and device to send(bit7 == 0)信息.

第二个字节0x05,从table 9-4可以看到,SET_ADDRESS,From machine is host to set the address.

The third four bytes is together0x03,Reference standard equipment request list,可以知道,This is host to equipment distribution device address3.
 

3.4.1 Make the request of the phase analysis 

  • 请求数据为8个字节HEX:80 06 00 01 00 00 12 00  ==> Obtain the device descriptor request

3.5.1 Make the request of the phase analysis

  • 请求数据为8个字节HEX:80 06 00 02 00 00 09 00 == > Access to configuration descriptor request

第一个字节0x80Break up can get,This is a host to device(bit0~bit4)的一个标准(bit5~bit6)的请求命令,The result of the request is for equipment toHost返回(bit7 == 1).

第二个字节0x06查看表9-4Can be aGET_DESCRIPTOR,Obtaining the descriptor 的请求.

The third four bytes travels is0x0100 ,View the descriptor table,That high bytes descriptor type,01表示设备,02表示配置;Low byte index.Such as equipment has multiple configuration,When the need to read different configuration through the low byte.Or a configuration has multiple interfaces,Through the index to select different interface.So the high byte here2代表配置,The low byte in this equipment is useless to.

DiSiWu bytes0x0,这个参数如果为0,则不关心;如果为非零,则表示Langurage ID,Every one has a corresponding meaning.


The device class descriptor+配置描述符+接口描述符+端点描述符+厂商定义的描述符The total byte length for the34个字节

  •  请求数据为8个字节HEX:80 06 00 03 00 00 FF 00  ==> Get a string descriptor request

The third four bytes travels is0x0300 ,查看9-5描述符表,That high bytes descriptor type,01表示设备,02表示配置,3表示字符串;Low byte index.Such as equipment has multiple configuration,When the need to read different configuration through the low byte.Or a configuration has multiple interfaces,Through the index to select different interface.So the high byte here3表示字符串,Low bytes for the index0.

DiLiuQi bytes0xFF,Represents the data returned should not be more than255个字节.

请求数据为8个字节HEX:80 06 02 03 09 04 FF 00  ==> Get a string descriptor request,索引值为2

The third four bytes travels is0x0302 .So the high byte here3表示字符串,Low bytes for the index2.

DiSiWu bytes0x0409,When the request is string descriptor,则表示Langurage ID,0x0409表示美式英语.

DiLiuQi bytes0xFF,Represents the data returned should not be more than255个字节.

  • 请求数据为8个字节HEX:80 06 01 03 09 04 FF 00  ==> Get a string descriptor request,索引值为1
  • 请求数据为8个字节HEX:00 09 01 00 00 00 00 00 ==> Set the configuration descriptor request

第一个字节0x80Break up can get,This is a host to device(bit0~bit4)的一个标准(bit5~bit6)的请求命令,The result of the request is host to send device information(bit7 == 0).

第二个字节0x09查看表9-4Can be aSET_CONFIGURATION,Setting the configuration.

The third four bytes travels is0x1,查看9-3Standard request table,To learn that here1Is the value of the configuration.

DiSiWu bytes0x0,In the setup configuration,无意义.

DiLiuQi bytes0x0,In the setup configuration,无意义.

  • 请求数据为8个字节HEX: 21 0A 00 00 00 00 00 00 

第一个字节0x21Break up can get,这是一个The host to the interface(bit0~bit4)的一个类(bit5~bit6)Request for a particular class命令,请求的结果是The host send interface class command(bit7 == 0).

根据手册:0A表示Set_Idle功能,Set_IdleRequest silences the interrupt input pipe on the specific report,Until the new events or after a specified time.

 

参考:

(5条消息) 从零开始学USB(十七、USB的枚举)_To_run_away的博客-CSDN博客

原网站

版权声明
本文为[Emily_rong_2021]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/223/202208110515131691.html