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

📄 descript.h

📁 一个用C语言编写的usb程序,测试可以运行,内附有原理图
💻 H
字号:
unsigned char code D12Test_DeviceDescriptor[] = {
	18, 1,					// Length, Type
	0x10, 1,				// USB Rev 1.1 (=0110H, low=10H, High=01H)
	0, 0, 0,				// Class, Subclass and Protocol
	EP0Size,				// EP0 size
	0x42, 0x42, 0, 1, 0, 0,			// Vendor ID, Product ID and Version
	1, 2, 0,				// Manufacturer, Product & Serial# Names
	1				      	// #Configs
};
unsigned char code D12Test_ConfigurationDescriptor[] = {
	9, 2,					// Length, Type
	34, 0,
	1, 1, 0,				// #Interfaces, Configuration#, Config. Name
	0x80,					// Attributes = Bus Powered
	250	      				// Max. Power is 50x2 = 100mA
};
unsigned char code D12Test_InterfaceDescriptor[] = {
	9, 4,					// Length, Type
	0, 0, 1,				// No alternate setting, HID uses EP1
	3,				      	// Class = Human Interface Device
	0, 0,					// Subclass and Protocol
	0				      	// Interface Name
};
unsigned char code D12Test_HIDDescriptor[] = {
	9, 0x21,				// Length, Type
	0, 1,					// HID Class Specification compliance
	0,				      	// Country localization (=none)
	1,				      	// Number of descriptors to follow
	0x22,					// And it's a Report descriptor
	28, 00
};
unsigned char code D12Test_EndpointDescriptor[] = {
	7, 5,					// Length, Type
	0x81,					// Address = IN 1
	0x03,					// Interrupt
	EP0Size, 0,			 	// Maximum packet size
	10				       	// Poll every 10 msec (OS will round down to 8) 
};

unsigned char code D12Test_ReportDescriptor[] = {	// Generated with HID Tool, copied to here
	6, 0, 0xff,		// Usage_Page (Vendor Defined)
	9, 1,			// Usage (I/O Device)
	0xa1, 1,		// Collection (Application)
	0x19, 1,		//   Usage_Minimum
	0x29, 8,		//   Usage_Maximum
	0x15, 0,		//   Logical_Minimum (0)
	0x25, 1,		//   Logical_Maximum (1)
	0x75, 1,		//   Report_Size (1)
	0x95, 8,		//   Report_Count (8)
	0x81, 2,		//   Input (Data,Var,Abs)
	0x19, 1,		//   Usage_Minimum
	0x29, 8,		//   Usage_Maximum
	0x91, 2,		//   Output (Data,Var,Abs)
	0xc0			// End_Collection
};
	 
const unsigned char code D12Test_ConfigLength[] = {34};//$-ConfigurationDescriptor
const unsigned char code D12Test_ReportLength[] = {28}; //$-ReportDescriptor


unsigned char code Keyboard_DeviceDescriptor[] = {
	18, 1,					// Length, Type
	0x10, 1,				// USB Rev 1.1 (=0110H, low=10H, High=01H)
	0, 0, 0,				// Class, Subclass and Protocol
	EP0Size,				// EP0 size
	0x42, 0x42, 0, 2, 0, 0,	// Vendor ID, Product ID and Version
	1, 0, 0,				// Manufacturer, Product & Serial# Names
	1		    			// #Configs
};
unsigned char code Keyboard_ConfigurationDescriptor[] = {
	9, 2,					// Length, Type
	34, 0,
	1, 1, 0,				// #Interfaces, Configuration#, Config. Name
	0xa0,					// Attributes = Bus Powered & Remote Wakened
	50		 			// Max. Power is 50x2 = 100mA
};
unsigned char code Keyboard_InterfaceDescriptor[] = {
	9, 4,					// Length, Type
	0, 0, 1,				// No alternate setting, HID uses EP1
	3,	      				// Class = Human Interface Device
	1, 1,					// Subclass and Protocol
	0	      				// Interface Name
};
unsigned char code Keyboard_HIDDescriptor[] = {
	9, 0x21,				// Length, Type
	0, 1,					// HID Class Specification compliance
	0,		  			// Country localization (=none)
	1,		 			// Number of descriptors to follow
	0x22,					// And it's a Report descriptor
	63, 00
};
unsigned char code Keyboard_EndpointDescriptor[] = {
	7, 5,					// Length, Type
	0x81,					// Address = IN 1
	0x03,					// Interrupt
	EP0Size, 0,			 	// Maximum packet size
	10		     			// Poll every 10 msec (OS will round down to 8) 
};

unsigned char code Keyboard_ReportDescriptor[] = {	// Generated with HID Tool, copied to here
	5, 1,	 		// Usage_Page (Vendor Defined)
	9, 6,			// Usage (I/O Device)
	0xa1, 1,		// Collection (Application)
	0x05, 07,
	0x19, 0xe0,		//   Usage_Minimum
	0x29, 0xe7,		//   Usage_Maximum
	0x15, 0,		//   Logical_Minimum (0)
	0x25, 1,		//   Logical_Maximum (1)
	0x75, 1,		//   Report_Size (1)
	0x95, 8,		//   Report_Count (8)
	0x81, 2,		//   Input (Data,Var,Abs)

	0x95, 0x01,
	0x75, 0x08,
	0x81, 0x01,
	0x95, 0x05,
	0x75, 0x01,
	0x05, 0x08,
	0x19, 0x01,
	0x29, 0x05,
	0x91, 0x02,

	0x95, 0x01,
	0x75, 0x03,
	0x91, 0x01,
	
	0x95, 0x06,
	0x75, 0x08,
	0x15, 0x00,
	0x25, 0x65,
	0x05, 0x07,
	0x19, 0x00,		//   Usage_Minimum
	0x29, 0x65,		//   Usage_Maximum
	0x81, 0x00,		//   Output (Data,Var,Abs)
	0xc0			// End_Collection
};

const unsigned char code Keyboard_ConfigLength[] = {34};//$-ConfigurationDescriptor
const unsigned char code Keyboard_ReportLength[] = {63}; //$-ReportDescriptor

unsigned char code String0[] = {	// Declare the UNICODE strings
	4, 3, 9, 4		// Only English language strings supported
};
unsigned char code String1[] = {	// Manufacturer
	44/*(D12Test_String2-D12Test_String1)*/,3, 				// Length, Type 
	'U',0,'S',0,'B',0,' ',0,'D',0,'e',0,'s',0,'i',0,'g',0,'n',0,' ', 0,
	'B',0,'y',0,' ',0,'E',0,'x',0,'a',0,'m',0,'p',0,'l',0,'e',0
};
unsigned char code String2[] = {	// Product Name
	16/*(D12Test_EndOfDescriptors-D12Test_String2)*/,3,
	'D',0,'1',0,'2',0,' ',0,'T',0,'e',0,'s',0,'t',0
};
unsigned char code EndOfDescriptors[] = {
	0		// Backstop for String Descriptors
};


unsigned char code Mouse_DeviceDescriptor[] = {
	18, 1,					// Length, Type
	0x10, 1,				// USB Rev 1.1 (=0110H, low=10H, High=01H)
	0, 0, 0,				// Class, Subclass and Protocol
	EP0Size,				// EP0 size
	0x42, 0x42, 1, 2, 0, 0,	// Vendor ID, Product ID and Version
	1, 0, 0,				// Manufacturer, Product & Serial# Names
	1		    			// #Configs
};
unsigned char code Mouse_ConfigurationDescriptor[] = {
	9, 2,					// Length, Type
	34, 0,
	1, 1, 4,				// #Interfaces, Configuration#, Config. Name
	0xa0,					// Attributes = Bus Powered & Remote Wakened
	50		 			// Max. Power is 50x2 = 100mA
};
unsigned char code Mouse_InterfaceDescriptor[] = {
	9, 4,					// Length, Type
	0, 0, 1,				// No alternate setting, HID uses EP1
	3,	      				// Class = Human Interface Device
	1, 2,					// Subclass and Protocol
	0	      				// Interface Name
};
unsigned char code Mouse_HIDDescriptor[] = {
	9, 0x21,				// Length, Type
	0, 1,					// HID Class Specification compliance
	0,		  			// Country localization (=none)
	1,		 			// Number of descriptors to follow
	0x22,					// And it's a Report descriptor
	50, 00
};
unsigned char code Mouse_EndpointDescriptor[] = {
	7, 5,					// Length, Type
	0x81,					// Address = IN 1
	0x03,					// Interrupt
	3, 0,				 	// Maximum packet size
	10		     			// Poll every 10 msec (OS will round down to 8) 
};

unsigned char code Mouse_ReportDescriptor[] = {	// Generated with HID Tool, copied to here
	5, 1,	 		// Usage_Page (Vendor Defined)
	9, 2,			// Usage (I/O Device)
	0xa1, 1,		// Collection (Application)
        0x09, 1,
        0xa1, 0,
	0x05, 9,
	0x19, 0x01,		//   Usage_Minimum
	0x29, 0x03,		//   Usage_Maximum
	0x15, 0,		//   Logical_Minimum (0)
	0x25, 1,		//   Logical_Maximum (1)
	0x95, 3,		//   Report_Count (8)
        0x75, 1,
	0x81, 2,		//   Input (Data,Var,Abs)
	0x95, 0x01,
	0x75, 0x05,
	0x81, 0x01,
	0x05, 0x01,
	0x09, 0x30,
	0x09, 0x31,
	0x15, 0x81,
	0x25, 0x7f,
	0x75, 0x08,
	0x95, 0x02,
	0x81, 0x06,
	0xc0, 0xc0		// End_Collection
};

const unsigned char code Mouse_ConfigLength[] = {34};//$-ConfigurationDescriptor
const unsigned char code Mouse_ReportLength[] = {50}; //$-ReportDescriptor



⌨️ 快捷键说明

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