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

📄 mouse_desc.c

📁 用ST92163开发的鼠标
💻 C
字号:
#include <cpu.h>
#include <version.h>
#include "mouse_desc.h"

const BYTE MOUSE_DeviceDescriptor[ MOUSE_SIZ_DEVICE_DESC] = {
    0x12,     	// bLength
    0x01,     	// bDescriptorType
    0x10, 0x01,	// bcdUSB (spec release # 1.10)
    0x00,     	// bDeviceClass
    0x00,     	// bDeviceSubClass
    0x00,     	// bDeviceProtocol
    0x08,     	// bMaxPacketSize0
    0xB7, 0x0E,	// idVendor
    0x17, 0x00, // idProduct 
    V_MINOR, V_MAJOR,	// bcdDevice ex: 2.02
	1,			// Index of string Descriptor describing manufacturer
	4,			// Index of string Descriptor describing product
	0,			// Index of string Descriptor describing the device's serial number
	0x01		// bNumConfigurations (Only one config)
} ;

const BYTE MOUSE_ConfigDescriptor[MOUSE_SIZ_CONFIG_DESC] = {
	// Configuration descriptor                                                                      
	0x09,		// bLength: Configuration Descriptor size
	0x02,		// bDescriptorType: Configuration
	MOUSE_SIZ_CONFIG_DESC,	// Length of configuration descriptor.
	0,			// MSB Length of configuration descriptor.
	0x01,		// bNumInterfaces: 1 interfaces.
	0x01,		// bConfigurationValue: Configuration value = 1
	0,			// iConfiguration: Index of string descriptor describing the configuration (None)
	0x80,		// bmAttributes: Bus powered and NO Remote wakeup
//	0xA0,		// bmAttributes: Bus powered and Remote wakeup
//	0xC0,		// bmAttributes: Self powered and NO Remote wakeup
//	0xE0,		// bmAttributes: Self powered and Remote wakeup
	0x32,		// MaxPower 100 mA
	// Interface descriptor (Interface 0 = DemoKit)
	0x09,		// bLength: Interface Descriptor size
	0x04,		// bDescriptorType: Interface descriptor type
	0x00,		// bInterfaceNumber: Interface Number = 0
	0x00,		// bAlternateSetting: No Alternate setting
	0x01,		// bNumEndpoints: one endpoints used
	0x03,		// bInterfaceClass: HID
	0x01,		// bInterfaceSubClass: BOOT
	0x02,		// bInterfaceProtocol: Mouse
	0x00,		// iInterface: Index of string descriptor (No string value)
	// HID descriptor (Demokit)
	0x09,		// bLength: HID Descriptor size
	0x21,		// bDescriptorType: HID
	0x10,		// bcdHID(LSB): HID Class Spec release number (1.10)
	0x01,		// bcdHID(MSB)
	0x00,		// bCountryCode: None
	0x01,		// bNumDescriptors: Number of HID class descriptors to follow 
	0x22,		// bDescriptorType: Report
	MOUSE_SIZ_REPORT_DESC,	// Length of report descriptor interface 0 (2 bytes)
	0,			// MSB Length of report descriptor interface 0 (2 bytes)
	// Endpoint 1 descriptor (Demokit)
	0x07,		// bLength: Endpoint Descriptor size
	0x05,		// bDescriptorType: Endpoint descriptor type
	0x81,		// bEndpointAddress: Endpoint  1 IN
	0x03,		// bmAttributes: Interrupt endpoint
	0x04,		// wMaxPacketSize(LSB): 4 Byte max (0x0004)
	0x00,		// wMaxPacketSize (MSB)
	0x0A        // bInterval: Polling Interval (10 ms = 0x0A)
};

const BYTE MOUSE_ReportDescriptor[ MOUSE_SIZ_REPORT_DESC] = {
	0x05, 0x01,			// USAGE_PAGE( Generic Desktop)
	0x09, 0x02,			// USAGE( Mouse)
	0xA1, 0x01,			// COLLECTION( Application)
	0x09, 0x01,			//	USAGE( Pointer)
	0xA1, 0x00,			//	COLLECTION( Physical)
	0x05, 0x09,			//		USAGE_PAGE( Button)
	0x19, 0x01,			//		USAGE_MINIMUM( Button 1)
	0x29, 0x03,			//		USAGE_MAXIMUM( Button 3)
	0x15, 0x00,			//		LOGICAL_MINIMUM( 0)
	0x25, 0x01,			//		LOGICAL_MAXIMUM( 1)
	0x95, 0x03,			//		REPORT_COUNT( 3)
	0x75, 0x01,			//		REPORT_SIZE( 1)
	0x81, 0x02,			//		INPUT( Data, Var, Abs)

	0x95, 0x01,			//		REPORT_COUNT( 1)
	0x75, 0x05,			//		REPORT_SIZE( 5)
	0x81, 0x03,			//		INPUT( Cnst, Var, Abs)
	0x05, 0x01,			//		USAGE_PAGE( Generic Desktop)
	0x09, 0x30,			//		USAGE( X)
	0x09, 0x31,			//		USAGE( Y)
	0x09, 0x38,			//		USAGE( Wheel)
	0x15, 0x81,			//		LOGICAL_MINIMUM( -127)
	0x25, 0x7F,			//		LOGICAL_MAXIMUM( 127)
	0x35, 0x81,			//		PHYSICAL_MINIMUM( -127)
	0x45, 0x7F,			//		PHYSICAL_MAXIMUM( 127)
	0x75, 0x08,			//		REPORT_SIZE( 8)
	0x95, 0x03,			//		REPORT_COUNT( 3)
	0x81, 0x07,			//		INPUT( Cnst, Var, Rel)

	0xC0,				//	END_COLLECTION
	0xC0				// END_COLLECTION
} ;

⌨️ 快捷键说明

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