Skip to content

Sun Keyboard Protocol

hasu@tmk edited this page Sep 21, 2024 · 40 revisions

TMK SUN-USB Converter

Prebuilt converter is available here: https://geekhack.org/index.php?topic=72052.0

Source code

https://github.com/tmk/tmk_keyboard/tree/master/converter/sun_usb

Discussion

https://geekhack.org/index.php?topic=105671.0

Connector

Modern Type 4 and 5 keyboards uses 8Pin mini DIN.

   ___ ___
  /  |_|  \
 / 8  7  6 \
| 5    4  3 |
 \_ 2   1 _/
   \_____/
 (receptacle)

Wiring:
Pin mini DIN        MCU
----------------------------------
1   GND             GND
2   GND             GND
3   5V
4   Mouse RX/TX     PD4
5   Keyboard RX     PD2
6   Keyboard TX     PD3
7   GND             GND
8   5V              VCC

Protocol

Signal: Asynchronous, Negative logic, 1200baud, No Flow control

Frame format:

1-Start bit, 8-Data bits, No-Parity, 1-Stop bit

0      ___ ___ ___ ___ ___ ___ ___ ___ ___      
1 ____/   \___X___X___X___X___X___X___X___\_______
        S   0   1   2   3   4   5   6   7   S

AVR USART engine expects positive logic while Sun keyboard signal is negative. To use AVR UART engine you need external inverter in front of RX and TX pin. Otherwise you can use software serial to communicate the keyboard.

This firmware uses software serial by default, so you don't need any inverter. It can be still built with 'make HARDWARE_SERIAL=y' to enable hardware serial if you have inverter. You can use 74LS04 for example.

Commands From System To Keyboard

0x01 Reset
        Keyboard responds with following byte sequence:
        Success: 0xFF 0x04
        Fail:    0x7E 0x01
0x02 Bell On
0x03 Bell Off
0x0A Click On
0x0B Click Off
0x0E LED
        followed by LED status byte:
        bit: 3       2       1       0
        LED: CapsLk  ScrLk   Compose NumLk
0x0F Layout(DIP switch)
        Keyboard responds with 0xFE 0xXX
        bit: 7 6 5 4 3 2 1 0
        DIP: x 2 3 4 5 6 7 8(DIP-SW1 is always 0 on Type-5)
  • Type-5 keyboard at least starts sending key events without Reset command.
  • SHORT TYPE KEYBOARD has no DIP switch and replies fixed value 0x22 as layout.

Commands From Keyboard To System

0xFF sent after power up
0x7F Idle(no keys are pressed)
0xFE Layout(DIP switch) Response
0xFF 0x04 Reset Response(success)
0x7E 0x01 Reset Response(failure)

Mouse Protocol

Signal: Asynchronous, Negative logic, 1200baud, No Flow control

Frame format:

1-Start bit, 8-Data bits, No-Parity, 1-Stop bit

0      ___ ___ ___ ___ ___ ___ ___ ___ ___      
1 ____/   \___X___X___X___X___X___X___X___\_______
        S   0   1   2   3   4   5   6   7   S

Data Format:

Bit  |  7  6  5  4  3  2  1  0
-----+------------------------
Byte1|  1  0  0  0  0  L  M  R
Byte2| x7 x6 x5 x4 x3 x2 x1 x0
Byte3| y7 y6 y5 y4 y3 y2 y1 y0
Byte4| X7 X6 X5 X4 X3 X2 X1 X0
Byte5| Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0

X/Y indicates movement recorded after x/y movement occured. In the end you can get total mouse movement by adding like x+X/y+Y.

Sun mouse protcol is compatible with MouseSystems 5-byte mouse protocol.

http://www.bitsavers.org/pdf/mouseSystems/300771-001_Mouse_Systems_Optical_Mouse_Technical_Reference_Models_M2_and_M3_1985.pdf

Confirmed with ball mouse COMPACT 1 model made by Logitech(FCCID:DZLNSUN1).

3-byte format

Tadpole Sparcbook 3GX uses 3-byte format.

Bit  |  7  6  5  4  3  2  1  0
-----+------------------------
Byte1|  1  x  0  0  1  L  M  R
Byte2| x7 x6 x5 x4 x3 x2 x1 x0
Byte3| y7 y6 y5 y4 y3 y2 y1 y0

Resources

SPARC Keyboard Specification

http://kentie.net/article/sunkbd/KBD.pdf

Sun keyboard to USB Converter

http://kentie.net/article/sunkbd/page2.htm

Type 3

http://blog.daveastels.com.s3-website-us-west-2.amazonaws.com/2014/12/27/type-3-keyboard.html

CTCSP SHORT TYPE KEYBOARD(Type 5)

http://imgur.com/a/QIv6p

suniversal

https://codeberg.org/xelalexv/suniversal

mouse converter

http://www.rosenau-ka.de/ps2sun/

Clone this wiki locally