Apr 14
The HID parser will now be a part of the next MyUSB release, in the actual library. I’ve created a new folder called Class in the Drivers/USB/ directory for class-specific USB drivers and convenience API.
I’ve since made a bunch of changes to the parser, which now works with collections. Having to support collections means making linked list structures, so that for each report item, a pointer to a collection path node is present. To determine all the parent usages, you simply walk the list back to when PARENT == NULL and check the usages.
The last change to the parser I believe is to make a usages stack for the report items. Once that’s done, it should be complete enough for general use. I’ve tried it with my mice as well; my wireless Logitec works just as well as my $5 cheapy, despite the radically different report structures.
The only downside to the parser is the RAM usage. With the report and collection items being on the global structure as well as a state table stack and usages stack in the parser routine, it will require quite a bit of RAM when used (about 300 bytes with modest sizes of each stack).
If anyone needs a pre-release containing the parser before the official release, send me an email.
Apr 11
Good news! The HID report parser I started work on last night is in a working state, even if it isn’t fully completed and compliant yet. Despite that, I can now plug in any keyboard in the house and have both the formatted report data printed out, and the keypresses indicated on the USBKEY’s LED irrespective of the report formatting of the device.
I’ve had to cut a few corners to keep it all statically allocated, avoiding problematic dynamic memory allocation at runtime. To that end, the stack depth of the parser (HID reports have the capability of pushing and popping the state table onto a custom stack) and the total number of HID report items which can be parsed into a table is limited by constants set at compile time. I’ve also tried to keep it simple so that it supports devices utilizing a single HID report - multiple-report devices are rare anyway and the multi-report support can be added by the user.
The demo now dumps out both the parser’s internal strings (for each report item processed), as well as the contents of the finalized report table. The latter gives out a bunch of entries on startup similar to the following:
Item 0:
Type: IN
BitOffset: 0
BitSize: 1
Usage Page: 7
Usage: 6
Usage Min: 224
Usage Max: 231
Unit Type: 0
Unit Exp: 0
Log Min: 0
Log Max: 1
Phy Min: 0
Phy Max: 0
I should be able to complete it next week. As far as I’m aware no one else has written a full parser for the AVR microcontrollers, so this is a great jump!
Apr 10
I’ve decided to take a short detour, and see if I can do what no one else has with the USB AVRs (to my knowledge) - write a HID report parser. At this point in time I’m not even certain it can be done in a reasonable amount of space and RAM, but I’m giving it a go nonetheless.
All the current MyUSB demos use hard-coded report offsets, which causes things to break if the device uses a report which doesn’t follow the standard examples in the USB.org spec. Writing a parser for the report data will mean perfect operation across all devices, but it does take a lot of engineering. The USB.org engineered the specification for large hosts such as PCs, not tiny 8-bit microcontrollers. I’m trying to avoid dynamic memory allocation, but it just might be required for the finished API.
Speaking of non-standard devices, I’ve made another fix to the library. There is now a 100ms delay after the addressing of a device when in host mode before passing back to the user code for further commands, as some devices seemed to need the pause. Now I’m able to see the X/Y movements of my wireless USB mouse using the library.
Apr 08
Good progress with my new book (currently entitled “USB and the USB AVR Series Microcontrollers”), which is coming along nicely. I’ve had to learn a few new things about formatting in Microsoft Word - specifically the auto-table of contents, and the sectionalized footers.
A big thanks to my proof-readers, Ross McKenzie, Nard Awater and Darren McInnes. They’ve already provided plenty of useful feedback which is helping shape the text. If you want to have your own say on what you’d like to be in the book, send me and email or leave a comment.
Also please check out the great work by Julian Beard on his Wikimedia Gallery page - Julian has provided several Public Domain images for the book. Great work, they really are first-class images.
Not much to add on MyUSB development; I’ve added a fully-interrupt driven (including control requests) mouse demo to the project, as several people have been looking for one. No release scheduled in the immediate future, as I still need to find more improvements to make to justify a whole release.
EDIT: I’ve posted the current book outline to the thread on AVRFreaks, so that others can comment on it.
Apr 01
First off, a small deviation: My USB book is progressing well, but don’t forget to email me suggestions on what you’d want to see in it!
I’ve just released MyUSB 1.3.2. This is another minor bugfix and enhancement release, and fixed a number of bugs users have reported. It also adds support for the new ATMEGA32U4 AVR microcontroller, and the new Raven RZUSBSTICK USB dongle board.
The changelog is as follows:
- Added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes are reflected in the hardware
- Fixed CDC and USBtoSerial demos - Stream commands do not work for control endpoints, and the GetLineCoding request had an incorrect RequestType mask preventing it from being processed
- Improved reliability of the USBtoSerial demo, adding a busy wait while the buffer is full
- Device control endpoint size is now determined from the device’s descriptors rather than being fixed
- Seperated out SPI code into new SPI driver in AT90USBXXX driver directory
- Bootloader now returns correct PID for the selected USB AVR model, not just the AT90USB128X PID
- Added support for the RZUSBSTICK board
- Bicolour driver removed in favour of generic LEDs driver
- Added support for the ATMEGA32U4 AVR
- Added MANUAL_PLL_CONTROL compile time option to prevent the USB library from manipulating the PLL
This release does contain one or two small migration issues; see the new version’s migration page on my site Wiki.
Recent Comments