The firmware for this project is developed in C, and compiled under GCC/winAVR. Included in the source download is a project file which can be imported into Eclipse. Specifically Eclipse Helios (v3.6) with the CDT plugin.
The USB stack is based on an Atmel AVR application note, with extensions to expose other standard microcontroller functions. Input and output HID reports are configured at 64 bytes (max for HID) by default. Each out report (to the microcontroller) includes a firmware section ID, an instruction code and the relevant data packet if required. These messages are created in the .NET PC software, more information in the Software section.
HID report protocol
When using the default structure,a fixed 8-byte packet header is used. This header specifies the firmware section (HD44780 LCD interface, SPI port, I2C, timers/PWM etc), the instruction (read/write, start/stop etc) and the relevant data packet.
The firmware supports the following functions without modification. Most options available in firmware for each of the hardware peripherals are catered for. All of these functions are also fully supported in the .NET PC software, with most functions simply requiring two lines of code to implement.
- 16bit timer setup - PWM, one shot, pulse counting
- UART setup and data transfer
- Software I2C port setup and data transfer
- SPI port setup and data transfer (master/slave operation)
- HD44780 LCD interface
- General digital IO - set direction and pullups, read/write pins
A simple switch statement is used to determine the section/instruction to execute, so adding user functions is as simple as writing said functions, and adding a case to the switch statement with a unique section/instruction.