描述符——接口描述符

描述符定义

描述符——接口描述符_第1张图片
描述符——接口描述符_第2张图片

描述符实现

/**
 * @brief USB interface descriptor.
 */
typedef struct __attribute__ ((packed))
{
    uint8_t  bLength            ; /**< Size of this descriptor in bytes. */
    uint8_t  bDescriptorType    ; /**< INTERFACE Descriptor Type. */

    uint8_t  bInterfaceNumber   ; /**< Number of this interface. Zero-based value identifying the index in the array of concurrent interfaces supported by this configuration. */
    uint8_t  bAlternateSetting  ; /**< Value used to select this alternate setting for the interface identified in the prior field. */
    uint8_t  bNumEndpoints      ; /**< Number of endpoints used by this interface (excluding endpoint zero). If this value is zero, this interface only uses the Default Control Pipe. */
    uint8_t  bInterfaceClass    ; /**< Class code (assigned by the USB-IF). \li A value of zero is reserved for future standardization. \li If this field is set to FFH, the interface class is vendor-specific. \li All other values are reserved for assignment by the USB-IF. */
    uint8_t  bInterfaceSubClass ; /**< Subclass code (assigned by the USB-IF). \n These codes are qualified by the value of the bInterfaceClass field. \li If the bInterfaceClass field is reset to zero, this field must also be reset to zero. \li If the bInterfaceClass field is not set to FFH, all values are reserved for assignment by the USB-IF. */
    uint8_t  bInterfaceProtocol ; /**< Protocol code (assigned by the USB). \n These codes are qualified by the value of the bInterfaceClass and the bInterfaceSubClass fields. If an interface supports class-specific requests, this code identifies the protocols that the device uses as defined by the specification of the device class. \li If this field is reset to zero, the device does not use a class-specific protocol on this interface. \li If this field is set to FFH, the device uses a vendor-specific protocol for this interface. */
    uint8_t  iInterface         ; /**< Index of string descriptor describing this interface. */
}usb_desc_interface_t;

描述符含义

field description
bLength 该描述符的长度。标准的 USB 接口描述符的长度为 9 字节。
bDescriptorType 描述符的类型。接口描述符的类型编码为 0x04。
bInterfaceNumber 该接口的编号。当一个配置具有多个接口时,每个接口的编号都不同。
bAlternateSetting 该接口的备用编号。
bNumEndpoints 该接口所使用的端点数目 (不包括 0 端点)。
bInterfaceClass 接口所使用的类。
bInterfaceSubClass 接口所使用的子类。
bInterfaceProtocol 接口所使用的协议。
iInterface 接口的字符串的索引值。
  • 接口描述符决定有多少端点

描述符——接口描述符_第3张图片

你可能感兴趣的:(USB,接口描述符)