?? desc.h
字號(hào):
unsigned char DEV_DESC[]= { 18, /*Device Descriptor length*/ 1, /*Decriptor type*/ 0x00, /*0x0001 is Specification Version (BCD)即符合USB1.0標(biāo)準(zhǔn)*/ 0x01, 0x00, /*Device class*/ 0x00, /*Device sub-class*/ 0x00, /*Device sub-sub-class*/ 8, /*Maximum packet size*/ 0x19, /*Vendor ID=0x1419(Samsung Semi)*/ 0x14, 0x30, /*Product ID=0x0130*/ 0x01, 0x00, /*Product version ID*/ 0x01, 1, /*Manufacturer string index*/ 2, /*Product string index*/ 3, /*Serial number string index*/ 1 /*Number of configurations*/ };/*Configuration The configuration descriptor describes information about a specific device configuration.The descriptorcontains a bConfigurationValue field with a value that,when used as parameter to the SetConfiguration()request,cause the device to assume the described configuration. The descriptor descriptor describes the number of interface provided by the configuration.Each interfacemay operate independently.For example,an ISDN device might be configured with two interface,each prviding64KB/s bi-directional channels that have separate data sources or sinks on the host.Another configuration mightpresent the ISDN device as a single interface,bonding the two channels into one 128KB/s bi-directional channels. When the host requests the configuration descriptor,all related interface and endpoint descriptors arereturn. A USB device has one or more configuration descriptors.Each configuration has one or more interface and eachinterface has zero or more endpoints.An endpoint is not shared among interfaces whthin a single configurationunless the endpoint is used by alternate settings of the same interface.Endpoints may be shared among interfacethat are part of different configuration.Following shows the standard configuration descriptor.--------------------------------------------------------|Offset| Field |Size|Value ||======+===================+====+========+| 0 |bLength | 1 |Number |size of this descriptor in bytes|------+-------------------+----+--------+--------------------------------| 1 |bDescriptorType | 1 |Constant|CONFIGURATION Descriptor Type|------+-------------------+----+--------+--------------------------------| 2 |wTotalLength | 2 |Number ||------+-------------------+----+--------+| 4 |bNumInterfaces | 1 |Number ||------+-------------------+----+--------+| 5 |bConfigurationValue| 1 |Number ||------+-------------------+----+--------+| 6 |iConfiguration | 1 |Index ||------+-------------------+----+--------+*/unsigned char CFG_DESC[]= { 9, /*Configuration Descriptor length of this desc*/ 2, /*Decriptor type(CONFIGURATION)*/ 60, /*TOTAL LENGTH of data returned(LSB)->60Bytes*/ 0x00, /*TOTAL LENGTH of data returned(MSB)*/ 0x01, /*NUM OF INTERFACES*/ 1, /*ID of this CONFIG (1 FOR NOW)*/ 4, /*Config string index*/ 0x80, /*Bus power*/ 150, /*MAX POWER, 300MA FOR NOW*//*following is interface descriptor*/ 9, /*Size of this*/ 4, /*TYPE:interface*/ 0x00, /*Index of this interface*/ 0x00, /*Index of this alternate setting*/ 0x06, /*endpoint number由于在這里我們使用了6個(gè)endpoint(endpoint1~3×2),所以這里為6*/ 0xff, /*InterfaceClass*/ 0xff, /*InterfaceSubClass*/ 0xff, /*InterfaceProtocol*/ 5, /*Interface string index*//*following is standard BULK IN endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x81, /*IN endpoint 1*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, /**/ 0x00, /**//*following is standard BULK OUT endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x01, /*OUT endpoint 1*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, 0x00,/*following is standard BULK IN endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x82, /*IN endpoint 2*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, /**/ 0x00, /**//*following is standard BULK OUT endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x02, /*OUT endpoint 2*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, 0x00,/*following is standard BULK IN endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x83, /*IN endpoint 3*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, /**/ 0x00, /**//*following is standard BULK OUT endpointer descriptor*/ 7, /*Size of this descriptor*/ 5, /*Descriptor type:endpoint*/ 0x03, /*OUT endpoint 3*/ 0x02, /*BULK*/ 64, /*Max Packet size is 64bytes*/ 0x00, 0x00 };#define MFG_STR_OFS 4#define PID_STR_OFS 30#define SER_STR_OFS 58#define CON_STR_OFS 70#define IFC_STR_OFS 116unsigned char STR_OFFSET[]= { 0, MFG_STR_OFS, /*Index1 string在STR_DATA[]中的偏移量*/ PID_STR_OFS, /*Index2 string在STR_DATA[]中的偏移量*/ SER_STR_OFS, /*Index3 string在STR_DATA[]中的偏移量*/ CON_STR_OFS, /*Index4 string在STR_DATA[]中的偏移量*/ IFC_STR_OFS /*Index5 string在STR_DATA[]中的偏移量*/ };unsigned char STR_DATA[]= { /*index0 is for Language ID*/ 4, /*String descriptor length*/ 3, /*DSCR Type is string */ 9,4 /*English language ID *//*the offset of here is 4*/ /*following is index1 string*/ ,26, /*Index1 String descriptor length*/ 3, /*DSCR Type is string */ 'H',0, 'a',0, 'r',0, 'd',0, ' ',0, '&',0, ' ',0, 'S',0, 'o',0, 'f',0, 't',0, ' ',0/*the offset of here is 30*/ /*following is index2 string*/ ,28, /*Index2 String descriptor length*/ 3, /*DSCR Type is string */ 'S',0, 'a',0, 'm',0, 'A',0, 'r',0, 'm',0, ' ',0, 'D',0, 'V',0, 'K',0, ' ',0, ' ',0, ' ',0/*the offset of here is 58*/ /*following is index3 string*/ ,12, /*Index3 String descriptor length*/ 3, /*DSCR Type is string */ 'V',0, '2',0, '.',0, '0',0, '0',0/*the offset of here is 70*/ /*following is index4 string*/ ,46, /*Index4 String descriptor length*/ 3, 'S',0, 't',0, 'a',0, 'n',0, 'd',0, 'a',0, 'r',0, 'd',0, ' ',0, 'C',0, 'o',0, 'n',0, 'f',0, 'i',0, 'g',0, 'u',0, 'a',0, 'r',0, 't',0, 'i',0, 'o',0, 'n',0/*the offset here is 116*/ /*following is index5 string*/ ,36, /*Index5 String descriptor length*/ 3, 'F',0, 'o',0, 'r',0, ' ',0, 'S',0, '3',0, 'C',0, '4',0, '4',0, 'B',0, '0',0, '(',0, 'A',0, 'R',0, 'M',0, '7',0, ')',0/*the offset here is 152*/};unsigned char ReportDescriptor[]={0,1,2,3,4,5,6,7,8,9};#define DEV_DESC_SIZE sizeof(DEV_DESC)#define CFG_DESC_SIZE sizeof(CFG_DESC)#define STR_DATA_SIZE sizeof(STR_DATA)#define RPT_DESC_SIZE sizeof(ReportDescriptor)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -