esp32s3实现hid通信

Xiaowen_Li
Posts: 5
Joined: Tue Dec 05, 2023 2:08 pm

esp32s3实现hid通信

Postby Xiaowen_Li » Sun May 26, 2024 8:40 am

我想通过hid直接实现与电脑的数据交互,尝试在tusb_hid例程上做修改,目前测试工具可以识别到键盘,鼠标外的第三个报告描述符,但是无法实现通信,想知道是在哪里配置出现了问题。
下面是我在例程上做出修改的地方:

const uint8_t hid_report_descriptor[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(HID_ITF_PROTOCOL_KEYBOARD) ),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(HID_ITF_PROTOCOL_MOUSE) ),
TUD_HID_REPORT_DESC_GENERIC_INOUT(63,HID_REPORT_ID(3)), //添加第三个描述符

};

static const uint8_t hid_configuration_descriptor[] = {
// Configuration number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, 1, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),

// Interface number, string index, boot protocol, report descriptor len, EP In address, size & polling interval
//TUD_HID_DESCRIPTOR(0, 4, false, sizeof(hid_report_descriptor), 0x81, 16, 10),

TUD_HID_INOUT_DESCRIPTOR(0,0,HID_ITF_PROTOCOL_NONE,sizeof(hid_report_descriptor), 0x01, 0x81, 64, 10),
};

//数据发送函数
void hid_data_send(uint8_t data[], uint8_t length)
{
uint8_t reportData[63] = {0};

if (tud_hid_ready())
{
tud_hid_report(3,reportData,63);
}
}

下图是使用调试工具的连接结果
屏幕截图 2024-05-26 163840.png
屏幕截图 2024-05-26 163840.png (13.51 KiB) Viewed 3599 times

Who is online

Users browsing this forum: No registered users and 136 guests