自制USB HID笔设备仅适用于Windows 7/Linux

自制USB HID笔设备仅适用于Windows 7/Linux,windows,embedded,usb,hid,stm32,Windows,Embedded,Usb,Hid,Stm32,我用STM32F4微控制器制作了一个USB HID笔设备。我的设备在Windows7或Debian7(Linux)上运行得非常好 问题是=>它在Windows 8、8.1、10等上不起作用 我的设备被识别为“HID手写笔”,usb视图没有错误,管道是打开的,但我的光标不会移动。 更糟糕的是,我没有看到任何数据包与UsbLyzer一起进出 编辑: On windows 7 = PowerDevice = stay @ D0 On windows 8 = PowerDevice = D0 1s

我用STM32F4微控制器制作了一个USB HID笔设备。我的设备在Windows7或Debian7(Linux)上运行得非常好

问题是=>它在Windows 8、8.1、10等上不起作用

我的设备被识别为“HID手写笔”,usb视图没有错误,管道是打开的,但我的光标不会移动。 更糟糕的是,我没有看到任何数据包与UsbLyzer一起进出

编辑:

 On windows 7 = PowerDevice = stay @ D0
 On windows 8 = PowerDevice = D0 1s an then = D3
以下是计算机如何查看我的设备(usbview):

这是我的设备HID描述符:

0x05, 0x0d,                         // USAGE_PAGE (Digitizers)
0x09, 0x02,                         // USAGE (Pen)

0xa1, 0x01,                         // COLLECTION (Application)
0x09, 0x02,                         //   USAGE (pen)

0xa1, 0x00,                         //   COLLECTION (Physical)

0x09, 0x42,                         //     USAGE (Tip Switch)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x25, 0x01,                         //     LOGICAL_MAXIMUM (1)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x95, 0x03,                         //     REPORT_COUNT (3)
0x81, 0x03,                         //     INPUT (Cnst,Ary,Abs)

0x09, 0x32,                         //     USAGE (In Range)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x95, 0x03,                         //     REPORT_COUNT (3)
0x81, 0x03,                         //     INPUT (Cnst,Ary,Abs)

0x09, 0x56,                         //     USAGE (Scan time)
0x16, 0x00, 0x00,                   //     LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00,                   //     LOGICAL_MAXIMUM (255)
0x75, 0x08,                         //     REPORT_SIZE (8)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Ary,Abs)

// X TILT
0x09, 0x3d,                         //     USAGE (X tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

// Y TILT
0x09, 0x3e,                         //     USAGE (Y tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0x08, 0x52,                   //     LOGICAL_MAXIMUM (21000) /// 0x08, 0x52, = 21000
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x30,                         //     USAGE (X)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0x08, 0x52,                   //     PHYSICAL_MAXIMUM (21000) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs)

0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0xd0, 0x39,                   //     LOGICAL_MAXIMUM (14800) /// 0xd0, 0x39, = 14800
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x31,                         //     USAGE (Y)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0xd0, 0x39,                   //     PHYSICAL_MAXIMUM (14800) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs) 

0xc0,                               //   END_COLLECTION
0xc0,                               // END_COLLECTION

我改变了很多事情:

  • 改变我做填充物的方式
  • 我不再发送扫描时间了
  • 。。。。也许其他人有很多东西没什么变化
我终于制造出了一个可以工作的装置

这是我的usb配置描述符和IAD(HID笔设备+CDC)

/**********************USB配置描述符**********************/

0x09,                                 /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType: Configuration */
USB_CONFIG_DESC_SIZE,                 /* wTotalLength: Bytes returned */
0x00,
0x03,                                 /*bNumInterfaces: 3 interface*/
0x01,                                 /*bConfigurationValue: Configuration value*/
0x01,                                 /*iConfiguration: Index of string descriptor describing the configuration*/
0x80,                                 /*bmAttributes: self powered  */
0xFA,                                 /*MaxPower 500 mA: this current is used for detecting Vbus*/
/* Total 09 */
0x09,                             /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,    /*bDescriptorType: Interface descriptor type*/
0x00,                             /*bInterfaceNumber: Number of Interface*/
0x00,                             /*bAlternateSetting: Alternate setting*/
0x01,                             /*bNumEndpoints*/
0x03,                             /*bInterfaceClass: HID*/
0x00,                             /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00,                             /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00,                             /*iInterface: Index of string descriptor*/
/* Total 18 */
/******************** Descriptor of Digitizer HID ********************/
0x09,                             /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE,              /*bDescriptorType: HID*/
0x11,                             /*bcdHID: HID Class Spec release number*/
0x01,
0x00,                             /*bCountryCode: Hardware target country*/
0x01,                             /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22,                             /*bDescriptorType*/
HID_DIGITIZER_REPORT_DESC_SIZE,   /*wItemLength: Total length of Report descriptor*/
0x00,
/* Total 27 */
/******************** Descriptor of Digitizer endpoint ********************/
0x07,                             /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE,     /*bDescriptorType:*/
HID_IN_EP,                        /*bEndpointAddress: Endpoint Address (IN)*/
0x03,                             /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET_DIG,                /*wMaxPacketSize: 4 Byte max */
0x00,
0x03,                             /*bInterval: Polling Interval (3 ms)*/
/* Total 34 */  
0x08,                               // Size of this descriptor in bytes
0x0B,                               // Interface association descriptor type
0x01,                               // First associated interface
0x02,                               // Number of contiguous associated interfaces
COMM_INTF,                          // bInterfaceClass of the first interface
ABSTRACT_CONTROL_MODEL,             // bInterfaceSubClass of the first interface
V25TER,                             // bInterfaceProtocol of the first interface
0x00,                               // Interface string index
/* Total 42 */
// Interface Descriptor
0x09,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
CDC_COMM_INTF_ID,                   // Interface number
0x00,                               // Alternate setting number
0x01,                               // Number of endpoints in this interface
COMM_INTF,                          // Class code
ABSTRACT_CONTROL_MODEL,             // Subclass code
V25TER,                             // Protocol code
0x00,                               // Interface string index
/* Total 51 */

// CDC Class Specific
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_HEADER,                      // bDescriptorSubtype
0x20, 0x01,                         // bcdCDC
/* Total 56 */

// Abstract Control Management Functional Descriptor
0x04,                               // Size of this descriptor in bytes (4)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_ACM,                         // bDescriptorSubtype
USB_CDC_ACM_FN_DSC_VAL,             // bmCapabilities: (see PSTN120.pdf Table 4)
/* Total 60 */

// Union Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_UNION,                       // bDescriptorSubtype
0x01,                               // bControlInterface
0x02,                               // bSubordinateInterface0
/* Total 65 */

// Call Management Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_CALL_MGT,                    // bDescriptorSubtype
0x00,                               // bmCapabilities
0x02,                               // bDataInterface
/* Total 70 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes (7)
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_CMD_EP,                           // Endpoint address
_INTERRUPT,                         // Attributes
CDC_COMM_IN_EP_SIZE, 0x00,          // Size
0x02,                               // Interval
/* Total 77 */

// CDC Data Interface
0x09,                               // Size of this descriptor in bytes (9)
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
0x02,                               // Interface number
0x00,                               // Alternate setting number
0x02,                               // Number of endpoints in this interface
DATA_INTF,                          // Class code
0x00,                               // Subclass code
NO_PROTOCOL,                        // Protocol code
0x00,                               // Interface string index
/* Total 86 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_OUT_EP,                          // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00,                               // Interval
/* Total 93 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_IN_EP,                           // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00
/* Total 100 */
/**********************HID数字化仪接口**********************/

0x09,                                 /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType: Configuration */
USB_CONFIG_DESC_SIZE,                 /* wTotalLength: Bytes returned */
0x00,
0x03,                                 /*bNumInterfaces: 3 interface*/
0x01,                                 /*bConfigurationValue: Configuration value*/
0x01,                                 /*iConfiguration: Index of string descriptor describing the configuration*/
0x80,                                 /*bmAttributes: self powered  */
0xFA,                                 /*MaxPower 500 mA: this current is used for detecting Vbus*/
/* Total 09 */
0x09,                             /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,    /*bDescriptorType: Interface descriptor type*/
0x00,                             /*bInterfaceNumber: Number of Interface*/
0x00,                             /*bAlternateSetting: Alternate setting*/
0x01,                             /*bNumEndpoints*/
0x03,                             /*bInterfaceClass: HID*/
0x00,                             /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00,                             /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00,                             /*iInterface: Index of string descriptor*/
/* Total 18 */
/******************** Descriptor of Digitizer HID ********************/
0x09,                             /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE,              /*bDescriptorType: HID*/
0x11,                             /*bcdHID: HID Class Spec release number*/
0x01,
0x00,                             /*bCountryCode: Hardware target country*/
0x01,                             /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22,                             /*bDescriptorType*/
HID_DIGITIZER_REPORT_DESC_SIZE,   /*wItemLength: Total length of Report descriptor*/
0x00,
/* Total 27 */
/******************** Descriptor of Digitizer endpoint ********************/
0x07,                             /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE,     /*bDescriptorType:*/
HID_IN_EP,                        /*bEndpointAddress: Endpoint Address (IN)*/
0x03,                             /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET_DIG,                /*wMaxPacketSize: 4 Byte max */
0x00,
0x03,                             /*bInterval: Polling Interval (3 ms)*/
/* Total 34 */  
0x08,                               // Size of this descriptor in bytes
0x0B,                               // Interface association descriptor type
0x01,                               // First associated interface
0x02,                               // Number of contiguous associated interfaces
COMM_INTF,                          // bInterfaceClass of the first interface
ABSTRACT_CONTROL_MODEL,             // bInterfaceSubClass of the first interface
V25TER,                             // bInterfaceProtocol of the first interface
0x00,                               // Interface string index
/* Total 42 */
// Interface Descriptor
0x09,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
CDC_COMM_INTF_ID,                   // Interface number
0x00,                               // Alternate setting number
0x01,                               // Number of endpoints in this interface
COMM_INTF,                          // Class code
ABSTRACT_CONTROL_MODEL,             // Subclass code
V25TER,                             // Protocol code
0x00,                               // Interface string index
/* Total 51 */

// CDC Class Specific
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_HEADER,                      // bDescriptorSubtype
0x20, 0x01,                         // bcdCDC
/* Total 56 */

// Abstract Control Management Functional Descriptor
0x04,                               // Size of this descriptor in bytes (4)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_ACM,                         // bDescriptorSubtype
USB_CDC_ACM_FN_DSC_VAL,             // bmCapabilities: (see PSTN120.pdf Table 4)
/* Total 60 */

// Union Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_UNION,                       // bDescriptorSubtype
0x01,                               // bControlInterface
0x02,                               // bSubordinateInterface0
/* Total 65 */

// Call Management Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_CALL_MGT,                    // bDescriptorSubtype
0x00,                               // bmCapabilities
0x02,                               // bDataInterface
/* Total 70 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes (7)
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_CMD_EP,                           // Endpoint address
_INTERRUPT,                         // Attributes
CDC_COMM_IN_EP_SIZE, 0x00,          // Size
0x02,                               // Interval
/* Total 77 */

// CDC Data Interface
0x09,                               // Size of this descriptor in bytes (9)
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
0x02,                               // Interface number
0x00,                               // Alternate setting number
0x02,                               // Number of endpoints in this interface
DATA_INTF,                          // Class code
0x00,                               // Subclass code
NO_PROTOCOL,                        // Protocol code
0x00,                               // Interface string index
/* Total 86 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_OUT_EP,                          // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00,                               // Interval
/* Total 93 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_IN_EP,                           // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00
/* Total 100 */
/*****************接口关联描述符**********************/

0x09,                                 /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType: Configuration */
USB_CONFIG_DESC_SIZE,                 /* wTotalLength: Bytes returned */
0x00,
0x03,                                 /*bNumInterfaces: 3 interface*/
0x01,                                 /*bConfigurationValue: Configuration value*/
0x01,                                 /*iConfiguration: Index of string descriptor describing the configuration*/
0x80,                                 /*bmAttributes: self powered  */
0xFA,                                 /*MaxPower 500 mA: this current is used for detecting Vbus*/
/* Total 09 */
0x09,                             /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,    /*bDescriptorType: Interface descriptor type*/
0x00,                             /*bInterfaceNumber: Number of Interface*/
0x00,                             /*bAlternateSetting: Alternate setting*/
0x01,                             /*bNumEndpoints*/
0x03,                             /*bInterfaceClass: HID*/
0x00,                             /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00,                             /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00,                             /*iInterface: Index of string descriptor*/
/* Total 18 */
/******************** Descriptor of Digitizer HID ********************/
0x09,                             /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE,              /*bDescriptorType: HID*/
0x11,                             /*bcdHID: HID Class Spec release number*/
0x01,
0x00,                             /*bCountryCode: Hardware target country*/
0x01,                             /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22,                             /*bDescriptorType*/
HID_DIGITIZER_REPORT_DESC_SIZE,   /*wItemLength: Total length of Report descriptor*/
0x00,
/* Total 27 */
/******************** Descriptor of Digitizer endpoint ********************/
0x07,                             /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE,     /*bDescriptorType:*/
HID_IN_EP,                        /*bEndpointAddress: Endpoint Address (IN)*/
0x03,                             /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET_DIG,                /*wMaxPacketSize: 4 Byte max */
0x00,
0x03,                             /*bInterval: Polling Interval (3 ms)*/
/* Total 34 */  
0x08,                               // Size of this descriptor in bytes
0x0B,                               // Interface association descriptor type
0x01,                               // First associated interface
0x02,                               // Number of contiguous associated interfaces
COMM_INTF,                          // bInterfaceClass of the first interface
ABSTRACT_CONTROL_MODEL,             // bInterfaceSubClass of the first interface
V25TER,                             // bInterfaceProtocol of the first interface
0x00,                               // Interface string index
/* Total 42 */
// Interface Descriptor
0x09,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
CDC_COMM_INTF_ID,                   // Interface number
0x00,                               // Alternate setting number
0x01,                               // Number of endpoints in this interface
COMM_INTF,                          // Class code
ABSTRACT_CONTROL_MODEL,             // Subclass code
V25TER,                             // Protocol code
0x00,                               // Interface string index
/* Total 51 */

// CDC Class Specific
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_HEADER,                      // bDescriptorSubtype
0x20, 0x01,                         // bcdCDC
/* Total 56 */

// Abstract Control Management Functional Descriptor
0x04,                               // Size of this descriptor in bytes (4)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_ACM,                         // bDescriptorSubtype
USB_CDC_ACM_FN_DSC_VAL,             // bmCapabilities: (see PSTN120.pdf Table 4)
/* Total 60 */

// Union Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_UNION,                       // bDescriptorSubtype
0x01,                               // bControlInterface
0x02,                               // bSubordinateInterface0
/* Total 65 */

// Call Management Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_CALL_MGT,                    // bDescriptorSubtype
0x00,                               // bmCapabilities
0x02,                               // bDataInterface
/* Total 70 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes (7)
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_CMD_EP,                           // Endpoint address
_INTERRUPT,                         // Attributes
CDC_COMM_IN_EP_SIZE, 0x00,          // Size
0x02,                               // Interval
/* Total 77 */

// CDC Data Interface
0x09,                               // Size of this descriptor in bytes (9)
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
0x02,                               // Interface number
0x00,                               // Alternate setting number
0x02,                               // Number of endpoints in this interface
DATA_INTF,                          // Class code
0x00,                               // Subclass code
NO_PROTOCOL,                        // Protocol code
0x00,                               // Interface string index
/* Total 86 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_OUT_EP,                          // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00,                               // Interval
/* Total 93 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_IN_EP,                           // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00
/* Total 100 */
/*****************疾病控制中心描述符**********************/

0x09,                                 /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE,    /* bDescriptorType: Configuration */
USB_CONFIG_DESC_SIZE,                 /* wTotalLength: Bytes returned */
0x00,
0x03,                                 /*bNumInterfaces: 3 interface*/
0x01,                                 /*bConfigurationValue: Configuration value*/
0x01,                                 /*iConfiguration: Index of string descriptor describing the configuration*/
0x80,                                 /*bmAttributes: self powered  */
0xFA,                                 /*MaxPower 500 mA: this current is used for detecting Vbus*/
/* Total 09 */
0x09,                             /*bLength: Interface Descriptor size*/
USB_INTERFACE_DESCRIPTOR_TYPE,    /*bDescriptorType: Interface descriptor type*/
0x00,                             /*bInterfaceNumber: Number of Interface*/
0x00,                             /*bAlternateSetting: Alternate setting*/
0x01,                             /*bNumEndpoints*/
0x03,                             /*bInterfaceClass: HID*/
0x00,                             /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
0x00,                             /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00,                             /*iInterface: Index of string descriptor*/
/* Total 18 */
/******************** Descriptor of Digitizer HID ********************/
0x09,                             /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE,              /*bDescriptorType: HID*/
0x11,                             /*bcdHID: HID Class Spec release number*/
0x01,
0x00,                             /*bCountryCode: Hardware target country*/
0x01,                             /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22,                             /*bDescriptorType*/
HID_DIGITIZER_REPORT_DESC_SIZE,   /*wItemLength: Total length of Report descriptor*/
0x00,
/* Total 27 */
/******************** Descriptor of Digitizer endpoint ********************/
0x07,                             /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE,     /*bDescriptorType:*/
HID_IN_EP,                        /*bEndpointAddress: Endpoint Address (IN)*/
0x03,                             /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET_DIG,                /*wMaxPacketSize: 4 Byte max */
0x00,
0x03,                             /*bInterval: Polling Interval (3 ms)*/
/* Total 34 */  
0x08,                               // Size of this descriptor in bytes
0x0B,                               // Interface association descriptor type
0x01,                               // First associated interface
0x02,                               // Number of contiguous associated interfaces
COMM_INTF,                          // bInterfaceClass of the first interface
ABSTRACT_CONTROL_MODEL,             // bInterfaceSubClass of the first interface
V25TER,                             // bInterfaceProtocol of the first interface
0x00,                               // Interface string index
/* Total 42 */
// Interface Descriptor
0x09,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
CDC_COMM_INTF_ID,                   // Interface number
0x00,                               // Alternate setting number
0x01,                               // Number of endpoints in this interface
COMM_INTF,                          // Class code
ABSTRACT_CONTROL_MODEL,             // Subclass code
V25TER,                             // Protocol code
0x00,                               // Interface string index
/* Total 51 */

// CDC Class Specific
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_HEADER,                      // bDescriptorSubtype
0x20, 0x01,                         // bcdCDC
/* Total 56 */

// Abstract Control Management Functional Descriptor
0x04,                               // Size of this descriptor in bytes (4)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_ACM,                         // bDescriptorSubtype
USB_CDC_ACM_FN_DSC_VAL,             // bmCapabilities: (see PSTN120.pdf Table 4)
/* Total 60 */

// Union Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_UNION,                       // bDescriptorSubtype
0x01,                               // bControlInterface
0x02,                               // bSubordinateInterface0
/* Total 65 */

// Call Management Functional Descriptor
0x05,                               // Size of this descriptor in bytes (5)
CS_INTERFACE,                       // bDescriptorType
DSC_FN_CALL_MGT,                    // bDescriptorSubtype
0x00,                               // bmCapabilities
0x02,                               // bDataInterface
/* Total 70 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes (7)
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_CMD_EP,                           // Endpoint address
_INTERRUPT,                         // Attributes
CDC_COMM_IN_EP_SIZE, 0x00,          // Size
0x02,                               // Interval
/* Total 77 */

// CDC Data Interface
0x09,                               // Size of this descriptor in bytes (9)
USB_DESCRIPTOR_INTERFACE,           // Interface descriptor type
0x02,                               // Interface number
0x00,                               // Alternate setting number
0x02,                               // Number of endpoints in this interface
DATA_INTF,                          // Class code
0x00,                               // Subclass code
NO_PROTOCOL,                        // Protocol code
0x00,                               // Interface string index
/* Total 86 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_OUT_EP,                          // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00,                               // Interval
/* Total 93 */

// Endpoint Descriptor
0x07,                               // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT,            // Endpoint descriptor
CDC_IN_EP,                           // Endpoint address
_BULK,                              // Attributes
DESC_CONFIG_WORD(0x40),             // Size
0x00
/* Total 100 */

最后是我使用的HID描述符:

0x05, 0x0d,                         // USAGE_PAGE (Digitizers)
0x09, 0x01,                         // USAGE (Digitizers)
// +4
0xa1, 0x01,                         // COLLECTION (Application)
0x09, 0x02,                         //   USAGE (pen)
// +4
0xa1, 0x00,                         //   COLLECTION (Physical)
// +2
0x09, 0x42,                         //     USAGE (Tip Switch)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x25, 0x01,                         //     LOGICAL_MAXIMUM (1)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +12
0x09, 0x00,                         //     USAGE (Undefined / Padding)
0x75, 0x03,                         //     REPORT_SIZE (3)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x03,                         //     INPUT (Cnst,Var,Abs)
// +8
0x09, 0x32,                         //     USAGE (In Range)
0x75, 0x01,                         //     REPORT_SIZE (1)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +8
0x09, 0x00,                         //     USAGE (Undefined / Padding)
0x75, 0x03,                         //     REPORT_SIZE (3)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x81, 0x03,                         //     INPUT (Cnst,Var,Abs)
// +8
// X TILT
0x09, 0x3d,                         //     USAGE (X tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
// Y TILT
0x09, 0x3e,                         //     USAGE (Y tilt)
0x16, 0xd8, 0xdc,                   //     LOGICAL_MINIMUM (-9000)
0x26, 0x28, 0x23,                   //     LOGICAL_MAXIMUM (9000)
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0E,                         //     UNIT_EXPONENT (-2)
0x65, 0x14,                         //     UNIT (en dg)
0x36, 0xd8, 0xdc,                   //     PHYSICAL_MINIMUM (-9000)
0x46, 0x28, 0x23,                   //     PHYSICAL_MAXIMUM (9000)
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop)
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0x08, 0x52,                   //     LOGICAL_MAXIMUM (21000) /// 0x08, 0x52, = 21000
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x30,                         //     USAGE (X)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0x08, 0x52,                   //     PHYSICAL_MAXIMUM (21000) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs)
// +24
0x15, 0x00,                         //     LOGICAL_MINIMUM (0)
0x26, 0xd0, 0x39,                   //     LOGICAL_MAXIMUM (14800) /// 0xd0, 0x39, = 14800
0x75, 0x10,                         //     REPORT_SIZE (16)
0x95, 0x01,                         //     REPORT_COUNT (1)
0x55, 0x0d,                         //     UNIT_EXPONENT (-3)
0x65, 0x11,                         //     UNIT (en cm)
0x09, 0x31,                         //     USAGE (Y)
0x35, 0x00,                         //     PHYSICAL_MINIMUM (0)
0x46, 0xd0, 0x39,                   //     PHYSICAL_MAXIMUM (14800) 
0x81, 0x02,                         //     INPUT (Data,Var,Abs) 
// +22
0xc0,                               //   END_COLLECTION
0xc0,                               // END_COLLECTION
// +2
// TOTAL = 142

您是否有在stm32f4板上运行linux时所遵循的步骤,在任何地方或任何类型的b中都有提及?我想我的问题是,除了D0(活动)之外,我不处理电源状态。我搜索如何拒绝HID Windows驱动程序要求的“PowerDeviceD3”功率级别,但我不知道我是否真的可以这样做。