All USB data transfers are initiated by the USB host. The host controls the communication time by maintaining the time interval for weighing frames. The host sends a frame start (SOF) sequence on the USB data line at the beginning of each frame.
The time interval for each frame is determined by the specified USB speed. One of the competencies required for USB compliance certification is that the host accurately publishes SOF.
The SOF interval of low speed or full speed is 1ms, and that of high speed is 125us.
The mechanism for transferring data involves the host reading and writing to a set of memory locations located on each device. These memory locations are called endpoints. The size of the endpoints (that is, the amount of data in the endpoints) can vary greatly from device to device.
Device endpoints appear as numbered pairs. Endpoint numbers start at 0 and can be up to 32. Each endpoint number has an IN and an OUT endpoint. The OUT endpoint carries data from the host, while the IN endpoint contains data sent to the host. For example, endpoint 1 is two endpoints; Endpoint 1IN (EP1IN) and endpoint 1OUT (EP1OUT).
The USB host sends data to the device
When a host wants to send a message to a device, it places the message in an OUT endpoint on the device using a WRITE transaction. The application code of the device monitors the OUT endpoint to determine whether any messages have been received from the host. Upon detecting the presence of a message from the Host, the Device copies the message from the OUT endpoint.
The USB host receives data from the device
If the device’s program wants to communicate with the host, a message is placed IN the IN endpoint. The message will remain IN the IN endpoint until the host issues a READ transaction. The READ transaction causes the contents of the IN endpoint to be sent to the host.
Communication parameters
The data rate at which a USB communicates with an endpoint depends on three things:
- The signal rate of the frame is determined by the specified USB speed.
- The size of the endpoint (the amount of data moved per transaction).
- The frequency with which the host issues transactions to the endpoint. This can range from a few transactions per frame to multiple frames between endpoint transactions.
Information about all endpoint parameters and communication requirements is defined by the device and provided to the host when the device is inserted into the host and successfully enumerated. The enumeration procedure informs the host which transport type to use when communicating with the device endpoint.
Control and configuration
Each USB device reserves endpoint 0 as a unique endpoint called the control endpoint. Endpoint 0 IN contains the description of the USB device read by the host during enumeration. Endpoint 0 OUT enables the host to send configuration commands to the device.
END.