How USB devices work

Briefly:

  • You plug a device into a USB port
  • The computer (“host”) notices there’s a new device there.
  • The computer probes the device to find out what its capabilities are
  • The device replies with a description of its capabilities.
  • The two continue to talk, with the host asking the keyboard for an update every so often. (every 8ms)

The canonical book on this process is https://www.amazon.com/USB-Complete-Developers-Guide-Guides/dp/1931448280

On the keyboard side, there’s a tiny program that runs as soon as the microcontroller gets USB power. It takes care of turning on power to the LED subsystem, polling the ATTiny88 keyscanners for key matrix events and talking USB to the host.

EEPROM is, I suppose, more durable than NVRAM. It’s “electronically erasable read only memory.” If NVRAM is a low-power LCD screen with a big battery, EEPROM is an eInk screen.

You can think of EEPROM as the keyboard’s very, very tiny (2.5k?) SSD. The firmware has helper functions for reading and writing from EEPROM.

Does that help get you started?

4 Likes