Windows识别自定义HID设备需要什么?

时间:2018-02-04 00:14:53

标签: c++ embedded usb stm32f4discovery windows-kernel

目前,我正在使用STM32F746G-DISCO开发套件,我正在尝试构建一个通用的HID设备。 (不是键盘,不是控制器,不是鼠标等)使用mbed库,设置非常简单,无痛。我能够导入他们的USBHID.h并声明一个设备。

USBHID(descriptor.output_report_length, descriptor.input_report_length, descriptor.vendor_id, descriptor.product_id, descriptor.product_release, descriptor.connect)

给定由我创建的描述符结构中的默认值定义的值:

{
    this->output_report_length = 64;
    this->input_report_length = 64;
    this->vendor_id = 0x1234;
    this->product_id = 0x500;
    this->product_release = 0x0001;
    this->connect = true;
}

所有这些都在USBHID.cpp(mbed的库)中创建USB HID报告描述:

uint8_t * USBHID::reportDesc() {
static uint8_t reportDescriptor[] = {
    0x06, LSB(0xFFAB), MSB(0xFFAB),
    0x0A, LSB(0x0200), MSB(0x0200),
    0xA1, 0x01,         // Collection 0x01
    0x75, 0x08,         // report size = 8 bits
    0x15, 0x00,         // logical minimum = 0
    0x26, 0xFF, 0x00,   // logical maximum = 255
    0x95, input_length, // report count
    0x09, 0x01,         // usage
    0x81, 0x02,         // Input (array)
    0x95, output_length,// report count
    0x09, 0x02,         // usage
    0x91, 0x02,         // Output (array)
    0xC0                // end collection

};
reportLength = sizeof(reportDescriptor);
return reportDescriptor;
}

给定输入长度,输出长度都通过上面显示的结构传递。

我正在运行代码,并将现在应该是USBHID的USB端口插入我的计算机,现在设备显示在设备管理器下面,如下所示:

Under Human Interface Devices

我可以看到它是我编程的设备: enter image description here

并且Windows声明设备无法启动。这是为什么?有效设备的握手过程是什么样的?我可以在这里找到什么?

我更进了一步,确认其他mbed示例有效。其中一个是USB-HID鼠标,它可以根据需要检测和运行。

我正在设置此项目以向此设备发送和接收自定义报告。

0 个答案:

没有答案