先给出完整的usb描述符供参考: const unsigned char Demo_DeviceDescriptor[] = { //Device:USB1.10,Vid=0x0435,Pid=0x2430,bNumConfigurations= 0x01, 0x12,//Length 0x01,//DescriptorType 0x10, 0x01,//bcdUSB 0x00,//DeviceClass 0x00,//DeviceSubClass 0x00,//DeviceProtocol 0x08,//bMaxPacketSize8 0x35, 0x04,//idVendor........ 0x30, 0x24,//idProduct........ 0x01, 0x00,//bcdDevice 1,//iManufacturer 2,//iProduct 3,//iSerialNumber 0x01//bNumConfigurations }; /* USB Configuration Descriptor */ /*All Descriptors (Configuration,Interface, Endpoint, Class, Vendor */ const unsigned char Demo_ConfigDescriptor[] = { //Configuration:wTotalLength =0x00be,NumInterfaces = 0x03, 0x09,//Length 0x02,//DescriptorType: ConfigDescriptor 0xbe, 0x00,//TotalLength:0x00be 0x03,//NumInterfaces:3 0x01,//ConfigurationValue 0x00,//ConfigurationString 0x80,//Attributes:BusPower 0xfa,//MaxPower =0xfa*2ma //standard interface ACdescriptor(Interface 0, Alternate Setting 0): //bNumEndpoints =0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x01(audio ctl), 0x09,//Length 0x04,//DescriptorType:Inerface 0x00,//InterfaceNum:0 0x00, //AlternateSetting:0 0x00,//NumEndpoint:0 0x01,//InterfaceClass:audio 0x01,//InterfaceSubClass:audioctl 0x00,//InterfaceProtocol 0x00,//InterfaceString //class-specific AC interfacedescriptor,audio interface(0x24),audio control header(0x01), //Total Length 0x0048,Number ofstreaming interface 2,interfaceNr 2,1 0x0a,//Length 0x24,//DescriptorType:audiointerface descriptor 0x01,//DescriptorSubType:audiocontrol header 0x00, 0x01,//bcdADC:audio Device Class v1.00 0x48, 0x00,//TotalLength:0x0048 0x02,//InCollection:2AudioStreaming interface 0x02,//InterfaceNr(2)- AS #1 id AudioStreaming interface 2 belongs to this AudioControlinterface 0x01,//InterfaceNr(1)- AS #2 id AudioStreaming interface 1 belongs to this AudioControlinterface //USB Microphone IT:audiointerface descriptor,audio control input terminal(0x02),terminal id 0x01, //Microphone(0x0201),InputTerminal(0x02),2 channel:Left Front,Right Front 0x0c,//Length 0x24,//DescriptorType:audiointerface descriptor 0x02,//DescriptorSubType:InputTerminal 0x01,//TerminalID:0x01 0x01, 0x02,//TerminalType:USB Microphone 0x00,//AssocTerminal 0x02,//NrChannels:2channel 0x03, 0x00,//ChannelConfig:Left Front,Right Front, 0x00,//ChannelNameString 0x00,//TerminalString //Audio Feature UnitDescriptor:audio interface descriptor,feature_unit(0x06),terminal id 0x02, //SourceId 0x01,ControlSize0x01,Mute,Volume, 0x0a,//Length 0x24,//DescriptorType:audiointerface descriptor 0x06,//DescriptorSubType:AudioFeature Unit 0x02,//UnitID:0x02 0x01,//SourceID:1#Microphone IT 0x01,//ControlSize:1byte 0x01,//Controls:Mute 0x02,//Controls(0):Volume 0x02,//Controls(1):Volume 0x00,//Feature String //USB Streaming OT:audiointerface descriptor,audio control output terminal(0x03),terminal id 0x03, //USB Streaming(0x0101),OutputTerminal(0x03),SourceId 0x02, 0x09,//Length 0x24,//DescriptorType:audiointerface descriptor 0x03,//DescriptorSubTYpe:OutputTerminal 0x03,//TerminalID:0x03 0x01, 0x01,//TerminalType:USB Streaming 0x00,//AssocTerminal:ID0 0x02,//SourceID:2#Feature UNIT 0x00,//TerminalString //USB USB Streaming IT:audiointerface descriptor,audio control input terminal(0x02),terminal id 0x04, //USB Streaming(0x0101),InputTerminal(0x02),2 channel:Left Front,Right Front 0x0c,//Length 0x24,//DescriptorType:audiointerface descriptor 0x02,//DescriptorSubType:InputTerminal 0x04,//TerminalID:0x04 0x01, 0x01,//TerminalType:USB Streaming 0x00,//AssocTerminal 0x02,//NrChannels:2channel 0x03, 0x00,//ChannelConfig:Left Front,Right Front, 0x00,//ChannelNameString 0x00,//TerminalString //Audio Feature UnitDescriptor:audio interface descriptor,feature_unit(0x06),terminal id 0x05, //SourceId 0x04,ControlSize0x01,Mute,Volume, 0x0a,//Length 0x24,//DescriptorType:audiointerface descriptor 0x06,//DescriptorSubType:AudioFeature Unit 0x05,//UnitID:0x05 0x04,//SourceID:4 #USBStreaming IT 0x01,//ControlSize:1byte 0x01,//Controls:Mute, 0x02,//Controls(0):Volume 0x02,//Controls(1):Volume 0x00,//FeatureString //USB Speaker OT:audio interfacedescriptor,audio control output terminal(0x03),terminal id 0x06, //USB Speaker(0x0301),OutputTerminal(0x03),SourceId 0x05, 0x09,//Length 0x24,//DescriptorType:audiointerface descriptor 0x03,//DescriptorSubTYpe:OutputTerminal 0x06,//TerminalID:0x06 0x01, 0x03,//TerminalType:Speaker 0x00,//AssocTerminal: 0x05,//SourceID:5#Feature UNIT 0x00,//Terminal String //-------------------Microphoneinterface---------------------// //standardinterface AS descriptor(Interface 1, Alternate Setting 0): //bNumEndpoints =0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audiostream), 0x09,//Length 0x04,//DescriptorType:Interface 0x01,//InterfaceNum:1 0x00,//AlternateSetting:0 0x00,//NumEndpoint:0 0x01,//InterfaceClass:audio 0x02,//InterfaceSubClass:audiostreaming 0x00,//InterfaceProtocol 0x00,//InterfaceString //standard interface ASdescriptor(Interface 1, Alternate Setting 1): //bNumEndpoints = 0x01,bInterFaceClass = 0x01(audio),bInterfaceSubClass= 0x02(audio stream), 0x09,//Length 0x04,//DescriptorType:Interface 0x01,//InterfaceNum:1 0x01,//AlternateSetting:1 0x01,//NumEndpoint:1 0x01,//InterfaceClass:audio 0x02,//InterfaceSubClass:audiostreaming 0x00,//InterfaceProtocol 0x00,//Interface String //Audio Streaming InterfaceDescriptor:AS_GENERAL(0x01), //TerminalLink 0x03,PCM(0x0001) 0x07,//Length 0x24,//DescriptorType:audiointerface descriptor 0x01,//DescriptorSubType:AS_GENERAL 0x03,//TerminalLink:#3USBUSB Streaming OT 0x01,//Delay:1 0x01, 0x00,//FormatTag:PCM //Type 1 Format typedescriptor:FORMAT_TYPE(0x02),FORMAT_TYPE_I(0x01), //physical channels 0x02,twobyte per audio subframe(0x02),16bit, //32K(0x007d00) 0x0b,//Length 0x24,//DescriptorType:audiointerface descriptor 0x02,//DescriptorSubType:Format_type 0x01,//FormatType:Formattype 1 0x02,//NumberOfChanne:2 0x02,//SubframeSize:2byte 0x10,//BitsResolution:16bit 0x01,//SampleFreqType:Onesampling frequency. 0x00, 0x7d, 0x00,//32K(0x007d00) //Endpoint 1 - StandardDescriptor:Input Endpoint1 //Isochronous,SynchronizationType(Asynchronous),MaxPacketSize 0x0084, 0x07,//Length 0x05,//DescriptorType:endpointdescriptor 0x81,//EndpointAddress:Inputendpoint 1 0x05,//Attributes:0x05,Isochronous,SynchronizationType(Asynchronous)......... 0x84, 0x00,//MaxPacketSize:0x0084=........ 0x01,//Interval //Endpoint - Audio StreamingDescriptor: //Audio Endpointdescriptor,General, 0x07,//Length 0x25,//DescriptorType:audioendpoint descriptor 0x01,//DescriptorSubType:audioendpiont general 0x00,//Attributes:0x00........ 0x00,//LockDelayUnits 0x00, 0x00,//LockDelay //-------------------Speakerinterface---------------------// //standard interfaceAS descriptor(Interface 2, Alternate Setting 0): //bNumEndpoints =0x00,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream), 0x09,//Length 0x04,//DescriptorType:Interface 0x02,//InterfaceNum:2 0x00,//AlternateSetting:0 0x00,//NumEndpoint:0 0x01,//InterfaceClass:audio 0x02,//InterfaceSubClass:audiostreaming 0x00,//InterfaceProtocol 0x00,//InterfaceString //standard interface ASdescriptor(Interface 2, Alternate Setting 1): //bNumEndpoints =0x01,bInterFaceClass = 0x01(audio),bInterfaceSubClass = 0x02(audio stream), 0x09,//Length 0x04,//DescriptorType:Interface 0x02,//InterfaceNum:2 0x01,//AlternateSetting:1 0x01,//NumEndpoint:1 0x01,//InterfaceClass:audio 0x02,//InterfaceSubClass:audiostreaming 0x00,//InterfaceProtocol 0x00,//InterfaceString //Audio Streaming InterfaceDescriptor:AS_GENERAL(0x01), //TerminalLink 0x04,PCM(0x0001) 0x07,//Length 0x24,//DescriptorType:audiointerface descriptor 0x01,//DescriptorSubType:AS_GENERAL 0x04,//TerminalLink:#4USB Streaming IT 0x01,//Delay:1 0x01, 0x00,//FormatTag:PCM //Type 1 Format typedescriptor:FORMAT_TYPE(0x02),FORMAT_TYPE_I(0x01), //physical channels 0x02,twobyte per audio subframe(0x02),16bit, //32K(0x007d00) 0x0b,//Length 0x24,//DescriptorType:audiointerface descriptor 0x02,//DescriptorSubType:Format_type 0x01,//FormatType:Formattype 1 0x02,//NumberOfChanne:2 0x02,//SubframeSize:2byte 0x10,//BitsResolution:16bit 0x01,//SampleFreqType:Onesampling frequency. 0x00, 0x7d, 0x00,//32K(0x007d00) //Endpoint 2 - StandardDescriptor:Output Endpoint2 //Isochronous,SynchronizationType(Asynchronous),MaxPacketSize 0x0084, 0x07,//Length 0x05,//DescriptorType:endpoint descriptor 0x02,//EndpointAddress:Outputendpoint 2 0x05,//Attributes:0x05,Isochronous,SynchronizationType(Asynchronous)......... 0x84, 0x00,//MaxPacketSize:0x0084=..... 0x01,//Interval //Endpoint - Audio StreamingDescriptor: //Audio Endpointdescriptor,General, 0x07,//Length 0x25,//DescriptorType:audioendpoint descriptor 0x01,//DescriptorSubType:audioendpiont general 0x00,//Attributes:0x00............. 0x00,//LockDelayUnits 0x00, 0x00,//LockDelay }; /* USB String Descriptor (optional) */ const unsigned char Demo_StringLangID[] = { 0x04, 0x03, 0x09, 0x04 }; const unsigned char Demo_StringVendor[] = { 0x26, //Length 0x03, //DescriptorType 'D', 0, 'e', 0, 'm', 0, 'o', 0, '-', 0, 's', 0, 'p', 0, 'e', 0, 'r', 0, 'k', 0, 'e', 0, 'r', 0, 'p', 0, 'h', 0, 'o', 0, 'n', 0, 'e', 0, '1', 0 }; const unsigned char Demo_StringProduct[] = { 0x1c,//Length 0x03,//DescriptorType 'S', 0, 'p', 0, 'e', 0, 'a', 0, 'k', 0, 'e', 0, 'r', 0, 'p', 0, 'h', 0, 'o', 0, 'n', 0, 'e', 0, '2', 0 }; const unsigned char Demo_StringSerial[] = { 0x1c,//Length 0x03,//DescriptorType 'S', 0, 'p', 0, 'e', 0, 'a', 0, 'k', 0, 'e', 0, 'r', 0, 'p', 0, 'h', 0, 'o', 0, 'n', 0, 'e', 0, '2', 0 }; 相关说明: 2.描述符的分层组织结构 3.设备描述符里采用的Vendor和Product ID号是随便写的一个用于测试。 |
|