Development of USB driver in WINXP (III)

Source: Internet
Author: User
2.6. endpoints, pipelines, and interfaces

These three concepts are confusing during USB development. For USB operations in real environments, endpoints, pipelines, and interfaces cannot be ignored. The relationship between these three concepts is 2-6-1;

 

The USB physical endpoint. In the NXP lpc2478 USB, there are up to 32 physical endpoints, each endpoint from 0 to 31 has a fixed transmission mode (I/out). In means that the hub sends data to the host, and out means that the host sends data to the hub.

A pipe is a logical concept of an endpoint. To put it bluntly, it is a logical endpoint. The physical endpoint of USB is divided into two groups, one of which is in, the other is the out type. Therefore, NXP lpc2478 can be divided into 16 logical endpoints, from 0 to 15.

An interface is a descriptor of a device and a set of endpoints. It is used to enable and save endpoints.

2.7. Information Flow

USB defines four data transmission modes (control, batch, interrupt, and so on ). Their differences are: the amount of data that a single transaction can carry (the next section will explain the term "transaction" transaction), whether it can ensure a specific cycle or delay, and whether it can automatically correct errors. Each transmission method corresponds to a specific type of endpoint. In fact, for a given type of endpoints (control, batch, interrupt, etc.), the corresponding type of transmission is always used.

In addition to the transmission type, the endpoint also has several other attributes. One attribute is the maximum data volume that a single transaction endpoint can provide or consume. A discrete value must be specified for control and batch endpoints, and any value of less than or equal to the maximum value can be specified for interrupt and Other endpoints. Another attribute of the endpoint is the transmission direction. The input (data from the device to the master controller) or the output (data from the master controller to the device ). Finally, each endpoint has an endpoint number, which includes the input and output directions and is used as the endpoint address.

When the master controller requires the device to execute certain rules, USB uses a round check protocol. When a device needs to send data to the master controller, the master controller must notice and send a request to the device that wants to send the data. That is, the USB device does not need to interrupt the master computer in the traditional way, but provides the interrupt endpoint, and the host periodically checks the interrupt endpoint.

When a client sends or receives data through a USB channel, it first calls the Win32 API, which will eventually cause the function driver to receive an IRP. The job of the driver is to direct the customer's request to the pipeline with the correct endpoint. It submits the request to the bus driver, and the bus driver then splits the request into multiple transactions, which are then sent to the bus. The information flow on the bus flows in the form of a frame of data per millisecond. The bus driver must schedule multiple transactions so that they can be loaded into the same frame. Figure 2-6-1 shows this process.

In USB, transactions are composed of one or more phases (phase. There are three types of stages: Token, data, and ack. Depending on the type, the transaction has a token phase, an optional data phase, and an optional handshake phase, as shown in 2-6-2. In the token phase, the master controller broadcasts the token package to all configured devices. The token package contains the device address and usually has an endpoint number. Only the device to be addressed can process the transaction. When the device to be addressed is a transaction, no device can read or write the bus. In the data phase, data is placed on the bus. For output transactions, the host places the data on the bus, and the devices that are addressing consume the data. The opposite is true for input transactions. Devices place data on the bus and consume data from hosts. In the handshake phase, the device or host puts the handbag on the bus, and the package contains status information. When the device sends a handshake packet, the ACK packet indicates that the message is successfully received. The nak packet indicates that the message is busy and does not attempt to receive the message. The stall packet indicates that the transaction is correctly received but is not logically valid. When the host sends a handshake packet, it can only send ACK packets.

A transaction that does not issue a handshake packet indicates that a transmission error occurs in the transaction ". The party waiting for the handshake package should think that the lack of the handshake package may result in an error and retry the transaction.

Related Article

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.