Skip to content

Commit bb37ad8

Browse files
committed
Update a500kybhid.ino to enhance documentation on keyboard protocol and usage
1 parent c7afc68 commit bb37ad8

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

a500kybhid.ino

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,57 @@
44
* Copyright (c) 2024 by Luka "Void" MIT License
55
* GitHub: https://github.com/arvvoid/
66
* Contact: [email protected]
7-
* Repository: https://github.com/arvvoid/Amiga500-USB-Keyboard-Leonardo
7+
* Repository: https://github.com/arvvoid/a500kybhid
88
* Original code and inspiration by olaf, Steve_Reaver (taken from https://forum.arduino.cc/index.php?topic=139358.15)
99
*
1010
* This sketch converts an original Amiga 500 keyboard to a standard USB HID
1111
* keyboard using an Arduino Leonardo. It includes support for joystick inputs
1212
* and special function keys.
13-
*
14-
* Readme: https://github.com/arvvoid/Amiga500-USB-Keyboard-Leonardo/blob/main/README.md
13+
* This probably work on other board based on ATmega32U4 microcontroller.
14+
* This probably work on other Amiga keyboards with the same protocol.
15+
*
16+
* Keyboard protocol:
17+
* The keyboard transmits 8-bit data words serially to the main unit. Before
18+
* the transmission starts, both KCLK and KDAT are high. The keyboard starts
19+
* the transmission by putting out the first data bit (on KDAT), followed by
20+
* a pulse on KCLK (low then high); then it puts out the second data bit and
21+
* pulses KCLK until all eight data bits have been sent. After the end of
22+
* the last KCLK pulse, the keyboard pulls KDAT high again.
23+
*
24+
* When the computer has received the eighth bit, it must pulse KDAT low for
25+
* at least 1 (one) microsecond, as a handshake signal to the keyboard. The
26+
* handshake detection on the keyboard end will typically use a hardware
27+
* latch. The keyboard must be able to detect pulses greater than or equal
28+
* to 1 microsecond. Software MUST pulse the line low for 85 microseconds to
29+
* ensure compatibility with all keyboard models.
30+
*
31+
* All codes transmitted to the computer are rotated one bit before
32+
* transmission. The transmitted order is therefore 6-5-4-3-2-1-0-7. The
33+
* reason for this is to transmit the up/down flag last, in order to cause
34+
* a key-up code to be transmitted in case the keyboard is forced to restore
35+
* lost sync (explained in more detail below).
36+
*
37+
* The KDAT line is active low; that is, a high level (+5V) is interpreted as
38+
* 0, and a low level (0V) is interpreted as 1.
39+
*
40+
* _____ ___ ___ ___ ___ ___ ___ ___ _________
41+
* KCLK \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
42+
* ___________________________________________________________
43+
* KDAT \_____X_____X_____X_____X_____X_____X_____X_____/
44+
* (6) (5) (4) (3) (2) (1) (0) (7)
45+
*
46+
* First Last
47+
* sent sent
48+
*
49+
* The keyboard processor sets the KDAT line about 20 microseconds before it
50+
* pulls KCLK low. KCLK stays low for about 20 microseconds, then goes high
51+
* again. The processor waits another 20 microseconds before changing KDAT.
52+
*
53+
* Therefore, the bit rate during transmission is about 60 microseconds per
54+
* bit, or 17 kbits/sec.
55+
*
56+
* Readme for wiring instructors and other details:
57+
* https://github.com/arvvoid/a500kybhid/blob/main/README.md
1558
*/
1659

1760
#include <Keyboard.h>

0 commit comments

Comments
 (0)