usb-descriptor

usb descriptor


更新記錄

item note
20161027 第一版

目錄


USB Descriptors

usb descriptors如下:

  • Device Descriptors
  • Configuration Descriptors
  • Interface Descriptors
  • Endpoint Descriptors[USB Descriptors]

Device Descriptor

  • CH341
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    Device Descriptor:
    | bDescriptorType : 1
    | bNumConfigurations : 1
    |---------------------------------------
    |
    Configuration Descriptor:
    | bDescriptorType : 2
    | bNumInterfaces : 1
    |
    |----------------------------
    |
    Interface Descriptor:
    | bDescriptorType : 4
    | bNumEndpoints : 3
    |
    |-----------------------------------------------------------------------------------------------------------------
    | | |
    Endpoint Descriptor: Endpoint Descriptor: Endpoint Descriptor:
    | bDescriptorType : 5

每個descriptor都會填入自已的type如下
[Standard Descriptor Types]

Device Descriptor s

Device Descriptors
device-descriptor.png

說明

item note
bDescriptorType (1) 固定為1
bcdUSB (1.10) identify the device as a USB 1.0, USB 1.1 or USB 2.0 compliant device
bDeviceClass Class Code (Assigned by USB Org)
defines the device type
bMaxPacketSize0 端點0所支持最大數據長度
  • bDeviceClass
    If equal to 0xFF, the class code is vendor specified. (表示由厂商自定义设备类型)
    If equal to Zero, each interface specifies it’s own class code (表示由接口描述符来指定)
    0x01~0xfe,表示为USB-IF定义的设备类,例如0x03为HID设备,0x09为HUB设备
    ex. USB Mouse is a Human Interface Device (HID) , 0x03

  • bMaxPacketSize0
    端點0所支持最大數據長度
    low speed : 8byte
    high speed : 8, 16,32, 64byte
    full speed : 64byte

Configuration Descriptors

Configuration Descriptors
configuration-descriptor.png

說明

  • wTotalLength
    為1個Configure內部的資料(即下例資料總合)

    1
    2
    3
    4
    5
    6
    7
    - Configure
    - Interface 0
    |- EP1
    |- EP2
    - Interface 1
    |- EP1
    |- EP2
  • bMaxPower
    1個單位表示2mA,USB最大輸出500mA,此值最大為250

Interface Descriptors

Interface Descriptors
interface-descriptors.png

說明

item note
bInterfaceNumber 由0開始,表示第幾個interface (indicates the index of the interface descriptor.)
bAlternateSetting 預設為0,由host來設定configuration生成新的EP
bNumEndpoints 表示此interface裡下生成多少EP,以ch341為例有3個(EP2 IN,EP2 OUT, EP1 IN)

Endpoint Descriptors

  • Endpoint descriptors are used to describe endpoints other than endpoint zero.

  • USB中規定,端點0沒有端點描述符,其餘端點必順包含端點描述符

Endpoint Descriptor

[Endpoint Descriptors]

說明

item 1 2 3
bEndpointAddress 0x82 EP 2 IN 0x02 EP 2 OUT 0x81 EP 1 IN
bmAttributes 2 2 3
Transfer Type Bulk Bulk Interrupt
Synch Type Nonoe None None
Usage Type Data Data Data
wMaxPacketSize 0x0020 1x 32 bytes 0x0020 1x 32 bytes 0x0008 1x 8 bytes
bInterval 0 0 1

Device Classes

[Device Classes]

Communication Device Class (CDC)


參考