forked from cub-uanic/tmk_keyboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
765 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Target file name (without extension). | ||
TARGET = sun_usb | ||
|
||
# Directory common source filess exist | ||
TOP_DIR = ../.. | ||
|
||
# Directory keyboard dependent files exist | ||
TARGET_DIR = . | ||
|
||
# keyboard dependent files | ||
SRC = keymap.c \ | ||
matrix.c \ | ||
led.c \ | ||
protocol/serial_soft.c | ||
|
||
CONFIG_H = config.h | ||
|
||
|
||
# MCU name, you MUST set this to match the board you are using | ||
# type "make clean" after changing this, so all files will be rebuilt | ||
#MCU = at90usb162 # Teensy 1.0 | ||
MCU = atmega32u4 # Teensy 2.0 | ||
#MCU = at90usb646 # Teensy++ 1.0 | ||
#MCU = at90usb1286 # Teensy++ 2.0 | ||
|
||
|
||
# Processor frequency. | ||
# Normally the first thing your program should do is set the clock prescaler, | ||
# so your program will run at the correct speed. You should also set this | ||
# variable to same clock speed. The _delay_ms() macro uses this, and many | ||
# examples use this variable to calculate timings. Do not add a "UL" here. | ||
F_CPU = 16000000 | ||
|
||
|
||
# | ||
# LUFA specific | ||
# | ||
# Target architecture (see library "Board Types" documentation). | ||
ARCH = AVR8 | ||
|
||
# Input clock frequency. | ||
# This will define a symbol, F_USB, in all source code files equal to the | ||
# input clock frequency (before any prescaling is performed) in Hz. This value may | ||
# differ from F_CPU if prescaling is used on the latter, and is required as the | ||
# raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
# at the end, this will be done automatically to create a 32-bit value in your | ||
# source code. | ||
# | ||
# If no clock division is performed on the input clock inside the AVR (via the | ||
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
F_USB = $(F_CPU) | ||
|
||
# Interrupt driven control endpoint task | ||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
|
||
|
||
# Build Options | ||
# *Comment out* to disable the options. | ||
# | ||
MOUSEKEY_ENABLE = yes # Mouse keys | ||
EXTRAKEY_ENABLE = yes # Audio control and System control | ||
CONSOLE_ENABLE = yes # Console for debug | ||
#NKRO_ENABLE = yes # USB Nkey Rollover | ||
|
||
|
||
# Boot Section Size in bytes | ||
# Teensy halfKay 512 | ||
# Atmel DFU loader 4096 | ||
# LUFA bootloader 4096 | ||
OPT_DEFS += -DBOOT_SIZE=4096 | ||
|
||
|
||
# Search Path | ||
VPATH += $(TARGET_DIR) | ||
VPATH += $(TOP_DIR) | ||
|
||
|
||
include $(TOP_DIR)/protocol/lufa.mk | ||
include $(TOP_DIR)/protocol.mk | ||
include $(TOP_DIR)/common.mk | ||
include $(TOP_DIR)/rules.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Sun to USB keyboard protocol converter | ||
====================================== | ||
Target MCU is ATMega32u4 but other USB capable AVR will also work. | ||
Supported keyboards: Sun Type 5 Keyboard, CTCSP SHORT TYPE KEYBOARD(CKUB) | ||
|
||
CTCSP SHORT TYPE KEYBOARD: http://imgur.com/a/QIv6p | ||
|
||
|
||
|
||
|
||
Connector | ||
--------- | ||
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 RX/TX(Mouse) | ||
5 RX PD3 | ||
6 TX PD2 | ||
7 GND GND | ||
8 5V VCC | ||
|
||
|
||
Protocol | ||
-------- | ||
Singnal: Asynchronous, Negative logic, 1200baud, No Flow control | ||
Frame format: 1-Start bit, 8-Data bits, No-Parity, 1-Stop bit | ||
|
||
AVR USART engine expects positive logic while Sun keyboard signal is negative. | ||
To use AVR UART engine you need exteral inverter in front of RX and TX pin. | ||
Otherwise you can software serial routine to communicate the keyboard. | ||
|
||
This converter uses software method, you doesn't need any inverter part. | ||
|
||
|
||
Commands From System To Keyboard | ||
0x01 Reset | ||
Keyboard responds with following byte sequence: | ||
Success: 0xFF 0x04 0x7F | ||
Fail: 0x7E 0x01 0x7F | ||
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 | ||
Keyboard responds with 'Layout Response' 0xFE 0xXX | ||
|
||
Commands From Keyboard To System | ||
0x7F Idle | ||
means no keys pressed. | ||
0xFE Layout Response | ||
0xFF Reset Response(followed by 0x04) | ||
|
||
Reference | ||
http://kentie.net/article/sunkbd/page2.htm | ||
http://kentie.net/article/sunkbd/KBD.pdf | ||
|
||
|
||
Build Firmware | ||
-------------- | ||
Just use 'make' | ||
$ cd sun_usb | ||
$ make | ||
Then, load the binary to MCU with your favorite programmer. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
Copyright 2012 Jun Wako <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#define VENDOR_ID 0xFEED | ||
#define PRODUCT_ID 0x3333 | ||
#define DEVICE_VER 0x0100 | ||
#define MANUFACTURER t.m.k. | ||
#define PRODUCT Sun keyboard converter | ||
#define DESCRIPTION converts Sun keyboard protocol into USB | ||
|
||
|
||
/* matrix size */ | ||
#define MATRIX_ROWS 16 | ||
#define MATRIX_COLS 8 | ||
|
||
|
||
/* key combination for command */ | ||
#define IS_COMMAND() ( \ | ||
keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ | ||
keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \ | ||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ | ||
) | ||
|
||
|
||
/* Serial(USART) configuration | ||
* asynchronous, negative logic, 1200baud, no flow control | ||
* 1-start bit, 8-data bit, non parity, 1-stop bit | ||
*/ | ||
#define SERIAL_NEGATIVE_LOGIC | ||
#define SERIAL_BAUD 1200 | ||
#define SERIAL_RXD_DDR DDRD | ||
#define SERIAL_RXD_PORT PORTD | ||
#define SERIAL_RXD_PIN PIND | ||
#define SERIAL_RXD_BIT 2 | ||
#define SERIAL_RXD_VECT INT2_vect | ||
#define SERIAL_RXD_INIT() do { \ | ||
/* pin configuration: input with pull-up */ \ | ||
SERIAL_RXD_DDR &= ~(1<<SERIAL_RXD_BIT); \ | ||
SERIAL_RXD_PORT |= (1<<SERIAL_RXD_BIT); \ | ||
/* enable interrupt: INT2(rising edge) */ \ | ||
EICRA |= ((1<<ISC21)|(1<<ISC20)); \ | ||
EIMSK |= (1<<INT2); \ | ||
} while (0) | ||
#define SERIAL_RXD_INT_ENTER() | ||
#define SERIAL_RXD_INT_EXIT() do { \ | ||
/* clear interrupt flag */ \ | ||
EIFR = (1<<INTF2); \ | ||
} while (0) | ||
|
||
#endif |
Oops, something went wrong.