1. STM32CubeMX版本:6.8.1
2. MCU: STM32F103RCT
3. 配置成Custom Human Interface Device Class(HID) 工程。USBD_CUSTOMHID_OUTREPORT_BUF_SIZE (Maximum report buffer size)修改为64,其它参数为默认值。
4. 修改[size=14.6667px]CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE]
[size=14.6667px] {
0x06, 0x00, 0xFF, //Usage Page (Vendor-Defined 29)
0x09, 0x92, //Usage (Vendor-Defined 146)
0xA1, 0x01, //Collection (Application)
0x19, 0x00, //Usage Minimum (Undefined)
0x2A, 0xFF, 0x00, //Usage Maximum (Vendor-Defined 255)
0x15, 0x00, //Logical Minimum (0)
0x26, 0xFF, 0x00, //Logical Maximum (255)
0x75, 0x08, //Report Size (8)
0x95, 0x40, //Report Count (63)
0x91, 0x00, //Output (Data,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0x19, 0x00, //Usage Minimum (Undefined)
0x2a, 0xFF, 0x00, //Usage Maximum (Vendor-Defined 255)
0x81, 0x00, //Input (Data,Ary,Abs)
0xC0, //End Collection
}
修改以下几个宏定义
#define USBD_CUSTOM_HID_REPORT_DESC_SIZE 31
#define CUSTOM_HID_EPIN_SIZE 0x40U
#define CUSTOM_HID_EPOUT_SIZE 0x40U
5. 编译下载并连接PC,PC将其枚举成 STM32 Custom Human Interface 键盘
这个设备在Portheaper软件中会出现读访问打开HIDUSB设备失败。
请问怎样修改,才能实现枚举成未定义设备,类似上面第一张图中的STM32 STlink ,并且在Portheaper软件读访问打开HIDUSB设备成功。
|