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.

TM4C123G USB design advice needed

Hello everyone, this is my first post on the forum by the way.

My plan is to create time measuring gate for linefollowers race (@amateur robotics tournament)  using Tiva Launchpad. What I would like to hear from you is a bunch of advice on the USB library coming from TivaWare. Below I describe functionality of the device:

-understanding of custom commands like: start_measurement, reset_measurement sent my PC via USB
-automatic response with the result of the robot, PC application is notified with incoming result (via interruption?)

I have already made one gate using usb bulk device and a lot of inherited code. What I don't want in this design is polling the usb port. I mean is this possible to create a connection and from that point communicate both sides using interruptions ? On the PC I would like to use pyUSB.
Another thing is that I dont quite understand OTG concept, does it allow a system to switch between being host and device ? How would you solve a problem like this? I know that polling will work and thats sufficient but I wanted to learn how to make a really good solution for other projects using USB too.

Regards Michał


  • Hello Michal

    Welcome!

    What you are looking for is interrupt type endpoint. Look at the examples of the HID class devices which use Interrupt end points for communication.
    The OTG allows the system to change between Device or Host. In your case a pure device only implementation would be acceptable.

    Regards
    Amit
  • Michal Plebanski said:
    What I don't want in this design is polling the usb port. I mean is this possible to create a connection and from that point communicate both sides using interruptions ? On the PC I would like to use pyUSB.

    By the USB concept (<= USB2.0) - host centric: device shouldn't send any packet until host would request it -, your host has to poll the device over the USB line. However, your design may leave polling to the USB hardware on both ends (host/device).

    The outline is,
    1. Host application puts an asynchronous IN transfer call, just once.
    2. Host controller (hardware) starts polling the target IN endpoint.
    3. While no data is placed by the firmware, the IN endpoint (device hardware) returns NAK (without any firmware intervention) - polling continues
    4. When the firmware places data to the IN endpoint, the IN transfer completes at the next polling by host controller.
    5. At transfer completion, registered callback is called on the host application.
    6. Back to 1.

    Unfortunately, pyUSB doesn't support asynchronous transfer, yet.
    http://sourceforge.net/p/pyusb/mailman/message/32661373/

    As suggested in above link, you may try another python wrapper library for asynchronous transfer.
    https://github.com/vpelletier/python-libusb1

    Michal Plebanski said:
    Another thing is that I dont quite understand OTG concept, does it allow a system to switch between being host and device ? How would you solve a problem like this?

    Using OTG, you may switch host/device role every time when transfer direction switches. But role switch (HNP: Host Negotiation Protocol) takes so much time and device resources (code/ execution time). It isn't realistic for your purpose.

    Tsuneo