我在开发基于HID的自定义传输应用,当前的想法是实现每次64字节的报文传输通路。但是在实现过程中发现,我只能每次写入3个字节到下位机即STM32中,如果写入过多,Windows的hid驱动会提示写入失败,错误代码为31(Device A device attached to the system is not functioning).
下面是我的HID描述符以及USB端口描述符: 部分HID描述符: const u8 CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] = { 0x05, 0xAC, // USAGE_PAGE (Vendor Defined Page 1) 0x09, 0x01, // USAGE (Undefined)
0xa1, 0x01, // COLLECTION (Application)
/* PC to STM32 */ 0x85, 0x01, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 0x26, 0xFF, 0x00, /* LOGICAL_MAXIMUM (1) */ 0x75, 0x08, /* REPORT_SIZE (8) */ 0x95, 0x02, /* REPORT_COUNT (2) */ 0xB1, 0x82, /* FEATURE (Data,Var,Abs,Vol) */
0x85, 0x01, /* REPORT_ID (1) */ 0x09, 0x01, /* USAGE (LED 1) */ 0x91, 0x82, /* OUTPUT (Data,Var,Abs,Vol) */
....
}; /* CustomHID_ReportDescriptor */
USB描述符 /******************** Descriptor of Custom HID endpoints ******************/ /* 27 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */
0x81, /* bEndpointAddress: Endpoint Address (IN) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x40, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x20, /* bInterval: Polling Interval (32 ms) */ /* 34 */ 0x07, /* bLength: Endpoint Descriptor size */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */ /* Endpoint descriptor type */ 0x01, /* bEndpointAddress: */ /* Endpoint Address (OUT) */ 0x03, /* bmAttributes: Interrupt endpoint */ 0x40, /* wMaxPacketSize: 2 Bytes max */ 0x00, 0x14, /* bInterval: Polling Interval (20 ms) */ /* 41 */
其中,将HID报文中的0x95, 0x02, /* REPORT_COUNT (2) */ 改为4以下数字可以通信,改成4以上数字则不能通信,请问有兄弟遇到过雷系情况吗? |