I've been bringing up the Chibi boards recently and ported FreakUSB to the ATMega32U4. I've been using FreakUSB for my development on many different boards now over the past year that its been released. Since then, I've also made modifications, ported it to different chips (all AVR tho), and have been tweaking things and fixing small bugs that have been coming up. I think that FreakUSB is at a point where its very stable for me and an indispensable tool for development, especially when paired with a command line parser. Hence, I decided to take some time to collect all the mods, package them up, and do a release.
Here are the main modifications in the v0.70 release of FreakUSB:
- Updated licenses to Modified BSD.
- This should have been done a long time ago since FreakZ has also moved to Modified BSD.
- Added flow control to prevent buffer overflow.
- I noticed that the stack would crash intermittently and found that it was caused by buffer overflow. I made the flow control smarter so that if the stack's ring buffer can't accomodate incoming data, it will instruct the chip to NAK the host until the current buffer data has been processed and the new data in the chip's FIFO has been safely moved to the buffers.
- Added smarter buffer sizing.
- Max buffer size only needs to be set in freakusb.h and all FIFO, buffer, and max packet sizes will automatically be set.
- Added command line support in main demo.
- For the demo code, I've implemented a command line parser and a command table. You enter the mnemonic of the command, and the function that it maps to inside the command table. From there, you can call the function from the command line when you connect to the device via a terminal program. Its quite useful for development. I'll add more examples later.
- Added support for AT90USB162 and ATMega32U4.
- The AT90USB162 was a bit of a challenge because there is no builtin VBUS detection to detect when the device is connected to a host. VBUS must be connected to an interrupt and the interrupt must be mapped to the ISR found in isr.c.
- Makefile automatically chooses hardware directory based on hardware part type.
- Future FreakUSB updates will be hosted on this site rather than Sourceforge
- Sourceforge's access is slow from Japan, there's a lot of formality to doing a release, and in general, its just a hassle with little benefit. I know its the vehicle of choice for open source projects, but there's a mental barrier on doing a release if I know that I'm going to need to jump through hoops to upload to their server and go through the release process. I'd prefer it to be informal and will just have the releases on the project page on this site.
I think I got a question from somebody a while back on why somone would use this stack rather than Atmel's or LUFA. Actually, LUFA is a very well maintained open source USB project with significantly more functionality than FreakUSB. Atmel's project is also...well...Atmel's. Anyways, in both cases, the projects are structured in a way that they're pretty heavily targeted towards the Atmel AVR architecture. This is a drawback for my situation since I want to eventually port to different platforms other than AVRs. Hence, I tried to make a simple stack with clear separations between hardware dependent and hardware independent code. I guess that's about it. I can't say I'd recommend my stack over anything else for AVRs. However if I can port it to platforms like Microchip and MSP430, then I can see if its really worth the effort to have a hardware independent stack :)
Here's a direct link to download the source code. You can also get it from the project page:Updated: I added an example of how to add commands to the command line parser in the demo code. Click here for the link .