USB Design By Example
Design Examples
The many examples in the book are listed here for your convenience. They are listed by Chapter and Name.
There may have been corrections to this software since this CDROM was manufactured. Please check on my website for updated software.
If you find errors in any of the software please send me an email and I will post all corrections on my website.
Which example are you interested in?
- Introduction
- Chapter 4 Examples
- Chapter 6 Examples
- Chapter 8 USB Modem
- Chapter 9 Examples
- Chapter 10 Examples
Return to Main Menu
Overview of the Examples
There are two parts to most of the examples (Chapter 4 examples are PC Host only): PC Host - this is the Visual Basic program the runs on the PC, and, IO Device - this is the program that runs on the USB microcontroller. The source code for all of the examples is provided in the EXAMPLES/PCHOST or EXAMPLES/IODEVICE directory. The source code is in a format suitable for direct input into Visual Basic or into the uVision Integrated Development Environment. The source code is also viewable from this browser.
Return to Top
Overview of PC Host Software
The PC Host software is written is Visual Basic to hide some of the complexity of writing Windows Applications Programs. The source code for all of the examples is included on this CDROM. The Learning Edition of Visual Basic is adequate to support all of the example programs. Project files are included and these can be found in the EXAMPLES directory.
Before running the programs please copy the two files from the CDROM's Windows/System directory into your C:/Windows/System directory. These two files are
- apigid32.dll - a small library which helps Visual Basic interface to the C libraries of the Windows operating system. This is supplied, with permission, from Dan Appleman.
- dwshk32.ocx - a Visual Basic library that supports controls
There are two interface modules used by the example programs:
- HIDinterface.bas - which contains the definitions of all of the data structures required by our HID devices and an Open, Close, Read, Write interface to make working with HID devices simpler. A collection of useful support routines are also included here.
- OSinterface.bas - which contains the definitions for all of the Windows operating system calls that will be made.
Return to Top
Overview of IO Device Software
The IO Device software is written in MCS51 Assembler code - development tools are provided on this CDROM to enable you to edit and regenerate all of the examples.
All of the examples use an EZ-USB Development Board from Anchorchips - when special hardware was required for an example, this was built on an Anchorchips EZ-USB breadboard.
The examples co-exist with the dScope monitor that is initially downloaded into the program memory. The dScope monitor requires access to Serial Port 1 (and it's IO pins), it's interrupt vector and Timer 0 for baudrate control. The examples stay clear of these IO features and the dScope program space. The examples use Port A as an 8-bit OUTPUT port. An 8-bit INPUT port is created using the upper 4 bits of Port B and the lower 4 bits of Port C (dScope is happy with this assignment).
Chapter 6 describes six modules. Of these, three are common for all examples:
- Declare.A51 = common. Includes all of the constant and data declarations for all of the examples
- Dtables.A51 = unique. Defines the descriptor tables for each example
- Main.A51 = unique. Defines the initialization and Report processing for each example
- Timer.A51 = unique. Defines the specific IO for each example
- USB_Int.A51 = common. Accepts USB commands from the PC Host and responds to them
- Vectors.A51 = common. Defines the interrupt vector table and the first level interrupt servicing for all examples
Return to Top
Display USB Devices, Display HID Devices
The Chapter 4 examples contain all of the detail of working with USB devices.
Display USB Devices contains the low-level system calls to transfer packets between the PC Host and the IO Device. It contains two major modules, CollectData.frm which works through system tables to discover which USB devices are currently connected to the PC Host and DisplayUSB.frm which tabulates the IO Device Descriptor Data in an easy-to-comprehend format. It is an interesting application to study.
Display HID Devices is a high level interface that accesses the IO Devices using a "file-style" interface, ie Open, Close, Read and Write. Most of Display HID Devices is converted into the HIDinterface.bas module that the other examples will just call.
Return to Top
Buttons and Lights
There are two halves to the Buttons and Lights example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top
Reader Board
There are two halves to the Reader Board example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top
Reader Board with Dual Configurations
There are two halves to the Reader Board example, the PC Host side and the IO Device side. The modules that are unique to this example are:
- PC Host: RBStartUp.frm - same as first Reader Board example
- PC Host: ReaderBoard.frm - same as first Reader Board example
- IO Device: DTables.A51 - the descriptor tables
- IO Device: Main.A51 - the MAIN program, interprets Reports
- IO Device: Timer.A51 - the TIMER program, does real-world IO
- IO Device: USB_INT.A51 - the USB interrupt program, that handles the two configurations
Return to Top
I2C Development System
There are two halves to the I2C Development System example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top
Thermometer Applications
There are two halves to the Thermometer Applications example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top
Infrared Applications
Sorry. The Infrared Applications example was not available at the time this CDROM was manufactured. Please download it from my website
Motor Control
There are two halves to the Motor Control example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top
Lighting Control Panel
There are two halves to the Lighting Control Panel example, the PC Host side and the IO Device side. The modules that are unique to this example are:
Return to Top