USB (通用串行总线)信令包括两条数据线 D+ 和 D-,用于差分信令,以提高抗噪能力和数据完整性。这些线路的控制决定了 USB 通信中的数据传输、各种状态和信号协议。
USB 差分信号
差分信号是指数据由 D+ 和 D- 线路之间的电压差来表示,而不是由它们的绝对电压电平来表示。这种技术提高了数据在长距离和嘈杂环境中传输的稳健性。
USB 信号状态
根据 USB 设备的速度和正在执行的操作,D+ 和 D- 线的状态可能处于几种情况之一:
-
高速(HS)信号:
- 闲置(J 状态): D+ 为高电平,D- 为低电平。
- 激活(K 状态): D+ 为低电平,D- 为高电平。
- SE0(单端归零): D+ 和 D- 均为低电平。
- 恢复信号: 从挂起状态恢复时,使用 K 状态。
-
全速(FS)和低速(LS)信号:
- 闲置(J 状态):
- 全速: D+ 为高电平,D- 为低电平。
- 低速: D+ 低,D- 高。
- 激活(K 状态):
- 全速: D+ 低,D- 高。
- 低速: D+ 为高电平,D- 为低电平。
- SE0(单端归零): D+ 和 D- 均为低电平,表示数据包结束或复位状态。
- 闲置(J 状态):
D+ 和 D- 线路的控制
USB 主机控制器和 USB 设备控制器通过各种信号协议管理 D+ 和 D- 线的状态。这些协议在 USB 硬件和固件中实现,涉及精确的定时和电压电平,以确保可靠的通信。
关键操作
-
数据传输:
- 数据使用 NRZI(非归零反转)编码传输,状态之间的转换表示二进制 “0”,无转换表示二进制 “1”。
- 比特填充用于确保有足够的转换来保持同步。
- SE0 条件标志着数据传输的结束,使接收器能够识别数据包之间的边界。
- 在传输数据包结束时,发送器会将 D+ 和 D- 短时间内(通常为 2 比特左右)驱动为低电平。
-
复位和速度检测:
- 将 D+ 和 D- 都置低 (SE0) 至少 10 毫秒即表示复位。此操作将重置所有已连接的 USB 设备,使其恢复到默认状态。总线上的设备会识别这一复位信号,并重新初始化其配置,就像它们是新连接的一样。
- 速度检测是通过主机检查复位后 D+ 和 D- 线的状态来实现的。例如,全速设备在 D+ 上有一个上拉电阻,而低速设备在 D- 上有一个上拉电阻。
-
暂停和恢复:
- 在正常运行期间,如果 3 毫秒内没有总线活动,设备就会进入暂停状态以节省电能。
- 要恢复运行,主机将总线驱动到 SE0 的持续时间最短(通常约为 1 至 2 毫秒),然后过渡到 K 状态(D+ 为低电平,D- 为全速和高速状态下的高电平)至少 20 毫秒至多100ms使所有设备能检测到并唤醒。(有时没有复位信号,而是直接resume信号)
-
握手和确认:
- USB 通信包括握手数据包(ACK、NAK、STALL),以管理数据流并确保可靠传输。
###电气特性
- 全速: 12 Mbps,D+ 端使用 1.5 kΩ 上拉电阻。
- 低速: 1.5 Mbps,D- 端使用 1.5 kΩ 上拉电阻。
- 高速: 480 Mbps,最初显示为全速,直到完成高速协商(chirp)。
这个电阻是在设备端的,由USB host来识别USB设备类型。
另外,通常15k 欧姆电阻通常用作主机侧 D+ 和 D- 线路的下拉电阻,以确保在未连接设备时将线路拉至地。
摘要
USB 中的 D+ 和 D- 线通过差分信号进行控制,以管理数据传输和各种 USB 状态。主机和设备控制器使用精确的电压电平和定时来控制这些线路,从而确保 USB 通信的稳健和高效。这种差分信号方法对于在各种可能存在噪声的环境中保持数据完整性和可靠性至关重要。
The USB (Universal Serial Bus) signaling involves two data lines, D+ and D-, which are used for differential signaling to improve noise immunity and data integrity. The control of these lines determines the data transmission, various states, and signaling protocols in USB communication.
USB Differential Signaling
Differential signaling means that data is represented by the voltage difference between the D+ and D- lines, rather than their absolute voltage levels. This technique enhances the robustness of data transmission over longer distances and in noisy environments.
USB Signal States
The state of the D+ and D- lines can be in one of several conditions, depending on the speed of the USB device and the operation being performed:
-
High-Speed (HS) Signaling:
- Idle (J State): D+ is high, D- is low.
- Active (K State): D+ is low, D- is high.
- SE0 (Single-Ended Zero): Both D+ and D- are low.
- Resume Signaling: When resuming from suspend, the K state is used.
-
Full-Speed (FS) and Low-Speed (LS) Signaling:
- Idle (J State):
- Full-Speed: D+ is high, D- is low.
- Low-Speed: D+ is low, D- is high.
- Active (K State):
- Full-Speed: D+ is low, D- is high.
- Low-Speed: D+ is high, D- is low.
- SE0 (Single-Ended Zero): Both D+ and D- are low, indicating the end of a packet(EOP) or a reset condition.
- Idle (J State):
Control of D+ and D- Lines
The USB host controller and USB device controllers manage the states of D+ and D- lines through various signaling protocols. These protocols are implemented in the USB hardware and firmware, and involve precise timing and voltage levels to ensure reliable communication.
Key Operations
-
Data Transmission:
- Data is transmitted using NRZI (Non-Return to Zero Inverted) encoding, where a transition between states indicates a binary ‘0’ and no transition indicates a binary ‘1’.
- Bit stuffing is used to ensure there are enough transitions to maintain synchronization.
- The SE0 condition signifies the end of the data transmission, allowing the receiver to recognize the boundary between packets.
- At the end of transmitting a data packet, the transmitter drives both D+ and D- low for a short period (typically around 2 bit times).
-
Reset and Speed Detection:
-
A reset condition is indicated by driving both D+ and D- low (SE0) for at least 10 milliseconds. This action resets all connected USB devices, bringing them back to their default state. Devices on the bus recognize this reset signal and reinitialize their configurations as if they were newly connected.
-
Speed detection is achieved by the host checking the state of the D+ and D- lines after reset. For example, full-speed devices have a pull-up resistor on D+, while low-speed devices have a pull-up resistor on D-.
-
-
Suspend and Resume:
- During normal operation, if there is no bus activity for 3 milliseconds, devices enter the suspended state to save power.
- To resume, the host drives the bus to SE0 for a minimum duration (typically around 1 to 2 milliseconds), followed by a transition to the K state (D+ low, D- high for full-speed and high-speed) for at least 20 ms and at most 100 ms to ensure all devices detect it and wake up the device.
-
Handshake and Acknowledgment:
- USB communication includes handshake packets (ACK, NAK, STALL) to manage data flow and ensure reliable transmission.
Electrical Characteristics
- Full-Speed: 12 Mbps, uses a 1.5 kΩ pull-up resistor on D+.
- Low-Speed: 1.5 Mbps, uses a 1.5 kΩ pull-up resistor on D-.
- High-Speed: 480 Mbps, initially appears as full-speed until high-speed negotiation (chirp) is completed.
This resistor is on the device side and is used by the USB host to recognize the USB device type.
Additionally, the 15k ohm resistors are typically used as pull-down resistors on both D+ and D- lines on the host side to ensure the lines are pulled to ground when no device is connected.
Summary
The D+ and D- lines in USB are controlled through differential signaling to manage data transmission and various USB states. The host and device controllers use precise voltage levels and timing to control these lines, ensuring robust and efficient USB communication. This differential signaling method is essential for maintaining data integrity and reliability in diverse and potentially noisy environments.
USB信号线颜色
一般白色表示D+,绿色D-。很多UART串口线也是红、黑、绿、白的颜色线。绿色RX、白色TX。
接头的线序如下: