Monday, October 11, 2010

Finally! Some real progress!

I know that a bunch of you out there were probably beginning to think that this project was showing all the signs of being vaporware, but I'm here today to let you know that it is not! In my last post I let everyone know that I had finally decided on a development platform, and today my new Toolstick base adapter and F340 daughter card arrived. I'm admittedly a USB noob, but I've already managed some awesome progress.

For those who are interested, there are several great reference materials available from Silicon Labs regarding USB HID development using their F320- and F340-series daughter cards (f you're interested in seeing them, there will be some links at the bottom of this post). I've been over them with a fine-tooth comb several times a piece over the last few days, and I've finally gotten my head wrapped around how they implement their USB functionality. I have taken a ton of notes, and I was actually able to start with their USB HID template and compile a hex file for the F340, but alas it didn't work. I'm fairly certain that I missed some kind of initialization since the PC didn't even report that there was a malfunctioning USB device.

Over the course of my reading, I had come to realize that the only real difference between a mouse and a gamepad (in the world of USB-HID) is the report descriptor. Everything else is pretty much the same. So, instead of basing my code off the template, I decided to base my code on Silicon Lab's USB mouse example. After commenting out the unnecessary stuff, modifying the report descriptor, and setting the code up to send static input values to the host, I was able to successfully enumerate the F340 as a USB HID-compliant gamepad. Below is a picture of the device showing up in Device Manager on my wife's laptop running Windows 7.

Since I got rid of my PS2 controllers a long time ago, and since I don't want to mess up my XIM just yet, the first iteration of this project is going to work with a SNES controller. Now before you get all worked up about it not working with the XIM just yet, let's remember what the biggest part of the project is: creating an adapter that will work with the PS3, and you don't have to emulate a PS2 controller to be compatible with the PS3..... or at least you didn't have to before firmware 3.50. There's a project that you can check out called Retro Adapter that has done exactly what I'm looking at try trying and his adapter has worked with the PS3 in the past. However, I emailed the guy who created it and he can't tell me if it still works with the PS3 or not. If I can't find a way to make simple HID emulation work, I'll move on to trying to emulate the TAC PS2->PS3 adatper which shouldn't be that hard since I've now got a working USB HID project to hack on.

As a side note, when I ordered my base adapter last week, I didn't realize that they came in shiny little jewel cases now. AND, as if that wasn't cool enough, the F340 daughter card has little plastic adhesive feet stuck to it's underside so that it can sit on your desk or table without having the circuit board touching anything. The more I play with this Silicon Labs stuff, the more I like it.

Anyway, here's those links that I promised.
- This one is by far the best that I've come across. It's very device specific, but it was an invaluable tool for the work I accomplished today and I'm sure I'll be going back to it before long.
- This one is also good. This document is the reason I decided to go with the F340.
- This one is a neat solution for developers that want USB functionaltiy without all the fuss. It's a set of libraries that you use to create the device firmware and the pc software. It isn't HID, but it's still a neat concept. The compiler that comes with the dev tools only compiles code that's less that 4k which might be a problem if you're doing what I'm doing an implementing the USB stuff yourself. However, this solution comes with libraries from Silicon Labs that you can use to compile your source with SDCC, a free, non-codesize restricted compiler.

1 comment:

  1. before reading any further than the first line, i have more faith in you than to expect vapor ware ;)

    ReplyDelete