Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.23 KB | None | 0 0
  1. __ALIGN_BEGIN static uint8_t USBD_AUDIO_CfgDesc[USB_AUDIO_CONFIG_DESC_SIZ] __ALIGN_END =
  2. {
  3.   /* Configuration 1 */
  4.   0x09,                                 /* bLength */
  5.   USB_DESC_TYPE_CONFIGURATION,          /* bDescriptorType */
  6.   LOBYTE(USB_AUDIO_CONFIG_DESC_SIZ),    /* wTotalLength  109 bytes*/
  7.   HIBYTE(USB_AUDIO_CONFIG_DESC_SIZ),      
  8.   0x03,                                 /* bNumInterfaces: conf, in, DFU*/
  9.   0x01,                                 /* bConfigurationValue */
  10.   USBD_IDX_CONFIG_STR,                  /* iConfiguration */
  11.   0x80,                                 /* bmAttributes  BUS Powered*/
  12.   0x32,                                 /* bMaxPower = 100 mA*/
  13.   /* 09 byte*/
  14.  
  15.   /* USB Microphone Standard interface descriptor */  
  16.   0x09,                                 /* bLength */
  17.   USB_DESC_TYPE_INTERFACE,              /* bDescriptorType */  
  18.   0x00,                                 /* bInterfaceNumber */
  19.   0x00,                                 // Alternate Setting Number
  20.   0x00,                                 // Number of endpoints in this intf
  21.   USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
  22.   AUDIO_SUBCLASS_AUDIOCONTROL,          /* bInterfaceSubClass */
  23.   0x00,                                 // Protocol code
  24.   0x00,                                 // Interface string index
  25.   /* 09 byte*/
  26.  
  27.   /* USB Microphone Class-specific AC Interface Descriptor  */
  28.   0x09,                                 // Size of this descriptor, in bytes.
  29.   AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
  30.   AUDIO_CONTROL_HEADER,                 /* bDescriptorSubtype */
  31.   0x00,0x01,                            // Audio Device compliant to the USB Audio specification version 1.00
  32.   0x1E,0x00,                            // Total number of bytes returned for the class-specific AudioControl interface descriptor.
  33.                                         // Includes the combined length of this descriptor header and all Unit and Terminal descriptors.
  34.   0x01,                                 // The number of AudioStreaming interfaces in Audio Interface Collection which this AudioControl interface belongs
  35.   0x01,                                 // AudioStreaming interface 1 belongs to this AudioControl interface.
  36.   /* 09 byte*/
  37.  
  38.   /* Microphone Input Terminal */
  39.  
  40.   /* USB Speaker Input Terminal Descriptor */
  41.   AUDIO_INPUT_TERMINAL_DESC_SIZE,       /* bLength */
  42.   AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
  43.   AUDIO_CONTROL_INPUT_TERMINAL,         /* bDescriptorSubtype */
  44.   0x01,                                 /* bTerminalID */
  45.   0x01,                                 /* wTerminalType 0x0201, generic microphone */
  46.   0x02,
  47.   0x00,                                 /* bAssocTerminal */
  48.   0x0A,                                 /* bNrChannels */
  49.   0x00,                                 /* wChannelConfig 0x0000 means no spacial info available */
  50.   0x00,
  51.   0x00,                                 /* iChannelNames */
  52.   0x00,                                 /* iTerminal */
  53.   /* 12 byte*/
  54.  
  55.   /*USB IN (to host) Audio Streaming Output Terminal */
  56.   AUDIO_OUTPUT_TERMINAL_DESC_SIZE,      /* bLength */
  57.   AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
  58.   AUDIO_CONTROL_OUTPUT_TERMINAL,        /* bDescriptorSubtype */
  59.   0x04,                                 /* bTerminalID */
  60.   0x01,                                 /* wTerminalType  0x0101, USB Streaming*/
  61.   0x01,
  62.   0x02,                                 /* bAssocTerminal - the USB stream from host */
  63.   0x01,                                 /* bSourceID - the microphone */
  64.   0x00,                                 /* iTerminal - unused */
  65.   /* 09 byte*/
  66.  
  67.   /*
  68.    * Microphone Standard AS Interface Descriptor - Audio Streaming Zero Bandwith
  69.    * Interface 1, Alternate Setting 0
  70.    */
  71.   AUDIO_INTERFACE_DESC_SIZE,            /* bLength */
  72.   USB_DESC_TYPE_INTERFACE,              /* bDescriptorType */
  73.   0x01,                                 /* bInterfaceNumber */
  74.   0x00,                                 /* bAlternateSetting */
  75.   0x00,                                 /* bNumEndpoints */
  76.   USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
  77.   AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
  78.   AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
  79.   0x00,                                 /* iInterface */
  80.   /* 09 byte*/
  81.  
  82.   /* Microphone Standard AS Interface Descriptor - Audio Streaming Operational */
  83.   /* Interface 1, Alternate Setting 1                                           */
  84.   AUDIO_INTERFACE_DESC_SIZE,            /* bLength */
  85.   USB_DESC_TYPE_INTERFACE,              /* bDescriptorType */
  86.   0x01,                                 /* bInterfaceNumber */
  87.   0x01,                                 /* bAlternateSetting */
  88.   0x01,                                 /* bNumEndpoints */
  89.   USB_DEVICE_CLASS_AUDIO,               /* bInterfaceClass */
  90.   AUDIO_SUBCLASS_AUDIOSTREAMING,        /* bInterfaceSubClass */
  91.   AUDIO_PROTOCOL_UNDEFINED,             /* bInterfaceProtocol */
  92.   0x00,                                 /* iInterface */
  93.   /* 09 byte*/
  94.  
  95.   /* Microphone Class-specific Audio Streaming Interface Descriptor */
  96.   AUDIO_STREAMING_INTERFACE_DESC_SIZE,  /* bLength */
  97.   AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
  98.   AUDIO_STREAMING_GENERAL,              /* bDescriptorSubtype */
  99.   0x04,                                 /* bTerminalLink: AudioStream Output Terminal */
  100.   0x01,                                 /* bDelay */
  101.   0x01,                                 /* wFormatTag AUDIO_FORMAT_PCM  0x0001*/
  102.   0x00,
  103.   /* 07 byte*/
  104.  
  105.   /* Microphone Audio Type I Format Interface Descriptor */
  106.   0x0B,                                 /* bLength */
  107.   AUDIO_INTERFACE_DESCRIPTOR_TYPE,      /* bDescriptorType */
  108.   AUDIO_STREAMING_FORMAT_TYPE,          /* bDescriptorSubtype */
  109.   AUDIO_FORMAT_TYPE_I,                  /* bFormatType */
  110.   0x0A,                                 /* bNrChannels */
  111.   0x02,                                 /* bSubFrameSize :  2 Bytes per sample (16bits) */
  112.   16,                                   /* bBitResolution (16-bits per sample) */
  113.   0x01,                                 /* bSamFreqType only one frequency supported */
  114.   AUDIO_SAMPLE_FREQ(USBD_AUDIO_FREQ),         /* Audio sampling frequency coded on 3 bytes */
  115.   /* 11 byte*/
  116.  
  117.   /* Endpoint 1 - Standard Descriptor */
  118.   AUDIO_STANDARD_ENDPOINT_DESC_SIZE,    /* bLength */
  119.   USB_DESC_TYPE_ENDPOINT,               /* bDescriptorType */
  120.   AUDIO_IN_EP,                         /* bEndpointAddress 1 out endpoint*/
  121.   USBD_EP_TYPE_ISOC,                    /* bmAttributes */
  122.   AUDIO_PACKET_SZE(USBD_AUDIO_FREQ, 10, 2), /* wMaxPacketSize in Bytes (Freq(Samples)*10(channels)*2(16bit)) */
  123.   0x01,                                 /* bInterval */
  124.   0x00,                                 /* bRefresh */
  125.   0x00,                                 /* bSynchAddress */
  126.   /* 09 byte*/
  127.  
  128.   /* Endpoint - Audio Streaming Descriptor*/
  129.   AUDIO_STREAMING_ENDPOINT_DESC_SIZE,   /* bLength */
  130.   AUDIO_ENDPOINT_DESCRIPTOR_TYPE,       /* bDescriptorType */
  131.   AUDIO_ENDPOINT_GENERAL,               /* bDescriptor */
  132.   0x00,                                 /* bmAttributes */
  133.   0x00,                                 /* bLockDelayUnits */
  134.   0x00,                                 /* wLockDelay */
  135.   0x00,
  136.   /* 07 byte*/
  137.  
  138.   /* DFU interface - This is just here to show that DFU interface exists. Device will be reset into DFU mode following ctrl command */
  139.   0x09,                                 /* bLength, 9 bytes */
  140.   0x04,                                 /* bDescriptor type : Interface */
  141.   0x02,                                 /* This is the second interface */
  142.   0x00,                                 /* Zero alternate settings */
  143.   0x00,                                 /* Only control pipe */
  144.   0xfe,                                 /* Class code */
  145.   0x01,                                 /* Upgrade code */
  146.   0x01,                                 /* Protocol number */
  147.   USBD_IDX_DFU_STR,                     /* String descriptor index */
  148.   /* DFU function descriptor */
  149.   0x09,
  150.   0x21,                                 /* DFU function */
  151.   0x0B,                                 /* Device will reset the bus, device can upload and download. Not manifestation tolerant (part of ST spec) */
  152.   LOBYTE(200),
  153.   HIBYTE(200),                          /* Timeout of 0.2s for the host to reset the bus, but device resets within 3ms or so, so unclear how important */
  154.   LOBYTE(12),                           /* Max number of bytes in a control request, 12 bytes covers all poss commands? */
  155.   HIBYTE(12),  
  156.   0x1a,                                 /* BCD version number for supported DFU protocol - version 1.1a - ST specific DfuSe*/
  157.   0x01,
  158. } ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement