USB - D+/D-信号介绍

USB (通用串行总线)信令包括两条数据线 D+ 和 D-,用于差分信令,以提高抗噪能力和数据完整性。这些线路的控制决定了 USB 通信中的数据传输、各种状态和信号协议。

USB 差分信号

差分信号是指数据由 D+ 和 D- 线路之间的电压差来表示,而不是由它们的绝对电压电平来表示。这种技术提高了数据在长距离和嘈杂环境中传输的稳健性。

USB 信号状态

根据 USB 设备的速度和正在执行的操作,D+ 和 D- 线的状态可能处于几种情况之一:

  1. 高速(HS)信号

    • 闲置(J 状态): D+ 为高电平,D- 为低电平。
    • 激活(K 状态): D+ 为低电平,D- 为高电平。
    • SE0(单端归零): D+ 和 D- 均为低电平。
    • 恢复信号: 从挂起状态恢复时,使用 K 状态。
  2. 全速(FS)和低速(LS)信号

    • 闲置(J 状态)
      • 全速: D+ 为高电平,D- 为低电平。
      • 低速: D+ 低,D- 高。
    • 激活(K 状态)
      • 全速: D+ 低,D- 高。
      • 低速: D+ 为高电平,D- 为低电平。
    • SE0(单端归零): D+ 和 D- 均为低电平,表示数据包结束或复位状态。

D+ 和 D- 线路的控制

USB 主机控制器和 USB 设备控制器通过各种信号协议管理 D+ 和 D- 线的状态。这些协议在 USB 硬件和固件中实现,涉及精确的定时和电压电平,以确保可靠的通信。

关键操作
  1. 数据传输

    • 数据使用 NRZI(非归零反转)编码传输,状态之间的转换表示二进制 “0”,无转换表示二进制 “1”。
    • 比特填充用于确保有足够的转换来保持同步。
    • SE0 条件标志着数据传输的结束,使接收器能够识别数据包之间的边界。
    • 在传输数据包结束时,发送器会将 D+ 和 D- 短时间内(通常为 2 比特左右)驱动为低电平。
  2. 复位和速度检测

    • 将 D+ 和 D- 都置低 (SE0) 至少 10 毫秒即表示复位。此操作将重置所有已连接的 USB 设备,使其恢复到默认状态。总线上的设备会识别这一复位信号,并重新初始化其配置,就像它们是新连接的一样。
    • 速度检测是通过主机检查复位后 D+ 和 D- 线的状态来实现的。例如,全速设备在 D+ 上有一个上拉电阻,而低速设备在 D- 上有一个上拉电阻。
  3. 暂停和恢复

    • 在正常运行期间,如果 3 毫秒内没有总线活动,设备就会进入暂停状态以节省电能。
    • 要恢复运行,主机将总线驱动到 SE0 的持续时间最短(通常约为 1 至 2 毫秒),然后过渡到 K 状态(D+ 为低电平,D- 为全速和高速状态下的高电平)至少 20 毫秒至多100ms使所有设备能检测到并唤醒。(有时没有复位信号,而是直接resume信号)
  4. 握手和确认

    • 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:

  1. 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.
  2. 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.

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

  1. 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).
  2. 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-.

  3. 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.
  4. 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。

接头的线序如下:

在这里插入图片描述

  • 15
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值