All USB data transfers are initiated by the USB Host. The Host controls communication timing by maintaining time intervals called frames. The Host issues a Start of Frame (SOF) sequence on the USB data lines at the beginning of each frame.
The time interval of each frame is determined by the specified USB speed. One requirement of USB compliance certification is the ability of a HOST to accurately issue SOFs.
The USB Hosts conducts communication transactions with the Devices during the Frame.
The mechanism of transferring data involves the Host reading and writing to a set of memory locations located on each Device. These memory locations are called Endpoints. Endpoints are essentially in and out baskets. The size of an endpoint ( i.e. amount of data in an endpoint) can vary significantly between different Devices.
Device endpoints are found in numbered pairs. Endpoint numbers start with 0 and can be as high as 32. Each endpoint number has an IN and an OUT endpoint. OUT endpoints carry data coming out of the Host, while IN endpoints contain data being sent In to the Host. For example, Endpoint 1 is two endpoints; endpoint 1 IN ( EP1IN) and Endpoint 1 OUT ( EP1OUT).
Writing to a USB Device
When the host wishes to send a message to a Device, the message is placed in an OUT endpoint on the Device through the use of a WRITE transaction. The Device’s application code monitors the OUT endpoints to determine if any messages have been received from the Host. After detecting the presence of a message from the Host, the Device will copy the message from the OUT endpoint.
Sending Data to the Host
If a device’s application wishes to communicate with the host, a message is placed in an IN endpoint. The message will remain in the IN endpoint until the Host issues a READ transaction. A READ transaction caused the contents of an IN endpoint to be sent to the host.
The data throughput of USB communications to an endpoint depends upon three items:
- The signaling rate of the frame, determined by the specified USB speed.
- The size of the endpoint (how much data each transaction moves)
- The frequency in which the host issues transactions to the endpoint. This can vary from several transactions per frame to multiple frames between endpoint transactions.
Information on all endpoint parameters and communication requirements are defined by the Device and given to the Host when the Device is plugged into the Host and successfully enumerated. The enumeration process informs the host which transfer type to use when communicating with a Device’s endpoints.
Control and Configuration
Each USB Device reserves Endpoint 0 as a unique endpoint called the Control Endpoint. EP0 IN contains a description of the USB Device which is read by the Host during enumeration. EP0 OUT provides the Host the ability to send configuration commands to the Device.