cubleMX配置如下
修改端点描述符一次传输的数据大小

根据cubelMX标准在这里修改

编译错误

直接修改(因为没有使用nodef )编译通过
修改报告描述符(默认的描述符无法传输数据)



参考:USB协议详解第10讲(USB描述符-报告描述符)-CSDN博客https://blog.csdn.net/weiaipan1314/article/details/112504129
USB鼠标HID描述符以及数据格式_hidusb输出的数据类型-CSDN博客https://blog.csdn.net/wingceltis/article/details/103114696
实际输入的内容
对应代码
cpp
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x00, // USAGE (none)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x01, // #1 USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE(x)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x40, // REPORT_COUNT (64)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x05, 0x01, // #2 USAGE_PAGE (Generic Desktop)
0x09, 0x31, // USAGE(y)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0xFF, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x40, // REPORT_COUNT (64)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0xc0 // END_COLLECTION
修改设备描述符大小为35(上面一共35个字符)

hid收发工具
【分享】一个HID数据收发调试工具 (stmicroelectronics.cn)https://shequ.stmicroelectronics.cn/thread-613811-1-1.html

修改发送函数

修改发送buf大小(注意必须在此处修改)

错误的修改位置(由于原有模板已经在外部定义了此参数,因此不能再这里修改,否则会出错,程序死机)

正确配置之后的通信测试

特此记录
anlog
2024年4月26日