Transceivers
At each end of the data link between host and device is a transceiver circuit.
By upstream, we mean the end nearer to the host. The upstream end has two 15K pull-down resistors.
Upstream End Transceivers
The equivalent downstream end transceiver, as found in a device.
When receiving, individual receivers on each line are able to detect Single Ended Zero (SE0) condition, where both lines are low, can be detected. There is also a differential receiver for reliable reception of data.
Downstream End Transceivers
Speed Identification
At the device end of the link a 1.5 kohm resistor pulls one of the lines up to a 3.3V supply derived from VBUS. This is on D- for a low speed device, and on D+ for a full speed device. (A high speed device will initially present itself as a full speed device with the pull-up resistor on D+.) The host can determine the required speed by observing which line is pulled high.
Line States
1. Detached
When no device is plugged in, the host will see both data lines low, as its 15 kohm resistors are pulling each data line low.
2. Attached
When the device is plugged in to the host, the host will see either D+ or D- go to a '1' level, and will know that a device has been plugged in.
The '1' level will be on D- for a low speed device, and D+ for a full (or high) speed device.
3. Idle
The state of the data lines when the pulled up line is high, and the other line is low, is called the idle state. This is the state of the lines before and after a packet is sent.
4. J , K - State
The 'J State' is the same polarity as the idle state (the line with the pull-up resistor is high, and the other line is low), but is being driven to that state by either host or device. The K state is just the opposite polarity to the J state.
5. Single Ended Zero (SE0)
The Single Ended Zero (SE0) is when both lines are being pulled low.
6. Single Ended One
This is the illegal condition where both lines are high. It should never occur on a properly functioning link.
7. Reset
When the host wants to start communicating with a device it will start by applying a 'Reset' condition.
The Reset condition involves the host pulling down both data lines to low levels (SE0) for at least 10 ms. The device may recognise the reset condition after 2.5 us.
This 'Reset' should not be confused with a micro-controller power-on type reset. It is a USB protocol reset to ensure that the device USB signaling starts from a known state.
8. EOP-Signal
The End of Packet (EOP) is an SE0 state for 2 bit times, followed by a J state for 1 bit time.
9. Suspend
One of the features of USB which is an essential part of today's emphasis of 'green' products is its ability to power down an unused device. It does this by suspending the device, which is achieved by not sending anything to the device for 3 ms.
10. Resume
When the host wants to wake the device up after a suspend, it does so by reversing the polarity of the signal on the data lines for at least 20ms. The signal is completed with a low speed end of packet signal.
11. Keep Alive Signal
This is represented by a Low speed EOP. It is sent at least once every millisecond on a low speed link, in order to keep the device from suspending.
Packet Data
The packet (as the smallest element of data transmission) conveys an integral number of bytes at the current transmission rate.
A packet starts with a sync pattern to allow the receiver bit clock to synchronise with the data. It is followed, by the data bytes of the packet, and concluded with an End of Packet (EOP) signal. The data is actually NRZI encoded, and in order to ensure sufficiently frequent transitions, a zero is inserted after 6 successive 1's (this is known as bit stuffing)
Some Terminology of USB Communication
- Endpoints
Each USB device has a number of endpoints. Each endpoint is a source or sink of data. A device can have up to 16 OUT and 16 IN endpoints. OUT always means from host to device. IN always means from device to host.
- Pipe
A logical data connection between the host and a particular endpoint
- Transaction
Simple transfers of data called 'Transactions' are built up using packets.
PID (Packet Identifier)
The first byte in every packet is a Packet Identifier (PID) byte. This byte needs to be recognised quickly by the SIE and so is not included in any CRC checks
The PID itself is 4 bits long, and the 4 bits are repeated in an complemented form.
There are 17 different PID values defined
Token = xx01
Data = xx11
Handshake = 10
Special = xx00
TOKEN Packet
Used for SETUP, OUT and IN packets. They are always the first packet in a transaction, identifying the targeted endpoint, and the purpose of the transaction.
The SOF packet is also defined as a Token packet, but has a slightly different format and purpose.
This device address can address up to 127 devices (Only 7 bit) , Endpoint number (4 bits) There can be up to 16 possible endpoints in a device in each direction. The direction is implicit in the PID. OUT and SETUP PIDs will refer to the OUT endpoint, and an IN PID will refer to the IN endpoint.
DATA Packet
Used for DATA0, DATA1, DATA2 and MDATA packets. If a transaction has a data stage this is the packet format used.
DATA0 and DATA1 are only used for Low and Full speed links.
DATA2 and MDATA are only used for High speed links.
HANDSHAKE Packet
ACK Receiver acknowledges receiving error free packet.
NAK Receiving device cannot accept data or transmitting device cannot send data.
STALL Endpoint is halted, or control pipe request is not supported.
NYET No response yet from receiver (high speed only)
SOF Packet
The Start of Frame packet is sent every 1 ms on full speed links. The frame is used as a time frame in which to schedule the data transfers which are required. For example, an isochronous endpoint will be assigned one transfer per frame.
On a low speed link, to preserve bandwidth, a Keep Alive signal is sent every millisecond, instead of a Start of Frame packet. In fact Keep Alives may be sent by a hub on a low speed link whenever the hub sees a full speed token packet.
Tidak ada komentar:
Posting Komentar