Jump to content
43oh

Energia Tiva USB support


Recommended Posts

Clarification - the example I gave above of creating a device similar to the MS Sidewinder Pro was not intended as using the micro as a host for that particular joystick.

What I was trying to do was work out how one would use this library in order to create a USB device that would appear to the host computer as a joystick with similar properties.

Writing an example of code that would use the API should help clarify how it is supposed to work, and help turn up difficulties.

For instance, somebody seeing the API might assume that joystick1 can have an analog16, an analog8 and a digital stick (as I did), but somebody else might assume that it can only have one of type of joystick (i.e. joystick 1 can be either analog16 or analog8 or digital).

 

Joysticks with hat sticks, or gamepads with multiple joysticks or joypads seem to be norm, so it makes sense to design the interface to handle typical controllers.

 

 

So here is some pseudo-code of what a use of the API might look like for a launchpad that has analog and digital devices connected on various pins, and uses the API to package it up like a joystick.  

buttons[] = { button1, button2, button3, ... button8 }

setup{
  initializeHIDcomp(4, 6, 8);
}

loop{
  joyxv = analogread(joyx)
  joyyv = analogread(joyy)
  joy1_AN16(joyxv, joyyv);

  throttle = analogread(throttlepin)
  turnl = digitalread(turnleftpin)
  turnr = digitalread(turnrightpin)
  turn = (turnl ? -127 : (turnr ? 127 : 0))  // Digital sensors converted to analog reading

  joy1_AN8(throttle, turn);

  hatleft, hatright, hatup, hatdown = digitalread(bhatleft, bhatright, bhatup, bhatdown)

  joy1_DIG((hatleft ? -1 : hatright ? 1 : 0), (hatup ? 1 : hatdown ? -1 : 0));


  for (i = 0; i < sizeof (buttons); i++)
  {
    butstate = digitalread(buttons[i])
    joy1_button_set(i, butstate);
  }
}

Hope that makes it clearer.

Link to post
Share on other sites
  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

I have brought this up within TI and the good thing is that all whom I talked to are open to converting the stack to the TI modified BSD license just as DriverLib. Give it a bit more time as these thi

I know nothing about MTP, and I don't believe I've seen any reference to it in the TI usblib (may have just missed it).  Not really something I'm looking to do at this time.  I'm not entirely positive

I should be able to knock out the wrapper in a few weeks (if I get time to work on it) along with instructions for how to integrate it and usblib into Energia until such time as TI decides to move the

Ok, I see where you are going with that.  The prototype functions I setup assume that you pick one of the three options for the joystick, either AN8, AN16, or Digital.  They are meant to allow a simple single x/y axis, 8 button joystick for simple use scenarios.

 

For what you are talking about, that is far more complex than I plan to deal with for simple prototype functions, and is why I will include the ability to build custom HID devices.  I haven't decided yet exactly how I'm going to set that up.  I will probably create an example program to show how to create a custom HID descriptor, how to initialize it as a custom device, and how to send reports.  That allows for more complex devices like what you are describing to be built without having to learn the entire usblib stack like I did.

 

Once I have the wrapper completed, I'll also convert my Mame control panel code over to Energia as an example of both how to create custom composite HID devices and at least one simple method of dealing with debouncing of digital inputs, as well as report structure for USB HID devices.

 

I haven't even started on the code yet, and examples won't come till after the code is close to completion.  There is a LOT of back end work I have to do to support those simple prototype functions for the library to work.  Most of what would normally be in the device code has to be moved into the wrapper library, such as setting up the physical USB port, handling report submission and error trapping, and all of the device configuration.  It's not especially complex, but will be a fair chunk of code.

 

I will continue to post updates as things move along.  Hoping to have the header file created (if not complete or final) and a github repository setup this weekend.  Might even manage to get some code started.

 

Thank you guys for all the comments and suggestions so far.  Keep them coming!

Link to post
Share on other sites
  • 1 month later...

Hi Folks,  Hope you don't mind answering some possibly dumb questions from someone with very limited coding experience.  I recently figured out that I could not communicate with my Stellaris / Tiva launchpads the "device" USB connection.  It appears to me that this is the issue that you are working on.  Is that correct?  If you are able to accomplish what you are attempting, will it be possible to communicate with the launchpads without downloading and installing the ICDI drivers?  I would like to use some launchpad based instruments to teach chemistry labs and I foresee installing the drivers on the student computers as a major obstacle.  If this is not what you are  working on and there is a simple answer to my problem, I would be grateful for that info.

Thanks,  Jack

Link to post
Share on other sites

While you would not need the ICDI drivers, you still might need drivers, depending on your operating system and what type of communication you are using.

Specifically, Windows often needs to install drivers for a USB_CDC (serial port) device.  

However I believe Linux generally does not need a driver installed for USB_CDC.

For HID devices (joystick, mouse, keyboard), both Windows and Linux have built-in drivers.

I do not know about Macs, although since they have *nix underpinnings I would sort of expect them to act more like Linux in this regard.

 

So, if your device acts like a serial port, then it might need a driver for Windows.  If it looks like one of the other HID types, then probably not.

Link to post
Share on other sites
  • 6 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...