USB Protocol
  • Data Flow Types
  • Used to configure the device, get information about it, send commands to it, retrieve status information.
  • reliable short data packets
  • Control transfers are used for initial configuration of the device by the host, using Endpoint 0 OUT and Endpoint 0 IN, which are reserved for this purpose. They may be used (on the same endpoints) after configuration as part of the device-specific control protocol, if required.
  • Control Read/Write Sequences
    • SETUP stage(Setup Transaction)
      • The SETUP stage carries 8 bytes called the Setup packet. This defines the request, and specifies whether and how much data should be transferred in the DATA stage.
    • DATA stage(same as for Bulk transaction)
      • The DATA stage is optional. If present, it always starts with a transaction containing a DATA1. The type of transaction then alternates between DATA0 and DATA1 until all the required data has been transferred.
    • STATUS stage(same as for Bulk Transaction)
      • The STATUS stage is a transaction containing a zero-length DATA1 packet. If the DATA stage was IN then the STATUS stage is OUT, and vice versa.
  • Enumeration: How the Host Learns about Devices
    • Simplified Description of USB Device Enumeration
    • Implementing the USB Enumeration Process on the AT8xC5131/32/22 and AT8xC51SND1
    • USB 列舉教學,詳解
    • Device 插入 Host 時, 因為 Device 在 D+ 或 D- 有上拉電阻, 會讓 Host 知道有 Device 插入, 開始連線.
    • Host 發出先 Reset (SE0), 之後 Device 如果是 High-speed 會發出 Device Charp, 之後如果 Host 本身也是 USB 2.0 就會再發出 Hub Chirp (KJKJKJ..), Device 收到 Hub Chirp 後就會進入 High-speed mode;反之, 如果步驟2 中雙方無法成功完成 chirp 的動作, Host 就會以 Full-speed 或 Low-speed 與 device 溝通.
    • 不管是 High-speed 或 Full-speed 或 Low-speed, 接下來 Host 會下 Control Transfer 來 Get Device Descriptor, 而 Device 必須告訴 Host 自己本身的相關資訊.
    • 之後, Host 會再下 Control Transfer 來 Set Device Address, 給 Devcie 一個非 00 的 address, 做為以後 device 的門號
    • Host 會再 Get Device Descriptor 一次確認 Address 成功
    • Host 再下 Control Transfer 來 Set Configuration, 針對 device 做一些設定確保連線.
    • 原則上大部分的 USB 產品到上面步驟6 就已經連上囉, 之後 Host 就會再針對不同 class 的產品下不同的指令, 例如去讀寫 FAT table 等動作, 有興趣你自己翻 USB specification 或坊間的書囉.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License