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

📄 joy_desc.c

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

const BYTE JOYSTICK_DeviceDescriptor[ JOYSTICK_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
    0x18, 0x00, // idProduct 
    V_MINOR, V_MAJOR,	// bcdDevice ex: 2.02
	1,			// Index of string Descriptor describing manufacturer
	5,			// Index of string Descriptor describing product
	0,			// Index of string Descriptor describing the device's serial number
	0x01		// bNumConfigurations (Only one config)
} ;

const BYTE JOYSTICK_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC] = {
	// Configuration descriptor                                                                      
	0x09,		// bLength: Configuration Descriptor size
	0x02,		// bDescriptorType: Configuration
	JOYSTICK_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
	0x00,		// bInterfaceSubClass: none
	0x00,		// bInterfaceProtocol: none
	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
	JOYSTICK_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
	0x07,		// wMaxPacketSize(LSB): 7 Byte max (0x0007)
	0x00,		// wMaxPacketSize (MSB)
	0x0A        // bInterval: Polling Interval (10 ms = 0x0A)
};

const BYTE JOYSTICK_ReportDescriptor[ JOYSTICK_SIZ_REPORT_DESC] = {
	0x05, 0x01,			/* USAGE_PAGE (Generic Desktop) */
	0x09, 0x04,			/* USAGE (Joystick) */
	0xA1, 0x01,			/* COLLECTION (Application) */

	0x09, 0x01,			/*  USAGE (Pointer) */
	0xa1, 0x00,			/*   COLLECTION (Physical) */
	0x05, 0x09,			/*     USAGE_PAGE (Button) */
	0x19, 0x01,			/*     USAGE_MINIMUM (Button 1) */
	0x29, 0x06,			/*     USAGE_MAXIMUM (Button 6) */
	0x15, 0x00,			/*     LOGICAL_MINIMUM (0) */
	0x25, 0x01,			/*     LOGICAL_MAXIMUM (1) */
	0x35, 0x00,			/*     PHYSICAL_MINIMUM (0) */
	0x45, 0x01,			/*     PHYSICAL_MAXIMUM (1) */
	0x75, 0x01,			/*     REPORT_SIZE (1) */
	0x95, 0x06,			/*     REPORT_COUNT (8) */
	0x81, 0x02,			/*     INPUT (Data,Var,Abs) */

	0x75, 0x01,			/*     REPORT_SIZE (1) */
	0x95, 0x02,			/*     REPORT_COUNT (2) */
	0x81, 0x01,			/*     INPUT (Padding) */

	0x05, 0x01,			/*     USAGE_PAGE (Generic Desktop) */
	0x09, 0x30,			/*     USAGE (X) */
	0x09, 0x31,			/*     USAGE (Y) */
	0x15, 0x00,			/*     LOGICAL_MINIMUM (0) */
	0x26, 0xff, 0x00,	/*     LOGICAL_MAXIMUM (255) */
	0x35, 0x00,			/*     PHYSICAL_MINIMUM (0) */
	0x46, 0xff, 0x00,	/*     PHYSICAL_MAXIMUM (255) */
    0x65, 0x00,			/*     Unit (None) */
	0x75, 0x08,			/*     REPORT_SIZE (8) */
	0x95, 0x02,			/*     REPORT_COUNT (2) */
	0x81, 0x02,			/*     INPUT (Data,Var,Abs) */

	0xc0,				/*   END_COLLECTION */

	0xc0				/* END_COLLECTION */
} ;

⌨️ 快捷键说明

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