USB Audio&hid 混合设备的描述符详解

/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_HS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
  {
    0x12,                       /*bLength */
    USB_DESC_TYPE_DEVICE,       /*bDescriptorType*/
#if (USBD_LPM_ENABLED == 1)
    0x01,                       /*bcdUSB */ /* changed to USB version 2.01 
                                               in order to support LPM L1 suspend
                                               resume test of USBCV3.0*/
#else  
    0x00,                       /* bcdUSB  USB version 2.00*/
#endif


    0x02,
    0x00,                       /*bDeviceClass  */
    0x00,                       /*bDeviceSubClass*/
    0x00,                       /*bDeviceProtocol*/
    USB_MAX_EP0_SIZE,          /*bMaxPacketSize  64*/
    LOBYTE(USBD_VID),           /*idVendor  0x0483*/
    HIBYTE(USBD_VID),           /*idVendor*/
    LOBYTE(USBD_PID_HS),           /*idVendor 0x5730*/
    HIBYTE(USBD_PID_HS),           /*idVendor*/
    0x00,                       /*bcdDevice rel. 2.00*/
    0x02,
    USBD_IDX_MFC_STR,           /*Index of manufacturer  string  STMicroelectronics*/
    USBD_IDX_PRODUCT_STR,       /*Index of product string  STM32 Audio Class*/
    USBD_IDX_SERIAL_STR,        /*Index of serial number string  00000000001A*/
    USBD_MAX_NUM_CONFIGURATION  /*bNumConfigurations*/

  } ; 



/* USB AUDIO device Configuration Descriptor */ __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALIGN_END = {     //Configuration:wTotalLength = 0x00be,NumInterfaces = 0x03,     0x09,    //Length     USB_DESC_TYPE_CONFIGURATION,    //DescriptorType : ConfigDescriptor 0x02     LOBYTE(USB_AUDIO_CONFIG_DESC_SIZ),    /* wTotalLength  0xE0bytes*/     HIBYTE(USB_AUDIO_CONFIG_DESC_SIZ),     0x04,      //NumInterfaces:4     0x01,    //ConfigurationValue     0x00,    //Configuration String  iConfiguration     0xC0,    //Attributes:Bus Power 4..0: Reserved  ...00000  4..0: Reserved  ...00000  6: Self Powered  .1......  Yes  6: Self Powered  .1......  Yes       0x32,     //MaxPower = 0x32*2ma  100mA     /* 9Bytes */     //standard interface AC descriptor(Interface 0, Alternate Setting 0):     //bNumEndpoints = 0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x01(audio ctl),     AUDIO_INTERFACE_DESC_SIZE,    //Length 09      USB_DESC_TYPE_INTERFACE,     //4 DescriptorType:Inerface 04     0x00,     //InterfaceNum:0     0x00,       //AlternateSetting:0     0x00,       //NumEndpoint:0     USB_DEVICE_CLASS_AUDIO,       //InterfaceClass:audio  0x01  audio     AUDIO_SUBCLASS_AUDIOCONTROL,       //InterfaceSubClass:audio ctl  0x01  audio control     AUDIO_PROTOCOL_UNDEFINED,       //InterfaceProtocol  0x00     0x00,      //Interface String inlterface     /* 9Bytes */     //class-specific AC interface descriptor,audio interface(0x24),audio control header(0x01),     //Total Length 0x0048,Number of streaming interface 2,interfaceNr 2,1     //Audio Control Interface Header Descriptor      0x0a,    //Length     AUDIO_INTERFACE_DESCRIPTOR_TYPE,//DescriptorType:audio interface descriptor  0x24     AUDIO_CONTROL_HEADER,     //DescriptorSubType:audio control header  0x01     0x00,0x01,  //bcdADC:audio Device Class v1.00     0x46,0x00,  //TotalLength:0x0046     0x02,      //InCollection:2 AudioStreaming interface     0x02,      //InterfaceNr(2) - AS #1 id AudioStreaming interface 2 belongs to this AudioControl interface     0x01,     //InterfaceNr(1) - AS #2 id AudioStreaming interface 1 belongs to this AudioControl interface     /* 10Bytes */     //USB Microphone IT:audio interface descriptor,audio control input terminal(0x02),terminal id 0x01,     //Microphone(0x0201),Input Terminal(0x02),2 channel:Left Front,Right Front     // Audio Control Input Terminal Descriptor      AUDIO_INPUT_TERMINAL_DESC_SIZE,    //Length  0x0c     AUDIO_INTERFACE_DESCRIPTOR_TYPE,    //DescriptorType:audio interface descriptor 0x24     AUDIO_CONTROL_INPUT_TERMINAL,     //DescriptorSubType:Input Terminal  0x02     0x01,     //TerminalID:0x01     0x01,0x02,  //TerminalType:USB Microphone     0x00,      //AssocTerminal     0x02,///////////////      //NrChannels:2 channel     0x00,0x00,  //ChannelConfig:Left Front,Right Front,     0x00,       //ChannelName String     0x00,       //Terminal String     /* 12Bytes */     //Audio Feature Unit Descriptor:audio interface descriptor,feature_unit(0x06),terminal id 0x02,     //SourceId 0x01,ControlSize 0x01,Mute,Volume,     //Audio Control Feature Unit Descriptor      0x09,    //Length  0x09     AUDIO_INTERFACE_DESCRIPTOR_TYPE,      //DescriptorType:audio interface descriptor 0x24     AUDIO_CONTROL_FEATURE_UNIT,      //DescriptorSubType:Audio Feature Unit 0x06     AUDIO_OUT_STREAMING_CTRL,       //UnitID:0x02     0x01,      //SourceID:1 #Microphone IT     0x01,      //ControlSize:1 byte     0x01,     //Controls:Mute     0x00,      //Controls(0):Volume     // 0x02,       //Controls(1):Volume     0x00,       //Feature String     /* 10Bytes */     //USB Streaming OT:audio interface descriptor,audio control output terminal(0x03),terminal id 0x03,     //USB Streaming(0x0101),Output Terminal(0x03),SourceId 0x02,     //Audio Control Output Terminal Descriptor      0x09,    //Length  0x09     AUDIO_INTERFACE_DESCRIPTOR_TYPE, //DescriptorType:audio interface descriptor  0x24     AUDIO_CONTROL_OUTPUT_TERMINAL,  //DescriptorSubTYpe:Output Terminal 0x03     0x03,      //TerminalID:0x03     0x01,0x01,  //TerminalType:USB Streaming     0x00,       //AssocTerminal:ID 0     0x02,      //SourceID:2 #Feature UNIT     0x00,       //Terminal String     /* 9Bytes */     //USB Streaming IT:audio interface descriptor,audio control input terminal(0x02),terminal id 0x04,     //USB Streaming(0x0101),Input Terminal(0x02),2 channel:Left Front,Right Front     //Audio Control Input Terminal Descriptor      0x0c,       //Length  0x0c     0x24,       //DescriptorType:audio interface descriptor     0x02,       //DescriptorSubType:Input Terminal     0x04,       //TerminalID:0x04     0x01,0x01,  //TerminalType:USB Streaming     0x00,       //AssocTerminal     0x02,       //NrChannels:2 channel     0x00,0x00,  //ChannelConfig:Left Front,Right Front,     0x00,       //ChannelName String     0x00,       //Terminal String     /*12Bytes */     //Audio Feature Unit Descriptor:audio interface descriptor,feature_unit(0x06),terminal id 0x05,     //SourceId 0x04,ControlSize 0x01,Mute,Volume,     //Audio Control Feature Unit Descriptor      0x09,    //Length  0x09     0x24,      //DescriptorType:audio interface descriptor     0x06,       //DescriptorSubType:Audio Feature Unit     0x05,       //UnitID:0x05     0x04,      //SourceID:4 #USB Streaming IT     0x01,      //ControlSize:1 byte     0x01,      //Controls:Mute,     0x00,       //Controls(0):Volume     // 0x02,      //Controls(1):Volume     0x00,       //Feature String     /* 10Bytes */     //USB Speaker OT:audio interface descriptor,audio control output terminal(0x03),terminal id 0x06,     //USB Speaker(0x0301),Output Terminal(0x03),SourceId 0x05,     //Audio Control Output Terminal Descriptor      0x09,      //Length  0x09     AUDIO_INTERFACE_DESCRIPTOR_TYPE,      //DescriptorType:audio interface descriptor 0x24     AUDIO_CONTROL_OUTPUT_TERMINAL,      //DescriptorSubTYpe:Output Terminal 0x03     0x06,      //TerminalID:0x06     0x01,0x03,  //TerminalType:Speaker     0x00,       //AssocTerminal:     0x05,      //SourceID:5 #Feature UNIT     0x00,      //Terminal String     /* 9Bytes */     //-------------------Microphone  interface---------------------//     //standard interface AS descriptor(Interface 1, Alternate Setting 0):     //bNumEndpoints = 0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream),     //Interface Descriptor 1/0 Audio, 0 Endpoints     AUDIO_INTERFACE_DESC_SIZE,    //Length  0x09     USB_DESC_TYPE_INTERFACE,       //DescriptorType:Interface 4     0x01,      //InterfaceNum:1     0x00,      //AlternateSetting:0     0x00,       //NumEndpoint:0     USB_DEVICE_CLASS_AUDIO,      //InterfaceClass:audio  0x01     AUDIO_SUBCLASS_AUDIOSTREAMING,      //InterfaceSubClass:audio streaming  0x02     AUDIO_PROTOCOL_UNDEFINED,       //InterfaceProtocol  0x00     0x00,       //Interface String     /* 9Bytes */     //standard interface AS descriptor(Interface 1, Alternate Setting 1):     //bNumEndpoints = 0x01,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream),     //Interface Descriptor 1/1 Audio, 1 Endpoint     AUDIO_INTERFACE_DESC_SIZE,    //Length  0x09     USB_DESC_TYPE_INTERFACE,      //DescriptorType:Interface  4     0x01,      //InterfaceNum:1     0x01,      //AlternateSetting:1     0x01,       //NumEndpoint:1     USB_DEVICE_CLASS_AUDIO,      //InterfaceClass:audio  0x01     AUDIO_SUBCLASS_AUDIOSTREAMING,       //InterfaceSubClass:audio streaming  0x02     AUDIO_PROTOCOL_UNDEFINED,      //InterfaceProtocol  0x00     0x00,       //Interface String     /* 9Bytes */     //Audio Streaming Interface Descriptor:AS_GENERAL(0x01),     //TerminalLink 0x03,PCM(0x0001)     //Audio Streaming Interface Descriptor      AUDIO_STREAMING_INTERFACE_DESC_SIZE,    //Length  0x07     AUDIO_INTERFACE_DESCRIPTOR_TYPE,       //DescriptorType:audio interface descriptor 0x24     AUDIO_STREAMING_GENERAL,      //DescriptorSubType:AS_GENERAL  0x01     0x03,       //TerminalLink:#3USB USB Streaming OT     0x00,       //Delay:0     0x01,0x00,  //FormatTag:PCM     /* 7Bytes */     //Type 1 Format type descriptor:FORMAT_TYPE(0x02),FORMAT_TYPE_I(0x01),     //physical channels 0x02,two byte per audio subframe(0x02),16bit,     //Audio Streaming Format Type Descriptor      0x0b,    //Length  0x0b     AUDIO_INTERFACE_DESCRIPTOR_TYPE, //DescriptorType:audio interface descriptor 0x24     AUDIO_STREAMING_FORMAT_TYPE,  //DescriptorSubType:Format_type  0x02     AUDIO_FORMAT_TYPE_I,       //FormatType:Format type1  0x01     0x02,      //NumberOfChanne:2     0x02,       //SubframeSize:2byte     0x10,      //BitsResolution:16bit     0x01,       //SampleFreqType:One sampling frequency.     AUDIO_SAMPLE_FREQ(USBD_AUDIO_FREQ),   //32K(0x007d00)     /* 11Bytes */     //Endpoint 1 - Standard Descriptor:Input Endpoint1     //Isochronous,Synchronization Type(Asynchronous),MaxPacketSize 0x0084,     //Endpoint Descriptor 82 2 In, Isochronous, 1 ms     0x09,     //Length  0x09     USB_DESC_TYPE_ENDPOINT,      //DescriptorType:endpoint descriptor 0x05 Endpoint     AUDIO_IN_EP,       //EndpointAddress:Input endpoint 2  0x82 2In     0x0D,       //Attributes:0x0D, 1..0: Transfer Type  ......01  Isochronous  3..2: Sync Type  ....11..  Synchronous  5..4: Usage Type  ..00....  Data  7..6: Reserved  00......         AUDIO_PACKET_SZE(USBD_AUDIO_FREQ),  //0, 192 bytes   wMaxPacketSize USBD_AUDIO_FREQ 48000     0x01,      //Interval   1 ms     0x00,                                 /* bRefresh */     0x00,                                 /* bSynchAddress */     //  /* 09 byte*/     /* 7Bytes */     //Endpoint - Audio Streaming Descriptor:     //Audio Endpoint descriptor,General,     //Audio Streaming Isochronous Audio Data Endpoint Descriptor  (There is no parsing)     AUDIO_STREAMING_ENDPOINT_DESC_SIZE,    //Length  0x07     AUDIO_ENDPOINT_DESCRIPTOR_TYPE,      //DescriptorType:audio endpoint descriptor  0x25     AUDIO_ENDPOINT_GENERAL,      //DescriptorSubType:audio endpiont general  0x01     0x00,       //Attributes:0x00........     0x00,      //LockDelayUnits     0x00,0x00,  //LockDelay     /* 7Bytes */     //-------------------Speaker  interface---------------------//     //standard interface AS descriptor(Interface 2, Alternate Setting 0):     //bNumEndpoints = 0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream),     //Interface Descriptor 2/0 Audio, 0 Endpoints     AUDIO_INTERFACE_DESC_SIZE,      //Length  0x09     USB_DESC_TYPE_INTERFACE,      //DescriptorType:Interface  0x04     0x02,       //InterfaceNum:2     0x00,       //AlternateSetting:0     0x00,      //NumEndpoint:0     USB_DEVICE_CLASS_AUDIO,       //InterfaceClass:audio  0x01     AUDIO_SUBCLASS_AUDIOSTREAMING,      //InterfaceSubClass:audio streaming  0x02     AUDIO_PROTOCOL_UNDEFINED,      //InterfaceProtocol  0x00     0x00,       //Interface String     /* 9Bytes */     //standard interface AS descriptor(Interface 2, Alternate Setting 1):     //bNumEndpoints = 0x01,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream),     //Interface Descriptor 2/1 Audio, 1 Endpoint     AUDIO_INTERFACE_DESC_SIZE,      //Length  0x09     USB_DESC_TYPE_INTERFACE,      //DescriptorType:Interface 4     0x02,       //InterfaceNum:2     0x01,       //AlternateSetting:1     0x01,       //NumEndpoint:1     USB_DEVICE_CLASS_AUDIO,      //InterfaceClass:audio  0x01     AUDIO_SUBCLASS_AUDIOSTREAMING,       //InterfaceSubClass:audio streaming  0x02     AUDIO_PROTOCOL_UNDEFINED,       //InterfaceProtocol  0x00     0x00,      //Interface String     /* 9Bytes */     //Audio Streaming Interface Descriptor:AS_GENERAL(0x01),     //TerminalLink 0x04,PCM(0x0001)     //Audio Streaming Interface Descriptor      AUDIO_STREAMING_INTERFACE_DESC_SIZE,      //Length  0x07     AUDIO_INTERFACE_DESCRIPTOR_TYPE,       //DescriptorType:audio interface descriptor 0x24     AUDIO_STREAMING_GENERAL,       //DescriptorSubType:AS_GENERAL 0x01     0x04,      //TerminalLink:#4 USB Streaming IT     0x00,      //Delay:0     0x01,0x00,  //FormatTag:PCM     /* 7Bytes */     //Type 1 Format type descriptor:FORMAT_TYPE(0x02),FORMAT_TYPE_I(0x01),     //physical channels 0x02,two byte per audio subframe(0x02),16bit,     //32K(0x007d00)     //Audio Streaming Format Type Descriptor      0x0b,     //Length  0x0b     AUDIO_INTERFACE_DESCRIPTOR_TYPE,       //DescriptorType:audio interface descriptor     AUDIO_STREAMING_FORMAT_TYPE,      //DescriptorSubType:Format_type     AUDIO_FORMAT_TYPE_I,       //FormatType:Format type 1     0x02,       //NumberOfChanne:2     0x02,       //SubframeSize:2byte     0x10,      //BitsResolution:16bit     0x01,      //SampleFreqType:One sampling frequency.     AUDIO_SAMPLE_FREQ(USBD_AUDIO_FREQ),   //     /* 11Bytes */     //Endpoint 2 - Standard Descriptor:Output Endpoint2     //Isochronous,Synchronization Type(Asynchronous),MaxPacketSize 0x0084,     //Endpoint Descriptor 01 1 Out, Isochronous, 1 ms     0x09,      //Length  0x09     USB_DESC_TYPE_ENDPOINT,       //DescriptorType:endpoint descriptor 0x05     AUDIO_OUT_EP,       //EndpointAddress:Output endpoint 1  0x01     0x0D,      //Attributes:0x0d,Isochronous,Synchronization Type(Asynchronous)......... 1..0: Transfer Type  ......01  Isochronous 3..2: Sync Type  ....11..  Synchronous  5..4: Usage Type  ..00....  Data  7..6: Reserved  00......       AUDIO_PACKET_SZE(USBD_AUDIO_FREQ),  //MaxPacketSize 192 bytes     0x01,      //Interval  1ms     0x00,                                 /* bRefresh */     0x00,                                 /* bSynchAddress */     /* 09 byte*/     /* 7Bytes */     //Endpoint - Audio Streaming Descriptor:     //Audio Endpoint descriptor,General,     //Audio Streaming Isochronous Audio Data Endpoint Descriptor      AUDIO_STREAMING_ENDPOINT_DESC_SIZE,       //Length  0x07     AUDIO_ENDPOINT_DESCRIPTOR_TYPE,       //DescriptorType:audio endpoint descriptor  0x25     AUDIO_ENDPOINT_GENERAL,       //DescriptorSubType:audio endpiont general  0x01     0x00,      //Attributes:0x00.............     0x00,       //LockDelayUnits     0x00,0x00,  //LockDelay     /* 7Bytes */     /************** Descriptor of CUSTOM HID interface ****************/     //Interface Descriptor 3/0 HID, 2 Endpoints     /* 09 */     0x09,         /*bLength: Interface Descriptor size   0x09*/     USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type  0x04*/     0x03,         /*bInterfaceNumber: Number of Interface*/     0x00,         /*bAlternateSetting: Alternate setting*/     0x02,         /*bNumEndpoints*/     0x03,         /*bInterfaceClass: CUSTOM_HID*/     0x00,         /*bInterfaceSubClass : 1=BOOT, 0=no boot*/     0x00,         /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/     0,            /*iInterface: Index of string descriptor*/     /******************** Descriptor of CUSTOM_HID *************************/     /* 18 */     //HID Descriptor      0x09,         /*bLength: CUSTOM_HID Descriptor size 0x09*/     CUSTOM_HID_DESCRIPTOR_TYPE, /*bDescriptorType: CUSTOM_HID 0x21*/     0x11,         /*bCUSTOM_HIDUSTOM_HID: CUSTOM_HID Class Spec release number 1.11*/     0x01,         //1.11     0x00,         /*bCountryCode: Hardware target country*/     0x01,         /*bNumDescriptors: Number of CUSTOM_HID class descriptors to follow*/     0x22,         /*bDescriptorType  Report*/     USBD_CUSTOM_HID_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor 33 bytes*/     0x00,     /******************** Descriptor of Custom HID endpoints ********************/     /* 27 */     //Endpoint Descriptor 83 3 In, Interrupt, 9 ms     0x07,          /*bLength: Endpoint Descriptor size  0x07*/     USB_DESC_TYPE_ENDPOINT, /*bDescriptorType: 0x05*/     CUSTOM_HID_EPIN_ADDR,     /*bEndpointAddress: Endpoint Address (IN) 0x83*/     0x03,          /*bmAttributes: Interrupt endpoint 1..0: Transfer Type  ......11  Interrupt  7..2: Reserved  000000..  */     CUSTOM_HID_EPIN_SIZE, /*wMaxPacketSize: Byte max  0x40*/     0x00, //64 bytes     0x09,          /*bInterval: Polling Interval (9 ms)*/     /* 34 */     0x07,        /* bLength: Endpoint Descriptor size  0x07*/     USB_DESC_TYPE_ENDPOINT,/* bDescriptorType:  0x05*/     CUSTOM_HID_EPOUT_ADDR,  /*bEndpointAddress: Endpoint Address (OUT) 0x03*/     0x03,/* bmAttributes: Interrupt endpoint  1..0: Transfer Type  ......11  Interrupt  7..2: Reserved  000000..  */     CUSTOM_HID_EPOUT_SIZE,/* wMaxPacketSize: 64 Bytes max  0x40*/     0x00,     0x09,/* bInterval: Polling Interval (9 ms) */     /* 41 */ } ;

相关文章
相关标签/搜索