October 30, 2023

Let's learn USB! -- a manifesto

I want to learn the low level details of USB programming. This is the kind of thing few people stick their noses into. I want to start with a datasheet and write code that will implement a working USB device.

Here are some basic ideas up front:

I am purposely excluding many interesting topics to keep this relatively simple. There is still plenty to tackle. Consider these subdivisions of labor: Like network programming, USB programming is done within the context of well defined standards and protocols. This will lead to a portable USB stack. Working with two different devices will help guide the project towards a clean division between the portable stack and hardware specific code.

This will end up being a USB support library for a microcontroller. That library will need to present itself as some kind of API to code that will use the library. This API will depend somewhat on just what sort of device is being implemented.

The first device I intend to aim for is a serial over USB device that could act as a console. On unix, the device would appear as /dev/ttyUSB0 or /dev/ttyACM0 or such and a terminal emulator like "picocom" should be able to talk to it. On the controller side, we would expect to have calls like:

usb_serial_open ()
usb_serial_putc ()
usb_serial_getc ()

Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org