A small firmware was developed to communicate with the user application and to adjust the offset. It uses the "Lightweight USB Framework for AVRs" (LUFA)  to interface the built-in USB 2.0 controller. The device registers itself as CDC (ACM) device. This enables the opposing application to treat the amplifier as a serial device. Platform independent serial communication libraries for Java are available and still supported. Most operating systems further provide CDC ACM drivers and hence make installation of the signal generator easy. Communicating directly through USB endpoints would have required a platform independent USB library. Such solutions exist, but as native libraries and therefore require a Java wrapper. It would also make programming more complicated and the hardware more expensive since it would require every device to have a USB controller. The structure of the firmware and its modules is depicted in figure 1 below. As mentioned before, the LUFA library handles the communication with the PC. Via the hardware serial peripheral interface (SPI) of the microcontroller, the DAC is controlled. It is used to generate the unshifted DC offset between 0V and 5V. The SPI transmission logic is located in the SPI module. In the Main module, the actual program logic is housed, and is described in the next section.
CRC holds the checksum implementation on the firmware side, and Protocol contains the header and payload definitions for the OpenLab protocol. The Util module contains just helper functions or preprocessor macros. By turning off all not required features in LUFA, and by compiling for space(-Os), the firmware requires about 4700 bytes.
The task of the firmware is simple. It listens for offset-packets on the connection and controls the DAC according to the values therein. Since the communication is stateless and connectionless, there is not much further logic involved. Figure 2 below, shows the program flow of the firmware as it is implemented in the Main module.
It can be seen that the firmware is passive and only communicates if requested, making the amplifier device the slave. Unknown data is ignored, while invalid packets are negative acknowledged. In the following section more information about the communication protocol can be found.
The content of his chapter is taken from the master thesis "Development of a Sound Card Based Arbitrary Waveform Generator" by Jakob Kriegbaum, MSc, May 2017.
Four Walled Cubicle: LUFA(2013) [Online] fourwalledcubicle.com/LUFA.php