From the Introduction
USB isn't just for mainstream PCs anymore. With hardware and firmware support, small embedded systems can use the same devices available to conventional desktop and notebook PCs.
Data loggers can store data on USB drives. Robotic arms can receive input from USB keyboards. Sales terminals can print receipts on USB printers. USB cameras, speakers, mics, network bridges, virtual serial ports, Bluetooth adapters, and more can be available to the embedded systems you create. This book will show you how.
If you are interested in designing, programming, or learning about small systems that access USB devices, this book is for you.
The first two chapters are an introduction to the USB interface and USB hosts in embedded systems.
Chapter 1, USB Essentials, is a whirlwind tour of what you need to know about USB hardware and protocols to develop a USB embedded host system.
Chapter 2, USB Hosts for Embedded Systems, explains how USB embedded hosts differ from USB hosts in conventional PCs. You’ll learn which USB host requirements are relaxed for embedded systems and what new requirements some USB embedded host systems must meet. A guide to USB embedded host hardware and software will help you select a development platform that matches your project’s needs.
Many USB embedded host systems use the Linux operating system because of its rich support for USB host communications. The next two chapters focus on tools and techniques for developing USB embedded host systems that use Linux.
Chapter 3, Using Linux in Embedded Systems, presents options for using Linux in small systems and introduces the BeagleBoard-xM open development platform. You’ll learn how to manage permissions on an embedded Linux system, how to run an application at startup, and how the applications you write can provide debugging data.
Chapter 4, Exploring USB in Linux, shows how to use Linux commands and utilities to learn about, monitor, and debug communications with attached USB devices.
The heart of the book focuses on communicating with USB devices. The chapters that follow discuss USB communications for a variety of USB peripheral types with example code for Linux USB host systems.
Chapter 5, Accessing Files on Drives, shows how to detect attached USB drives and how to read and write to files on USB drives.
Chapter 6, Getting User Input, introduces the USB human interface device class and shows how to read user input from USB keyboards.
Chapter 7, Bridging to Other Interfaces, shows how USB can function as a bridge to other interfaces such as serial ports, wired and wireless networks, and Bluetooth.
Chapter 8, Printing, introduces printer-control languages and shows how applications can print documents on USB printers.
Chapter 9, Using Sound and Video, shows how to use USB mics, speakers, and cameras to record and play audio and video streams.
Chapter 10, Accessing Vendor-defined Devices, shows how to communicate with devices that don’t fit standard USB classes, including devices that transfer vendor-defined data, HID-class devices that perform vendor-defined functions, and a display monitor that uses a USB interface and vendor-specific driver.
Chapter 11, Implementing a Dual-role Port, shows how a USB On-The-Go (OTG) port can function as both a host and device port. An example application configures an OTG system to function as a USB drive when attached to a USB host.
To get the most from this book, some experience with the USB interface is helpful. Whatever development platform you use, you’ll need to be familiar with how to compile, load, and run applications on your embedded system.
About the Example Code
Embedded-system developers have many choices for hardware and software platforms. For this book’s example code, I chose the BeagleBoard-xM open development board (beagleboard.org) with an Ubuntu Netbook distribution of Linux for ARM (elinux.org/BeagleBoardUbuntu). The example code is largely portable to other Linux systems, and the concepts behind the code apply to systems that use other development platforms.