USB – even more
I have written about USB many times – here, here and here, for example – and get a good response. Downloads of technical papers and web seminar attendances seem to break all records. It is clearly a topic of interest to many embedded developers. This is hardly surprising, as it is rare for any electronic device nowadays not to sport a USB interface. If you want a wired connection that just works, USB is an easy choice.
This ease of use comes at a price. The internal functions of USB are quite complex. This does not matter at all to the average user, but to the software developer of a USB-enabled device, it matters a lot. Even if a commercial USB stack is employed [which, naturally, I advocate and urge you to ensure that it is fully certified for standards compliance], having an understanding of the internals is useful to obtain the maximum performance and functionality. Today I want to talk about Endpoints, Pipes and Interfaces …
A USB connection between two devices [or between a computer and a peripheral – in the USB jargon, between a host and a function] is usually just 4 wires [prior to USB 3, which has 9 wires]. This is not important unless you are making cables and connectors, as, from a usage/software perspective, this connection carries a number of logical channels of communication or Pipes. A USB interface is configured to include a number [up to 32 – 16 IN and 16 OUT] Endpoints. These are the logical termination points of a pipe. As I mentioned on a previous occasion, USB communications may be performed using one of four modes: control, bulk, interrupt or isochronous. The endpoints are each characterized to support a single one of these modes.
An endpoint is normally part of the electronics hardware, with a set of registers set up by the USB stack. It is configured when the USB software is initialized. A pipe is a purely logical entity, which does not exist until a connection between two endpoints is established.
A USB enabled device can support a number of configurations. For each configuration, a number endpoints may be grouped into an Interface, which is associated with a specific function or purpose of a device and will use some or all of the endpoints. All the interfaces associated with a configuration can be set at the same time, so it is not possible to use the same endpoints for different interfaces. The first endpoint [Endpoint 0, which is actually a pair – IN and OUT] is exceptional, as it does not belong to an interface, but is used specifically for device configuration. A simple device will tend to have a single interface. A very simple device may only have a single endpoint [Endpoint 0, of course]. USB hubs also have a single endpoint.
I acknowledge the assistance I gratefully received from my colleague Stephen Olsen, who helped me get all of my terminology and concepts reasonably straight.
Posted November 1st, 2010, by Colin Walls
- Why develop embedded software bottom up?
- The Greek tragedy – what is it all about?
- Time for a new programming paradigm?
- Working on the weekend
- Authors wanted. Can you write about embedded software?
- Desert Island Discs
- ESC Silicon Valley: The RTOS Smackdown Revival
- How to run a hotel
- malloc() – just say no
- What size drink would you like?