This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] TM4C123GH6PM:遵循 USB 库(修订版 e)时、USBHIDInit 似乎会失败

Guru**** 2522140 points
Other Parts Discussed in Thread: EK-TM4C123GXL

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1339424/tm4c123gh6pm-usbhidinit-seems-to-fail-when-following-the-usb-library-rev-e

器件型号:TM4C123GH6PM
主题中讨论的其他器件:EK-TM4C123GXL

您好

我在创建 HID 设备时遇到问题。
我将访问 USB 库文档版本 E (https://www.ti.com/lit/ug/spmu297e/spmu297e.pdf)。

从2.13.2开始、我一直走到第85页。
在那里它称为 "USBDHIDMouseInit"... 尽管预期的结构不是 tUSBDHIDDevice...
如果我通过转换到正确的结构来调用它、则会失败。
如果在没有强制转换的情况下使用具有相同结构的 USBHIDInit、也会失败。

它在其中一个嵌套函数"USBDCDConfigGetInterfaceEndpoint (psHIDDevice->ppsConfigDescriptor[0]、psInst->ui8Interface、0、0);"中似乎失败

有什么方法可以对其进行调试吗?

我使用的是具有 TivaWare_C_Series-2.2.0.295的 code composer

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    Unknown 说:
    有人叫"USBDHIDMouseInit"...  尽管预期的结构不是 tUSBDHIDDevice...
    [/报价]

    您的意思是、预期的结构不是 tUSBDHIDDevice?  C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\USB_dev_keyboard 中提供了 HID 键盘示例。 您可以参考 HID 键盘 示例作为起点、并为 HID 鼠标修改、因为这两种设备都是 HID 器件。  

    第85页显示:

    从主初始化函数调用 HID 设备类驱动程序初始化函数
    配置 USB 控制器并将器件放置在总线上。


    pvDevice = USBDHIDMouseInit (0、&g_sHIDMouseDevice);

    如果你看看 从83页开始定义的 sHIDMouseDevice,它是一个 HID 鼠标。  

    const tUSBDHIDDevice g_sHIDMouseDevice =
    {
    //
    // The Vendor ID you have been assigned by USB-IF.
    //
    USB_VID_YOUR_VENDOR_ID,
    //

    // The product ID you have assigned for this device.
    //
    USB_PID_YOUR_PRODUCT_ID,
    //
    // The power consumption of your device in milliamps.
    //
    POWER_CONSUMPTION_MA,
    //
    // The value to be passed to the host in the USB configuration descriptor’s
    // bmAttributes field.
    //
    USB_CONF_ATTR_BUS_PWR,
    //
    // This mouse supports the boot subclass.
    //
    USB_HID_SCLASS_BOOT,
    //
    // This device supports the BIOS mouse report protocol.
    //
    USB_HID_PROTOCOL_MOUSE,
    //
    // The device has a single input report.
    //
    1,
    //
    // A pointer to our array of tHIDReportIdle structures. For this device,
    // the array must have 1 element (matching the value of the previous field).
    //
    g_psMouseReportIdle,
    //
    // A pointer to your receive callback event handler.
    //
    YourUSBReceiveEventCallback,
    //
    // A value that you want passed to the receive callback alongside every
    // event.
    //
    (void *)&g_sYourInstanceData,
    //
    // A pointer to your transmit callback event handler.
    //
    YourUSBTransmitEventCallback,
    //
    // A value that you want passed to the transmit callback alongside every
    // event.
    //
    (void *)&g_sYourInstanceData,
    //
    // This device does not want to use a dedicated interrupt OUT endpoint
    // since there are no output or feature reports required.
    //
    false,
    //
    // A pointer to the HID descriptor for the device.

    //
    &g_sMouseHIDDescriptor,
    //
    // A pointer to the array of HID class descriptor pointers for this device.
    // The number of elements in this array and their order must match the
    // information in the HID descriptor provided above.
    //
    g_pMouseClassDescriptors,
    //
    // A pointer to your string table.
    //
    g_pStringDescriptors,
    //
    // The number of entries in your string table. This must equal
    // (1 + (5 + (num HID strings)) * (num languages)).
    //
    NUM_STRING_DESCRIPTORS
    };

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,Charles

    USBHIDMouseInit 要求结构的类型为 tUSBDHIDMouseDevice、而不是 tUSBDHIDDevice 。
    usbdhidmous.h 中定义的 API 函数:
    extern void *USBDHIDMouseInit(uint32_t ui32Index,
    tUSBDHIDMouseDevice *psMouseDevice);

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

     好的。 这是文档错误。 在第83页、它应该说:

    const tUSBDHIDMouseDevice g_sHIDMouseDevice =
    {
    //
    // The Vendor ID you have been assigned by USB-IF.
    //
    USB_VID_YOUR_VENDOR_ID,

    snipped...

    Again, I will suggest you use the usb_dev_keyboard.c example as a starting point and changing all code relevant to keyboard to mouse.