aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-06-22 02:52:14 +0900
committertmk <nobody@nowhere>2013-06-22 02:52:14 +0900
commit2593ae132812414f02e7cf483bb141cd2c78595c (patch)
treeb2b158516bbdc71b2e63117be3d65f25776983ae
parentbebbe15562b45aeb911952b0765cd9c732d34306 (diff)
parentff47a5613875a9cc719ef7f026d99bb637e662f0 (diff)
downloadqmk_firmware-2593ae132812414f02e7cf483bb141cd2c78595c.tar.gz
qmk_firmware-2593ae132812414f02e7cf483bb141cd2c78595c.zip
Merge branch 'x68k_led'
-rw-r--r--converter/x68k_usb/Makefile19
-rw-r--r--converter/x68k_usb/README22
-rw-r--r--converter/x68k_usb/config_pjrc.h29
-rw-r--r--converter/x68k_usb/keymap.c20
-rw-r--r--converter/x68k_usb/led.c21
-rw-r--r--converter/x68k_usb/matrix.c13
-rw-r--r--protocol/x68k.c75
-rw-r--r--protocol/x68k.h47
8 files changed, 93 insertions, 153 deletions
diff --git a/converter/x68k_usb/Makefile b/converter/x68k_usb/Makefile
index 62b976c56..948622c7c 100644
--- a/converter/x68k_usb/Makefile
+++ b/converter/x68k_usb/Makefile
@@ -16,7 +16,7 @@ TARGET_DIR = .
16SRC = keymap.c \ 16SRC = keymap.c \
17 matrix.c \ 17 matrix.c \
18 led.c \ 18 led.c \
19 x68k.c 19 protocol/serial_uart.c
20 20
21CONFIG_H = config_pjrc.h 21CONFIG_H = config_pjrc.h
22 22
@@ -37,12 +37,23 @@ MCU = atmega32u4 # Teensy 2.0
37F_CPU = 16000000 37F_CPU = 16000000
38 38
39 39
40# Boot Section Size in bytes
41# Teensy halfKay 512
42# Atmel DFU loader 4096
43# LUFA bootloader 4096
44OPT_DEFS += -DBOOTLOADER_SIZE=4096
45
46
40# Build Options 47# Build Options
41# *Comment out* to disable the options. 48# *Comment out* to disable the options.
42# 49#
43MOUSEKEY_ENABLE = yes # Mouse keys 50BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
44EXTRAKEY_ENABLE = yes # Audio control and System control 51MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
45NKRO_ENABLE = yes # USB Nkey Rollover 52EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
53CONSOLE_ENABLE = yes # Console for debug(+400)
54COMMAND_ENABLE = yes # Commands for debug and configuration
55#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
56#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
46 57
47 58
48 59
diff --git a/converter/x68k_usb/README b/converter/x68k_usb/README
index 0b61b2c4b..5f1c2072c 100644
--- a/converter/x68k_usb/README
+++ b/converter/x68k_usb/README
@@ -5,6 +5,7 @@ http://en.wikipedia.org/wiki/Sharp_X68000
5 5
6X68000 keyboard has ALPS linear switches. 6X68000 keyboard has ALPS linear switches.
7- DSETK0016CE01 green linear 7- DSETK0016CE01 green linear
8- DSETK0022CE02 yellow linear
8- DSETK0023CE03 yellow linear 9- DSETK0023CE03 yellow linear
9 10
10 11
@@ -127,3 +128,24 @@ Scan Codes
127`-----------------------------------------------------------| .---=====---. |-----------| 4E| 128`-----------------------------------------------------------| .---=====---. |-----------| 4E|
128 | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| | 129 | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| |
129 `---------------------------------------------' `-----------' `---------------' 130 `---------------------------------------------' `-----------' `---------------'
131
132
133
134LED Special Functions
135---------------------
136http://homepage2.nifty.com/m_kamada/docs/unlistedx68k.htm#keyboard
137
1381. Random Illumination
139 Plug in with pressing F1, F2 and F3.
140
1412. Sequential Illumination
142 Plug in with pressing 記号入力(52), 登録(53) and HELP.
143
1443. Scan code Display
145 Plug in with pressing かな(5A), ローマ字(5B) and コード入力(5C).
146 You can see its scan code on LEDs by pressing a key.
147 +---------------------------------------------------+
148 |bit|6 |5 |4 |3 |2 |1 |0 |
149 |---+----+--------+---+----+----------+--------+----|
150 |LED|全角|ひらがな|INS|CAPS|コード入力|ローマ字|かな|
151 +---------------------------------------------------+
diff --git a/converter/x68k_usb/config_pjrc.h b/converter/x68k_usb/config_pjrc.h
index 2df83a2cb..c49b4a73e 100644
--- a/converter/x68k_usb/config_pjrc.h
+++ b/converter/x68k_usb/config_pjrc.h
@@ -34,30 +34,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34/* key combination for command */ 34/* key combination for command */
35#define IS_COMMAND() ( \ 35#define IS_COMMAND() ( \
36 keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ 36 keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
37 keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ 37 keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
38 keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) \
38) 39)
39 40
40/* legacy keymap support */ 41/* legacy keymap support */
41#define USE_LEGACY_KEYMAP 42#define USE_LEGACY_KEYMAP
42 43
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48 44
49/* USART configuration 45/* USART configuration
50 * asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control 46 * asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control
51 */ 47 */
52#ifdef __AVR_ATmega32U4__ 48#ifdef __AVR_ATmega32U4__
53# define KBD_RX_VECT USART1_RX_vect 49 #define SERIAL_UART_BAUD 2400
54# define KBD_RX_DATA UDR1 50 #define SERIAL_UART_DATA UDR1
55# define KBD_RX_BAUD 2400 51 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
56# define KBD_RX_UBBR ((F_CPU/(16UL*KBD_RX_BAUD))-1) 52 #define SERIAL_UART_RXD_VECT USART1_RX_vect
57# define KBD_RX_INIT() do { \ 53 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
58 UBRR1L = (uint8_t) KBD_RX_UBBR; \ 54 #define SERIAL_UART_INIT() do { \
59 UBRR1H = (uint8_t) (KBD_RX_UBBR>>8); \ 55 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
60 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \ 56 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
57 UCSR1B = (1<<RXCIE1) | (1<<RXEN1) | /* RX: interrupt, RX: enable */ \
58 (1<<TXEN1); /* TX: enable */ \
59 UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
60 (0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
61 sei(); \
61 } while(0) 62 } while(0)
62#else 63#else
63# error "USART configuration is needed." 64# error "USART configuration is needed."
diff --git a/converter/x68k_usb/keymap.c b/converter/x68k_usb/keymap.c
index 90abb3966..5e09f55d2 100644
--- a/converter/x68k_usb/keymap.c
+++ b/converter/x68k_usb/keymap.c
@@ -113,13 +113,23 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
113 | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| | 113 | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| |
114 `---------------------------------------------' `-----------' `---------------' 114 `---------------------------------------------' `-----------' `---------------'
115*/ 115*/
116 /* ANSI */
116 KEYMAP( 117 KEYMAP(
117 NO, NO, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,NO, NO, NO, 118 F16, F17, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,F11, F12, F13,
118 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, 119 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC, HOME,INS, DEL, NLCK,PSLS,PAST,PMNS,
119 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, DEL, END, PGDN, P7, P8, P9, PPLS, 120 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, PGDN,PGUP,END, P7, P8, P9, PPLS,
120 LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, UP, P4, P5, P6, PEQL, 121 LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,F18, UP, P4, P5, P6, PEQL,
121 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,GRV, LEFT,DOWN,RGHT, P1, P2, P3, PENT, 122 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,GRV, LEFT,DOWN,RGHT, P1, P2, P3, PENT,
122 LGUI,LALT,NO, SPC, RALT,RGUI,RCTL,APP, NO, NO, P0, PCMM,PDOT 123 F19, LGUI,LALT, SPC, RALT,RGUI,RCTL,APP, F14, F15, P0, PCMM,PDOT
124 ),
125 /* JIS */
126 KEYMAP(
127 F16, F17, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,F11, F12, F13,
128 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, HOME,INS, DEL, NLCK,PSLS,PAST,PMNS,
129 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, PGDN,PGUP,END, P7, P8, P9, PPLS,
130 LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, UP, P4, P5, P6, PEQL,
131 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, LEFT,DOWN,RGHT, P1, P2, P3, PENT,
132 LGUI,LALT,MHEN, SPC, HENK,KANA,APP, ZKHK, F14, F15, P0, PCMM,PDOT
123 ), 133 ),
124}; 134};
125 135
diff --git a/converter/x68k_usb/led.c b/converter/x68k_usb/led.c
index 40156cf4a..ccc38699c 100644
--- a/converter/x68k_usb/led.c
+++ b/converter/x68k_usb/led.c
@@ -16,11 +16,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include "stdint.h" 18#include "stdint.h"
19#include "x68k.h" 19#include "serial.h"
20#include "led.h" 20#include "led.h"
21#include "debug.h"
21 22
22 23
23void led_set(uint8_t usb_led) 24void led_set(uint8_t usb_led)
24{ 25{
25 // not supported now 26 /* X68000 LED bits 0: on, 1: off
27 * bit 7 1(fixed)
28 * bit 6 全角
29 * bit 5 ひらがな
30 * bit 4 INS
31 * bit 3 CAPS
32 * bit 2 コード入力
33 * bit 1 ローマ字
34 * bit 0 かな
35 */
36 uint8_t led = 0xFF;
37 if (usb_led&(1<<USB_LED_NUM_LOCK)) led &= ~(1<<2);
38 if (usb_led&(1<<USB_LED_CAPS_LOCK)) led &= ~(1<<3);
39 if (usb_led&(1<<USB_LED_SCROLL_LOCK)) led &= ~(1<<1);
40 if (usb_led&(1<<USB_LED_COMPOSE)) led &= ~(1<<4);
41 if (usb_led&(1<<USB_LED_KANA)) led &= ~(1<<0);
42 serial_send(led);
26} 43}
diff --git a/converter/x68k_usb/matrix.c b/converter/x68k_usb/matrix.c
index 954e7ef12..2d5a1e116 100644
--- a/converter/x68k_usb/matrix.c
+++ b/converter/x68k_usb/matrix.c
@@ -21,8 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#include <util/delay.h> 21#include <util/delay.h>
22#include "print.h" 22#include "print.h"
23#include "util.h" 23#include "util.h"
24#include "x68k.h" 24#include "serial.h"
25#include "matrix.h" 25#include "matrix.h"
26#include "debug.h"
26 27
27 28
28/* 29/*
@@ -63,7 +64,7 @@ uint8_t matrix_cols(void)
63 64
64void matrix_init(void) 65void matrix_init(void)
65{ 66{
66 x68k_init(); 67 serial_init();
67 68
68 // initialize matrix state: all keys off 69 // initialize matrix state: all keys off
69 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; 70 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
@@ -75,13 +76,13 @@ uint8_t matrix_scan(void)
75{ 76{
76 is_modified = false; 77 is_modified = false;
77 78
78 uint8_t code; 79 uint16_t code;
79 code = x68k_recv(); 80 code = serial_recv2();
80 if (code == 0) { 81 if (code == -1) {
81 return 0; 82 return 0;
82 } 83 }
83 84
84 phex(code); print(" "); 85 dprintf("%02X\n", code);
85 if (code&0x80) { 86 if (code&0x80) {
86 // break code 87 // break code
87 if (matrix_is_on(ROW(code), COL(code))) { 88 if (matrix_is_on(ROW(code), COL(code))) {
diff --git a/protocol/x68k.c b/protocol/x68k.c
deleted file mode 100644
index d17af51cc..000000000
--- a/protocol/x68k.c
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2Copyright 2012 Jun WAKO <wakojun@gmail.com>
3
4This software is licensed with a Modified BSD License.
5All of this is supposed to be Free Software, Open Source, DFSG-free,
6GPL-compatible, and OK to use in both free and proprietary applications.
7Additions and corrections to this file are welcome.
8
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13* Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16* Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in
18 the documentation and/or other materials provided with the
19 distribution.
20
21* Neither the name of the copyright holders nor the names of
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
24
25THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36*/
37
38#include <stdbool.h>
39#include <avr/io.h>
40#include <avr/interrupt.h>
41#include "x68k.h"
42
43
44void x68k_init(void)
45{
46 KBD_RX_INIT();
47}
48
49// RX ring buffer
50#define RBUF_SIZE 8
51static uint8_t rbuf[RBUF_SIZE];
52static uint8_t rbuf_head = 0;
53static uint8_t rbuf_tail = 0;
54
55uint8_t x68k_recv(void)
56{
57 uint8_t data = 0;
58 if (rbuf_head == rbuf_tail) {
59 return 0;
60 }
61
62 data = rbuf[rbuf_tail];
63 rbuf_tail = (rbuf_tail + 1) % RBUF_SIZE;
64 return data;
65}
66
67// USART RX complete interrupt
68ISR(KBD_RX_VECT)
69{
70 uint8_t next = (rbuf_head + 1) % RBUF_SIZE;
71 if (next != rbuf_tail) {
72 rbuf[rbuf_head] = KBD_RX_DATA;
73 rbuf_head = next;
74 }
75}
diff --git a/protocol/x68k.h b/protocol/x68k.h
deleted file mode 100644
index 2cfda63a7..000000000
--- a/protocol/x68k.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2Copyright 2012 Jun WAKO <wakojun@gmail.com>
3
4This software is licensed with a Modified BSD License.
5All of this is supposed to be Free Software, Open Source, DFSG-free,
6GPL-compatible, and OK to use in both free and proprietary applications.
7Additions and corrections to this file are welcome.
8
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13* Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16* Redistributions in binary form must reproduce the above copyright
17 notice, this list of conditions and the following disclaimer in
18 the documentation and/or other materials provided with the
19 distribution.
20
21* Neither the name of the copyright holders nor the names of
22 contributors may be used to endorse or promote products derived
23 from this software without specific prior written permission.
24
25THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35POSSIBILITY OF SUCH DAMAGE.
36*/
37
38#ifndef X68K_H
39#define X68K_H
40
41/* host role */
42void x68k_init(void);
43uint8_t x68k_recv(void);
44
45/* device role */
46
47#endif