How does a USB Host identify a USB device?
WhenUSB deviceWhen you plug in the host, the host performs a series of actions to enumerate the device configuration (the configuration is an enumeration state, which indicates the temporary State). These statuses are as follows:
1. Access state (attached): After a device is connected to a host, the host detects the access of the device by detecting the level changes on the signal line;
2. Power Supply Mode (powered): refers to the power supply to the device, which is divided into the default power supply value when the device is connected, and the power supply value after the configuration phase (by the maximum value required in the data, can be set through programming)
3. Default Mode: Before USB is configured, it communicates with the host through the default address 0;
4. Address: After configuration, after the USB device is reset, it can communicate with the host based on the unique address assigned to it by the host;
5. configured: uses various standard USB request commands to obtain various information about the device and modify or set the information about the device.
6. suspended state: the bus power supply device has no bus operation within 3 ms, that is, if the USB Bus is idle, the device will automatically enter the suspended state, the total current power consumption cannot exceed 280ua.
What is a standard USB device Request command?
The standard USB device Request command is used in the data packet phase (data0, consisting of eight bytes) in the "Initial setup step" of the control transmission ). There are a total of 11 request commands for the standard USB device, which are 8 bytes in size and have the same structure and are composed of five fields (the field is the data part of the standard request command ), the structure is as follows (Numbers in parentheses indicate the number of bytes, and the first letter is BM, B, and W, respectively, indicate bitmap, byte, and dual-byte ):
Bmrequesttype (1) + brequest (1) + wvalue (2) + Windex (2) + wlength (2)
The meaning of each field is as follows:
1. bmrequesttype: d7d6d5d4d3d2d1d0
D7 = 0 host to Device
= 1 device to host;
D6d5 = 00 Standard Request command
= 01 request commands
= 10 user-defined commands
= 11 reserved value
D4d3d2d1d0 = 00000 the receiver is a device
= 00001 the recipient is a device
= 00010 the receiver is the endpoint
= 00011 the recipient is another receiver
= Other values are retained.
2. brequest: Request commandCodeIn the standard USB command, each command defines a number, and the value of the number is the value of the field, the number and command name are as follows (note that the command code here should be used with other fields. It can be said that the command code is the core of the Standard Request command code, these command codes determine 11 USB standard request commands ):
0) 0 get_status: Used to return the status of a specific recipient
1) 1 clear_feature: Used to clear or disable certain characteristics of the recipient
2) 3 set_feature: used to enable or activate certain features of the command recipient
3) 5 set_address: used to allocate addresses to devices
4) 6 get_descriptor: used by the host to obtain the specific descriptor of the device.
5) 7 set_descriptor: Modify the descriptor related to the device, or add a new descriptor.
6) 8. get_configuration: used to obtain the configuration value of the current device on the host (note the same as above)
7) 9 set_configuration: used to indicate the required configuration of the device.
8) 10 get_interface: used to obtain the ID of an interface descriptor.
9) 11 set_interface: used by the host to require the device to use a descriptor to describe the interface
10) 12 synch_frame: Used to set and report the Synchronization Frame of an endpoint.
The above 11 commands are really as long as a piece of cloth. Please read the books. I will not talk about it here. controlling transmission is the focus of USB, these 11 commands are the focus of control over transmission, so these 11 commands are the top priority. This is clear, and USB is even a beginner.