]>
Commit | Line | Data |
---|---|---|
1 | Sun to USB keyboard protocol converter | |
2 | ====================================== | |
3 | Target MCU is ATMega32u4 but other USB capable AVR will also work. | |
4 | ||
5 | This converter will work with Sun Type 2-5 Keyboards. | |
6 | ||
7 | ||
8 | Tested on: | |
9 | Sun Type 3 Keyboard: http://blog.daveastels.com.s3-website-us-west-2.amazonaws.com/2014/12/27/type-3-keyboard.html | |
10 | CTCSP SHORT TYPE KEYBOARD(Type 5): http://imgur.com/a/QIv6p | |
11 | ||
12 | ||
13 | Keymap of Type 3(keymap_sun3.c) were impoted from dastels's repository. | |
14 | https://github.com/dastels/tmk_keyboard/tree/master/converter/sun3_usb | |
15 | ||
16 | ||
17 | ||
18 | Connector | |
19 | --------- | |
20 | 8Pin mini DIN | |
21 | ___ ___ | |
22 | / |_| \ | |
23 | / 8 7 6 \ | |
24 | | 5 4 3 | | |
25 | \_ 2 1 _/ | |
26 | \_____/ | |
27 | (receptacle) | |
28 | ||
29 | Wiring: | |
30 | Pin mini DIN MCU | |
31 | ---------------------------------- | |
32 | 1 GND GND | |
33 | 2 GND GND | |
34 | 3 5V | |
35 | 4 RX/TX(Mouse) | |
36 | 5 RX PD3 | |
37 | 6 TX PD2 | |
38 | 7 GND GND | |
39 | 8 5V VCC | |
40 | ||
41 | ||
42 | Protocol | |
43 | -------- | |
44 | Signal: Asynchronous, Negative logic, 1200baud, No Flow control | |
45 | Frame format: 1-Start bit, 8-Data bits, No-Parity, 1-Stop bit | |
46 | ||
47 | AVR USART engine expects positive logic while Sun keyboard signal is negative. | |
48 | To use AVR UART engine you need external inverter in front of RX and TX pin. | |
49 | Otherwise you can software serial routine to communicate the keyboard. | |
50 | ||
51 | This converter uses software method by default, so you don't need any inverter part. But | |
52 | it can also be built with 'make HARDWARE_SERIAL=y' to enable hardware serial if there | |
53 | is an inverter present. Good results have been obtained using a 74LS04 and hardware serial. | |
54 | ||
55 | ||
56 | Commands From System To Keyboard | |
57 | 0x01 Reset | |
58 | Keyboard responds with following byte sequence: | |
59 | Success: 0xFF 0x04 0x7F | |
60 | Fail: 0x7E 0x01 0x7F | |
61 | 0x02 Bell On | |
62 | 0x03 Bell Off | |
63 | 0x0A Click On | |
64 | 0x0B Click Off | |
65 | 0x0E LED | |
66 | followed by LED status byte: | |
67 | bit: 3 2 1 0 | |
68 | LED: CapsLk ScrLk Compose NumLk | |
69 | 0x0F Layout | |
70 | Keyboard responds with 'Layout Response' 0xFE 0xXX | |
71 | ||
72 | Commands From Keyboard To System | |
73 | 0x7F Idle | |
74 | means no keys pressed. | |
75 | 0xFE Layout Response | |
76 | 0xFF Reset Response(followed by 0x04) | |
77 | ||
78 | Reference | |
79 | http://kentie.net/article/sunkbd/page2.htm | |
80 | http://kentie.net/article/sunkbd/KBD.pdf | |
81 | ||
82 | ||
83 | Build Firmware | |
84 | -------------- | |
85 | Just use 'make' | |
86 | $ cd sun_usb | |
87 | $ make | |
88 | Then, load the binary to MCU with your favorite programmer. | |
89 | ||
90 | ||
91 | Sun commands | |
92 | ------------ | |
93 | You can send Sun protocol commands with TMK `Magic` key combo. By default `Magic` key is `LShift` + `RShift`, `LAlt` + `RAlt' or `LMeta` + `RMeta`. | |
94 | https://github.com/tmk/tmk_keyboard#magic-commands | |
95 | ||
96 | Following Sun specific commands are available. For example, to send 'Bell On' you can press `LShift` + `RShift` + `Up` keys simultaneously. | |
97 | ||
98 | ``` | |
99 | ----- Sun converter Help ----- | |
100 | Up: Bell On | |
101 | Down: Bell Off | |
102 | Left: Click On | |
103 | Right: Click Off | |
104 | PgUp: LED all On | |
105 | PgDown: LED all On | |
106 | Insert: Layout | |
107 | Delete: Reset | |
108 | ``` |