⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 descriptor.h

📁 使用ch375和stc 51写的usb鼠标的代码
💻 H
字号:
/*
** HID MOUSE DESCRIPTOR DECLARATIONS
*/
unsigned char code hid_report_desc_table[] = 
{
 0x05, 0x01, /*usage page (generic desktop) */
 0x09, 0x02, /*usage (mouse) */
 0xA1, 0x01, /*collection (application) */
 0x05, 0x09, /*usage page (buttons) */
 0x19, 0x01, /*usage minimum (1) */
 0x29, 0x03, /*usage maximum (3) */
 0x15, 0x00, /*logical minimum (0) */
 0x25, 0x01, /*logical maximum (1) */
 0x95, 0x03, /*report count (3 bytes) */
 0x75, 0x01, /*report size (1) */
 0x81, 0x02, /*input (3 button bits) */
 0x95, 0x01, /*report count (1) */
 0x75, 0x05, /*report size (5) */
 0x81, 0x03, /*input (constant 5 bit padding) */
 0x05, 0x01, /*usage page (generic desktop) */
 0x09, 0x01, /*pointer*/
 0xA1, 0x00, /*linked*/
 0x09, 0x30, /*X*/
 0x09, 0x31, /*Y*/
 0x15, 0x81, /*logical minimum (-127) */
 0x25, 0x7F, /*logical maximum (127) */
 0x75, 0x08, /*report size (8) */
 0x95, 0x02, /*report count (2) */
 0x81, 0x06, /*input (2 position bytes X & Y) */
 0xC0,		 /*end collection*/
 0xc0
 /*
 0x09,0x38,  //wheel
 0x95,0x01,	 //wheel size = 1 byte
 0x81,0x06,  //variable data bit field with relative position
 0x09,0x3c,  //motion wakeup
 0x15,0x00,  //0 no movement
 0x25,0x01,  //1 movement
 0x75,0x01,  //1st bit represents movement
 0x95,0x01,  //1 report
 0xb1,0x22,  //	Variable Data Bit Field with  absolute positioning and no preferred state
 0x95,0x07,  //	7 reports for reversing, upper 7 bits of byte 3
 0xb1,0x01,  //Constant Array Bit Field with absolute positioning
 0xC0        // end collection, end collection 
 */
};


//设备描述符
unsigned char  code DevDes[]=
{
  0x12			//描述符大小			
, 0x01			//常数DEVICE
, 0x10			//USB规范版本信息
, 0x01
, 0xFF			//类别码,
, 0x80			//子类别码	
, 0x37			//协议码
, 0x08			//端点0的最大信息包大小
, 0x48			//厂商ID
, 0x43
, 0x17			//产品ID	
, 0x55
, 0x00			//设备版本信息
, 0x01
, 0x00			//索引值	
, 0x00
, 0x00
, 0x01			//可能配置的数目	18
, 0x00			//无意义
, 0x00
, 0x00
, 0x00
, 0x00
, 0x00
};

//配置描述符
unsigned char   code ConDes[]={			//配置描述符
					  0x09					//描述符大小
					,  0x02					//常数CONFIG
					,  0x22					//此配置传回所有数据大小
					,  0x00					//
					,  0x01					//接口数
					,  0x01					//配置值
					,  0x00					//索引
					,  0x80					//电源设置
					,  0x40					//需要总线电源
										//接口描述符
					,  0x09					//描述符大小								
					,  0x04					//常数INTERFACE				
					,  0x00					//识别码
					,  0x00					//代替数值
					,  0x01//0x03					//支持的端点数
					,  0x03//0xFF					//类别码
					,  0x01//0x80					//子类别码
					,  0x02//0x37					//协议码
					,  0x00					//索引
										//端点描述符
					,  0x07 			// descriptor length (7 bytes) 
					,  0x05 			// descriptor type (ENDPOINT) 
					,  0x81 			// endpoint address (IN endpoint, endpoint 1) 
					,  0x03 			// endpoint attributes (interrupt) 
					,  0x04
					,  0x00				// maximum packet size (4 bytes)  
					,  0x0A  			// polling interval (10ms) 
					
					,  0x09			// descriptor size (9 bytes)                     
					,  0x21			// descriptor type (HID)                         
					,  0x10
					,  0x01			// class specification (1.10)                    
					,  0x00			// hardware target country                       
					,  0x01			// number of hid class desriptors to follow (1)  
					,  0x22			// report descriptor type (2)                    
					,  sizeof(hid_report_desc_table)                                
					,  0x00                                                          
				};		//配置描述符配置描述符
//HID descriptor
unsigned char code hidDes[]=
{
	0x09, // Size of HID descriptor
	0x21, // HID descriptor type
	0x10, //
	0x01, //Version of HID spec 1.1
	0x00, // Country Code USA
	0x01, // Number of report descriptors
	0x22, // Descriptor type
	0x48,
	0x00
}; 

//语言描述符
unsigned char  code LangDes[]=
{
	0x04,	//Language descriptor length
	0x03,	//Language Descriptor Type
	0x09,	//English
	0x04	//US
};
//字符串描述符
unsigned char  code SerDes[]=
{
	0x12,
	0x03,
	'C',
	0,
	'H',
	0,
	'3',
	0,
	'7',
	0,
	'5',
	0,
	'U',
	0,
	'S',
	0,
	'B',
	0
}; 
 
unsigned char code Class_Descriptor[] = 
{
 0x09, 		/* descriptor size (9 bytes) */
 0x21, 		/* descriptor type (HID) */
 0x10, 0x01,/* class specification (1.10) */
 0x00, 		/* hardware target country */
 0x01, 		/* number of hid class desriptors to follow (1) */
 0x22, 		/* report descriptor type (2) */
 sizeof(hid_report_desc_table),
 0x00
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -