CURRENT ISSUE

Contests

bottom corner

Feature Article



Issue #213 April 2008

Programmable Power
Build a Simple USB DAC
by Yoshiyasu Takefuji

Start | USB Communications | Firmware | MAX517 (DAC) Programming | Firmware, Software, & LIBUSB | Host Device Driver Installation | Testing | Sources & PDF

FIRMWARE, SOFTWARE, & LIBUSB

The makefile is used to generate a da.hex file, which is written in the ATtiny45’s flash memory. The makefile is posted on the Circuit Cellar FTP site.

LibUsb-Win32 is an open-source USB protocol stack library for Windows. There are two important functions: usbOpenDevice and usb_control_msg in this application. usbOpenDevice opens the USB device to ensure the target VendorID (VID) and ProductID (PID) are there. VID and PID are my unique commercial IDs, but you may use them for your personal use. usb_control_msg is a user-friendly function in the libusb protocol stack package. usb_control_msg sends and receives the data between a host PC and the ATtiny45. Two important parameters (mode and i) in usb_control_msg on the host application are transferred to two parameters (data and data) via usbFunctionSetup on firmware. The parameter mapping between usb_control_msg on your host PC’s software and usbFunctionSetup on the ATtiny45’s firmware is illustrated in Figure 2.

To generate the application program called volt.exe, type “gcc volt.c –lusb –o volt” in a Cygwin window. You may view the code on the Circuit Cellar FTP site.

LibUsb is an open-source project for the Linux, FreeBSD, NetBSD, OpenBSD, Darwin, Mac, and Windows operating systems (Windows 98, Win Me, Windows 2000, and Windows XP). Simple data transfer in a libusb protocol stack package can be accomplished using a usb_control_msg function for small data transfer. The usb_bulk_write and usb_bulk_read functions can be used for transferring large data. Definitions of the three functions are posted on the Circuit Cellar FTP site.

Previous | Next

 


bottom corner