2021-03-10 - USB klávesnice a USB obecněji + NKRO
Re: Questions about NKRO and USB « Reply #4 on: Sat, 30 August 2014, 04:18:21 » What makes NKRO over USB annoying is that a keyboard report has to be able to carry the state of the whole keyboard. PS/2 only transfers key up/down events and pushes remembering the state to the computer. A full blown USB host stack is fairly complicated to implement, esp. if you try to squeeze it into a BIOS. To mitigate this the USB-IF specified the "boot protocol" for keyboards and mice, allowing BIOS's to read these devices w/ minimal programming. The boot-protocol report of a keyboard has a pre-defined layout, one byte that carries the modifiers as a bitmap, one reserved byte, and six bytes that can carry a key code each, hence 6KRO (+ eight mods.) Unfortunately most keyboard manufacturers kept this format for the regular mode in order to keep their firmware/hardware as simple as possible.
About speeds -- even today most keyboards are USB 1.1 low-speed (1.5Mb/s), only a few made the transition to USB 1.1/2.0 full-speed (12Mb/s) so far. I'm not aware of any board that implements USB 2.0 hi-speed (480Mb/s, a bit overkill for a keyboard anyways ;) ) While it is true that the data payload sizes for a single transfer are 8, 64, and 1024 bytes (low-, full-, and hi-speed) you still can send larger reports via multiple transfers.
As for polling speed -- this is the time interval the USB host is querying a device for data. USB in general is host driven, no device can send any data unless instructed by the host. Devices request a poll interval for each endpoint in their USB descriptors, this can be overridden by the host. For low- and full-speed devices this can be 1-255ms. Windows limits this number to a minimum of 8ms for low-speed devices (!) even if the device requests 1ms. In order for true 1kHz USB polling to work the device has to be full-speed.
Some reference material:
- http://www.beyondlogic.org/usbnutshell/usb1.shtml USB in a Nutshell
- http://www.usb.org/developers/docs/usb20_docs/usb_20_081114.zip USB 2.0 Specification ( možná https://www.usb.org/sites/default/files/usb_20_20190524.zip ? files/usb_20_20190524.zip )
- http://www.usb.org/sites/default/files/documents/hid1_11.pdf Device Class Definition for HID 1.11 (App. B, C, F) files/hid1_11.pdf
- https://usb.org/sites/default/files/documents/hut1_12v2.pdf HID Usage Tables (pg. 53) files/hut1_12v2.pdf
See also: ./Arduino-ArduinoJakoKlavesnice-1.html