This book is for developers who are involved with designing or programming devices that use the Universal Serial Bus (USB) interface. If you are a hardware designer, if you write firmware that resides inside USB devices, or if you write applications that communicate with devices, this book is for you.

USB is versatile enough to serve a multitude of device functions. Familiar USB peripherals include mice, keyboards, drives, printers, speakers, and cameras. USB is also suitable for data-acquisition units, control systems, and other devices with specialized functions, including one-of-a-kind designs. The right choices of device hardware, software drivers and development tools and techniques can ease the path to designing devices that perform their functions without error or user aggravation. This book will guide you along the way.

The USB specifications are the ultimate authority on the USB interface, but by design they omit advice, example code, and other information that applies to specific device hardware, software, and other tools and products. This book bridges the gap between the specifications and real-world designs and will save you time and trouble when developing devices and the software to access them.

What's New in the 4th Edition

The core of USB has remained much the same since the release of USB 1.0 in 1996. But the interface has expanded to support faster bus speeds, improved power management, more device classes, wireless communications, dual-role devices (device and host), and more. Plus, new and improved chips and development tools have eased the task of developing devices and software to access them.

This edition is revised and updated throughout. All new in the Fourth Edition is an introduction to USB 3.0 and the SuperSpeed bus. You'll also learn how to use Microsoft's WinUSB driver to access devices that perform vendor-specific functions. Topics with major updates include device-controller chips, technologies for wireless USB communications, protocols for conserving power, and USB device classes.

Example code is provided for applications in both Visual Basic and Visual C#. For device firmware, using both Microengineering Labs' PICBASIC PRO and Microchip Technology's MPLAB C compiler is discussed.

Overview of Topics Covered

These are some of questions that the book answers:

How do USB devices communicate? This book doesn't attempt to restate everything in the specifications. Instead, the focus is on what you'll need to know to enable your devices to communicate efficiently and reliably.

How can I decide if my device should use a USB interface? Find out whether your device should use USB or another interface. If the choice is USB, you'll learn how to decide which of USB's four speeds -- including USB 3.0's SuperSpeed -- and which of USB's four transfer types are appropriate for your application.

What controller chip should my device use? Every USB device contains an intelligent controller to manage USB communications. Dozens of silicon providers offer controller chips with different architectures and abilities. This book will help you select a controller based on your project's needs, your budget, and your preferences for chip architecture, programming languages, and tools.

How can applications communicate with my devices? On a PC, an application accesses a USB device by communicating with a driver that the operating system has assigned to the device. You'll learn if your device can use a class driver provided by the host's operating system. For devices that don't fit a supported class, you can explore options such as Microsoft's WinUSB driver, other generic drivers, and custom drivers. Example code shows how to detect and communicate with devices from Visual Basic and Visual C# applications.

What firmware does my device need to support USB communications? Find out how to write firmware that enables your device to respond to USB requests and events and exchange data for any purpose.

Does my device need its own power supply? The USB interface can provide power to devices, including charging current for battery-powered devices. Learn how to determine if a design can obtain all of its power from the bus, how to meet USB's requirements for conserving power, and how to charge battery-powered devices from the bus.

How can I implement wireless communications? The Wireless USB specification defines a way for USB devices to communicate without wires. Other industry standards and vendor technologies offer additional options. Learn which technology is right for your device.

How can my device access other USB devices? Find out how to develop a host for an embedded system or a USB On-The-Go device that can function as both a USB device and a limited-capability host that accesses other USB devices.

How can I ensure reliable communications? All devices must respond to requests and other events on the USB port. The host computer must detect attached devices, locate appropriate drivers, and exchange data with the devices. This book provides tips, example code, and information about debugging software and hardware to help with these tasks.

To understand the material in the book, it's helpful to have some experience with digital logic, application programming for PCs and writing embedded code for peripherals. However, you don't have to know anything about USB.