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: USBHIDInit seems to fail when following the USB library (rev. e)

Part Number: TM4C123GH6PM
Other Parts Discussed in Thread: EK-TM4C123GXL

Hi

I am having troubles creating an HID device.
I am following the USB library documentation Rev. E. (https://www.ti.com/lit/ug/spmu297e/spmu297e.pdf)

Starting on 2.13.2, I followed all the way down to page 85.
There it calls  'USBDHIDMouseInit'... although the struct expected is not a tUSBDHIDDevice...
If I call it with a cast to the correct struct, it fails.
Using USBHIDInit with the same struct, without the cast, it fails as well.

It seems to fail in one of the nested functions 'USBDCDConfigGetInterfaceEndpoint(psHIDDevice->ppsConfigDescriptor[0], psInst->ui8Interface, 0, 0);'

Is there any way to debug this?

I am using code composer with TivaWare_C_Series-2.2.0.295

  • There it calls  'USBDHIDMouseInit'... although the struct expected is not a tUSBDHIDDevice...

    What do you mean the struct expected is not a tUSBDHIDDevice? There is a HID Keyboard example at C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\usb_dev_keyboard. You can reference the HID keyboard example as a starting point and modify for HID mouse since both are HID devices. 

    On page 85, it says:

    From your main initialization function call the HID device class driver initialization function to
    configure the USB controller and place the device on the bus.


    pvDevice = USBDHIDMouseInit(0, &g_sHIDMouseDevice);

    If you look at sHIDMouseDevice that is defined starting at page 83, it is a HID mouse. 

    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
    };

  • Hi Charles

    USBHIDMouseInit expects the struct to be of type tUSBDHIDMouseDevice and not tUSBDHIDDevice.
    API function as defined in usbdhidmouse.h:
    extern void *USBDHIDMouseInit(uint32_t ui32Index,
    tUSBDHIDMouseDevice *psMouseDevice);

  • Hi,

     Ok. that is a document mistake. On page 83, it should have said:

    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.