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.

CCS/TM4C1294NCPDT: Creating Custom HID Device using TivaWare USB library

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

I am trying to write a custom HID USB device using the TivaWare USB library. 

I am using the HIDKeyboard example and this forum post as a starting point. 

In the post another user provides some code base for creating a "generic" HID device:
https://gist.github.com/duanebester/068c87d84d8708603d6c
https://gist.github.com/duanebester/771d683e0c76f1fe2ca1

I have incorporated those into a my open test application (built off the hello TivaWare example).  Currently, the application compiles and runs without throwing any errors that I can see but the device is not seen in device manager so I suspect something is breaking during initialization of the USB device.  I have tried stepping through the files can chasing down all the function calls but I haven't had any luck so far.  Has anyone had any luck building a custom HID device using the TivaWare library or any other library for that matter?

I have checked that the unmodified keyboard example works and is detected in windows.


I've included my project below.

1616.hello.zip

  • Hello Erik,

    I would add in the call for MAP_IntMasterEnable(); as well, I don't see that being called and there are a few interrupts setup.

    Do you get the message on UART for "Host Connected..."? That would indicate if the device is connecting to Windows and just isn't enumerating or if the code is not even communicating with Windows.

    Depending what is going on, you may need a USB analyzer to understand where in the process this is breaking.

  • The program never receives the host connected event and therefore always hangs in the while loop before that UART message.  I am not sure where MAP_IntMasterEnable(); would be used and I have looked through the keyboard example and I don't see this function ever called, should it just be called near the start of the main loop?

  • Hello Erik,

    I would add it after:

        //
        // Set the system tick to fire 100 times per second.
        //
        MAP_SysTickPeriodSet(ui32SysClock / SYSTICKS_PER_SECOND);
        MAP_SysTickIntEnable();
        MAP_SysTickEnable();

  • Alright, I added that line but it still doesn't receive a connect event from the host.

  • Hello Erik,

    In that event, you would need to get a USB analyzer in order to check what information is being exchanged and where in the enumeration process the Custom HID device is failing to meet what Windows is expecting from the USB device. Unfortunately as I am just a device expert, I don't have in-depth knowledge on the USB enumeration requirements for interfaces like Custom HID so I don't really have much guidance I can offer. Maybe another community member will be able to assist though...

  • Erik Kinstler said:

    Alright, I added that line but it still doesn't receive a connect event from the host.

    Erik,

    The only difference between a "keyboard HID" and a "Generic HID" is the report descriptors. The "Usage Page" tells the host that the report  conforms to either a standard device, like a keyboard or mouse, or a custom/vendor-specific device. The host uses this to know which driver to load.

    Given how you describe your problem, I suspect that your report descriptor is screwed up in some way, or that the size of the descriptor is being reported incorrectly. A bus analyzer, or perhaps even Wireshark (which has USB analysis) will tell you that you have malformed descriptors.

    Getting descriptors right is part of the pain of developing a USB product!

  • Andy,

    Thanks for the tips.  Since I don't have a USB analyzer and I am not super confident about the code I was using for the "generic" device I decided to work back from the keyboard example to try and build a HID-compliant vendor-defined device which I was able to accomplish.  Looking through the generic device source and the hid keyboard source I am not entirely sure where the breakdown is.  It has to be some kind of malformed descriptor.

    For anyone looking to build a HID device with this library I really recommend working backwards from a working example to your desired configuration making small changes and observing the results as you go along.  That being said the source for this library is a rabbit-warren of pointers and structures and does require spending significant time reading and stepping through to understand and thereby be able to modify.

    Thanks for the help everyone!

    Erik