I am interested in plugging a simple standard cheap USB keyboard into a simple standard cheap AVR.
For old purple-connector PS2 keyboards, this was not hard. There were two lines: data and clock.
When a key was pressed, the PS2 keyboard sent a message that was one to three bytes. The framework
of each of these bytes was eleven bits, 1 start, 8 data, 1 parity, and 1 stop. When the clock line
went from 0 volts to +5 volts, the data line held a valid bit.
I am at a complete loss as to how to do this with a USB keyboard. I know that the keyboard is
a Human-Interface-Device with a diffential pair of data lines. Data transfers at 1.2 mega bits per second.
I assume that:
1) When the keyboard is plugged in, or, more likely, when the AVR is powered-on or reset, a
sequence of bytes is sent from the AVR to the keyboard requesting that it identify itself
according to some pre-defined USB standard.
2) Every 1/10th or 1/20th of a second (50-100 milliseconds), the AVR sends a sequence of bytes
(a packet) to the keyboard requesting if any key has been pressed or released since end of the
last period. The keyboard sends a packet back to the AVR saying that there has been no key
pressed, or a packet or set of bytes with a scancode for each key that was either pressed or released
since the end of the last period.
How can I learn to do this? I looked on the web and very quickly got waterboarded with tons of
poorly-written incomprehensible pseudo-documentation about classes, descriptor, links, endpoints,
isochronousities, protocols, configuation descriptors, interrupt pipes that are not interrupts,
reports, etc..
As far as I can tell, all the USB/AVR verbage on the web is concerned with making the AVR appear
to Windows/Linus PC as a USB device. But I simply want the USB keyboard to send scancodes to the
AVR, and then convert the keypress to ASCII for display or as triggers to signal the AVR to do specific
actions.
Since the USB keyboards are only $5-10 and the AVRs are the same cost, there are probably a lot of
people who want to learn how to connect the two together, but are overwhelmed by the USB documentation.
Any suggestions on clear tutorials or source code? Should I be looking into a specialized USB AVR or
can I read a keyboard with a standard Mega328?