USB for beginners (1) Enumeration

Source: Internet
Author: User

I. Overview
At present, many of the controllers are equipped with USB Function But for beginners Application Still tricky, because USB Not only FirmwareProgram Required, PC endDriver It also needs to be written, and the driver needs to be written. Write a host computer To see the effect. This way Debugging It is very difficult to get up. It is recommended to start with the USB keyboard and mouse, understand clearly, and then do your own Protocol It is relatively simple.
The concept of USB is not mentioned here. Let's ignore the specific Data Package format. This section briefly describes the process at the package level,
--------------------------------------- Device insertion -------------------------------------------------------------
1) The host will re-query each USB port, and the host detects an electrical pressure difference between D + and D-, so it thinks there is a new Set Access. The host sends a reset request Ms later. After receiving the reset request, the device generates an external interruption signal.
--------------------------------------- Enumeration process ------------------------------------------------------------
2) at this time, the host only knows that a new device has been inserted, but does not know what to plug in, so it starts to ask what device it is, how to use it, and how the load capacity is. At this time, the enumeration process is entered. Because no address is assigned to the device, the default address 0 is used. Get_descriptor (Get the device descriptor) command package. After the device receives the package, it starts to parse the package (in fact, you determine to process it in the firmware program), and then returns the device descriptor of the device in a fixed format, in this step, the host knows about you. The basic attributes of a USB device, such as the supported data transmission length, current load, supported USB version, and the PID and vid that facilitates the computer to find the driver in the future. .
3) when the host knows the Data Length and current size of your device, the next step is to allocate your address.
4) after giving you an address, you will be asked about your specific configuration. First, send a tentative Device Configuration request. Get_configuration (Requires a fixed return of 9 Device Configuration words). After receiving the message, you start to send 9-Byte Device Configuration words, including the total length of your configuration words, in this way, the host will know how long your configuration is, and then send it again Device Configuration request Then you start to upload all the configuration words. At this time, the host will understand the features of your work, and then you will be able to work normally.
5) If you want to describe your own name or something in some of the previous configurations (described in later sections), upload the string descriptor here.
6) Upload the report descriptor if the mouse or keyboard is used.
--------------------------------------- Normal data stage ------------------------------------------------------
7) at this time, you have been officially accepted and registered by the host. You can use your own test drive or general driver to communicate with your computer.

the above is a simple description. The detailed descriptions are described later, learning the key to learning something is to first know what it is, simple principle . For the work of USB, I would like to make an analogy here.
the host is like a company. You are a USB device. To enter the company, you must first interview (enumeration ), when you arrive at the interview site (the first time you insert a device), the interviewer first learns about your appearance, the gender of your position (device descriptor), and then gives you a number, in the future, you will start to call people by number. When you are called, you will start to ask about your professional knowledge, character, and so on (configuration descriptor). If you are appropriate (after enumeration) you will be admitted, and register your information to the company (driver installation, and write to the registry ). When you come to the company, you only need to report the employee ID (PID, VID) to know that you are here.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.