Author Topic: TMK SUN-USB Converter  (Read 25604 times)

0 Members and 1 Guest are viewing this topic.

Offline hasu

  • Thread Starter
  • Posts: 3491
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
TMK SUN-USB Converter
« on: Sat, 11 April 2020, 05:28:48 »




Sun to USB keyboard protocol converter
======================================
This converter translates Sun keyboard protocol into USB HID to use vintage Sun keyboards on modern computer. The converter should work with Sun Type 2-5 Keyboards. Target MCU is ATmega32U2/4. Mouse support is available only to ATmega32U2 at this time.


Prebuilt TMK Sun converter is available here:

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

Refer to this page for Sun keyboard protocol details.

https://github.com/tmk/tmk_keyboard/wiki/Sun-Keyboard-Protocol

Check wiki for general information about TMK keyboard firmware.

https://github.com/tmk/tmk_keyboard/wiki

Source code is available here.

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


Update
------
2024-09-28 Add mouse support and rewrite code to use timer for software uart
2020-04-08 Added unimap support



Wiriing
-------
For Type 4 and 5 keyboards use 8Pin mini DIN.

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

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


Just wire connecotr pins to MCU pins respectively, no extra component is needed. Pull-up resistor on signal lines are optional.



Keymap Editor
-------------
You can download prebuilt firmware on TMK keymap editor.

https://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?sun_usb

For ATmega32U4 use this link, instead.

https://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?sun_usb_32u4



Build Firmware
--------------
For TMK converter with ATmega32U2 just run `make` to build firmware hex file. For ATmega32U4 use `make -f Makefile.atmega32u4` instead of `make`.

    $ cd sun_usb
    $ make

Then, load the hex file into MCU with your favorite programmer. If you have `dfu-programmer` installed you can use `make dfu`.

    $ make dfu



Keyboard Commands
-----------------
You can send Sun keyboard commands with TMK Magic key combo. Magic key is `LShift + RShift` on the converter.

For example, to send 'Reset' command press `LShift + RShift + Delete` key combo.

Following Sun specific commands are available.

    --- Sun keyboard commands ---
    Home:        Toggle Bell
    End:         Toggle Click
    PgUp:        LED All On
    PgDown:      LED All Off
    Insert:      Layout
    Delete:      Reset
« Last Edit: Sat, 16 November 2024, 21:39:08 by hasu »

Offline doomsday_device

  • Posts: 7
  • Location: Germany
Re: TMK SUN-USB Converter
« Reply #1 on: Thu, 19 May 2022, 13:05:34 »
recently acquired a tatung branded sun 5 (?) board, successfully restored and converted it with this firmware.
it has a big beeper and screams everytime i connect. so my guess would be it is working like the other sun keyboards and is potentionally able to output beeps/clicks with each keypress.

to use this feature i would need to use the tmk "magic" key combo, which in this case would be both shift, both alt or both meta keys + a single extra key. it seems the matrix isnt able to do that.

my question here is, is there any way to remap "magic" key combos, or even to map a key to a single hexcode?
beside wiring up converters and putting the *.hex from the online editor on to the chip my knowledge is very limited.

also off topic: if anyone has any infos on the board or the system it came with it would be much appreciated. couldnt find any infos or pictures at all. its a forward fdw-107a

pic of board attached for beauty bonus

disclaimer: this is a crosspost and is also to be found on DT forums.

Offline hasu

  • Thread Starter
  • Posts: 3491
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK SUN-USB Converter
« Reply #2 on: Thu, 19 May 2022, 18:05:22 »
'Keyboard control' command is configured in config.h, you cannot remap in Keymap Editor.
https://github.com/tmk/tmk_keyboard/tree/2173767a78e3353f40b2bc6bb3f29bc67c896470/converter/sun_usb#keyboard-control

You have to edit these lines and compile firmware to change the command.
https://github.com/tmk/tmk_keyboard/blob/2173767a78e3353f40b2bc6bb3f29bc67c896470/converter/sun_usb/config.h#L33-L37

Offline doomsday_device

  • Posts: 7
  • Location: Germany
Re: TMK SUN-USB Converter
« Reply #3 on: Fri, 20 May 2022, 17:16:17 »
'Keyboard control' command is configured in config.h, you cannot remap in Keymap Editor.
https://github.com/tmk/tmk_keyboard/tree/2173767a78e3353f40b2bc6bb3f29bc67c896470/converter/sun_usb#keyboard-control

You have to edit these lines and compile firmware to change the command.
https://github.com/tmk/tmk_keyboard/blob/2173767a78e3353f40b2bc6bb3f29bc67c896470/converter/sun_usb/config.h#L33-L37
thanks,
remapping combo to two different mods (shift/alt) helped and it works now.
Code: [Select]
#define IS_COMMAND() ( \
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LALT)) \
)
thanks to my friend kelvinhall05 for figuring out with me and the compile.
« Last Edit: Fri, 20 May 2022, 17:27:52 by doomsday_device »

Offline hasu

  • Thread Starter
  • Posts: 3491
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: TMK SUN-USB Converter
« Reply #4 on: Sat, 28 September 2024, 11:49:04 »