]> git.gir.st - tmk_keyboard.git/blob - converter/next_usb/config.h
Update config.h
[tmk_keyboard.git] / converter / next_usb / config.h
1 /*
2 NeXT non-ADB Keyboard USB Converter
3
4 Copyright 2013, Benjamin Gould (bgould@github.com)
5
6 Based on:
7 TMK firmware code Copyright 2011,2012 Jun WAKO <wakojun@gmail.com>
8 Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license
9
10 Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB
11 Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html
12 Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/
13
14 This software is licensed with a Modified BSD License.
15 All of this is supposed to be Free Software, Open Source, DFSG-free,
16 GPL-compatible, and OK to use in both free and proprietary applications.
17 Additions and corrections to this file are welcome.
18
19 Redistribution and use in source and binary forms, with or without
20 modification, are permitted provided that the following conditions are met:
21
22 * Redistributions of source code must retain the above copyright
23 notice, this list of conditions and the following disclaimer.
24
25 * Redistributions in binary form must reproduce the above copyright
26 notice, this list of conditions and the following disclaimer in
27 the documentation and/or other materials provided with the
28 distribution.
29
30 * Neither the name of the copyright holders nor the names of
31 contributors may be used to endorse or promote products derived
32 from this software without specific prior written permission.
33
34 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
38 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
39 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
40 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
41 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
42 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
43 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
44 POSSIBILITY OF SUCH DAMAGE.
45
46 */
47
48 #define VENDOR_ID 0xFEED
49 #define PRODUCT_ID 0xBCBC
50 #define DEVICE_VER 0x0500
51 #define MANUFACTURER t.m.k.
52 #define PRODUCT NeXT Keyboard to USB converter
53 #define DESCRIPTION USB converter for NeXT non-ADB Keyboard
54
55 /* matrix size */
56 #define MATRIX_ROWS 12 // keycode bit: 3-0
57 #define MATRIX_COLS 8 // keycode bit: 6-4
58
59 #define DEBUG_ON_INIT 1
60
61 //#define TEENSY_CONFIG 1
62 //#define PRO_MICRO_CONFIG 1
63 #define TMK_CONFIG 1
64
65 // comment out if you don't want the keyboard's LEDs to flash upon initialization or pressing shift
66 //#define NEXT_KBD_INIT_FLASH_LEDS
67 //#define NEXT_KBD_SHIFT_FLASH_LEDS
68
69 //============= Start of Arduino Pro Micro Configuration ==============
70 #ifdef PRO_MICRO_CONFIG
71
72 // this is the debugging LED that flashes when a key is being pressed
73 // comment out in order to disable debugging LED
74 #define NEXT_KBD_LED1_PORT PORTD
75 #define NEXT_KBD_LED1_PIN PIND
76 #define NEXT_KBD_LED1_DDR DDRD
77 #define NEXT_KBD_LED1_BIT 5
78
79 #define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT);
80 #define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT);
81
82 // reserved for future use
83 #define NEXT_KBD_LED2_PORT PORTB
84 #define NEXT_KBD_LED2_PIN PINB
85 #define NEXT_KBD_LED2_DDR DDRB
86 #define NEXT_KBD_LED2_BIT 6
87
88 #define NEXT_KBD_LED2_ON NEXT_KBD_LED2_PORT &= ~(1<<NEXT_KBD_LED2_BIT);
89 #define NEXT_KBD_LED2_OFF NEXT_KBD_LED2_PORT |= (1<<NEXT_KBD_LED2_BIT);
90
91 // corresponds to the Keyboard In wire on the NeXT connector
92 // (red wire in NeXT connector) - pin 2 on the Pro Micro
93 #define NEXT_KBD_OUT_PORT PORTD
94 #define NEXT_KBD_OUT_PIN PIND
95 #define NEXT_KBD_OUT_DDR DDRD
96 #define NEXT_KBD_OUT_BIT 1
97
98 // corresponds to the Keyboard Out wire on the NeXT connector
99 // (orange wire in NeXT connector) - pin 3 on the Pro Micro
100 #define NEXT_KBD_IN_PORT PORTD
101 #define NEXT_KBD_IN_PIN PIND
102 #define NEXT_KBD_IN_DDR DDRD
103 #define NEXT_KBD_IN_BIT 0
104
105 // this pin is an input for the power key on the NeXT keyboard
106 // as the keyboard is powered on this should be normally high;
107 // if it is pulled low it means the power button is being preseed
108 // (yellow wire in NeXT connector) - pin 4 on the Pro Micro
109 #define NEXT_KBD_PWR_PORT PORTD
110 #define NEXT_KBD_PWR_PIN PIND
111 #define NEXT_KBD_PWR_DDR DDRD
112 #define NEXT_KBD_PWR_BIT 4
113
114 #endif
115 //============== End of Arduino Pro Micro Configuration ===============
116
117
118 //================ Start of Teensy 2.0 Configuration =================
119 #ifdef TEENSY_CONFIG
120
121 // this is the debugging LED that flashes when a key is being pressed
122 // comment out in order to disable debugging LED
123 #define NEXT_KBD_LED_PORT PORTD
124 #define NEXT_KBD_LED_PIN PIND
125 #define NEXT_KBD_LED_DDR DDRD
126 #define NEXT_KBD_LED_BIT 6
127
128 #define NEXT_KBD_LED_ON NEXT_KBD_LED_PORT |= (1<<NEXT_KBD_LED_BIT);
129 #define NEXT_KBD_LED_OFF NEXT_KBD_LED_PORT &= ~(1<<NEXT_KBD_LED_BIT);
130
131 // corresponds to the Keyboard In wire on the NeXT connector
132 // (red wire in NeXT connector)
133 #define NEXT_KBD_OUT_PORT PORTB
134 #define NEXT_KBD_OUT_PIN PINB
135 #define NEXT_KBD_OUT_DDR DDRB
136 #define NEXT_KBD_OUT_BIT 1
137
138 // corresponds to the Keyboard Out wire on the NeXT connector
139 // (orange wire in NeXT connector)
140 #define NEXT_KBD_IN_PORT PORTB
141 #define NEXT_KBD_IN_PIN PINB
142 #define NEXT_KBD_IN_DDR DDRB
143 #define NEXT_KBD_IN_BIT 0
144
145 #endif
146 //================= End of Teensy 2.0 Configuration ==================
147
148
149 //================ Start of TMK converter Configuration =================
150 #ifdef TMK_CONFIG
151
152 // this is the debugging LED that flashes when a key is being pressed
153 // comment out in order to disable debugging LED
154 #define NEXT_KBD_LED1_PORT PORTD
155 #define NEXT_KBD_LED1_PIN PIND
156 #define NEXT_KBD_LED1_DDR DDRD
157 #define NEXT_KBD_LED1_BIT 6
158
159 #define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT |= (1<<NEXT_KBD_LED1_BIT);
160 #define NEXT_KBD_LED1_OFF NEXT_KBD_LED1_PORT &= ~(1<<NEXT_KBD_LED1_BIT);
161
162 // corresponds to the Keyboard In wire on the NeXT connector
163 #define NEXT_KBD_OUT_PORT PORTD
164 #define NEXT_KBD_OUT_PIN PIND
165 #define NEXT_KBD_OUT_DDR DDRD
166 #define NEXT_KBD_OUT_BIT 1
167
168 // corresponds to the Keyboard Out wire on the NeXT connector
169 #define NEXT_KBD_IN_PORT PORTD
170 #define NEXT_KBD_IN_PIN PIND
171 #define NEXT_KBD_IN_DDR DDRD
172 #define NEXT_KBD_IN_BIT 0
173
174 // this pin is an input for the power key on the NeXT keyboard
175 // as the keyboard is powered on this should be normally high;
176 // if it is pulled low it means the power button is being preseed
177 #define NEXT_KBD_PWR_PORT PORTD
178 #define NEXT_KBD_PWR_PIN PIND
179 #define NEXT_KBD_PWR_DDR DDRD
180 #define NEXT_KBD_PWR_BIT 4
181
182 #endif
183 //================= End of TMK converter Configuration ==================
184
185 /* key combination for command */
186 #define IS_COMMAND() ( \
187 (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) || \
188 (keyboard_report->mods == (MOD_BIT(KC_RALT) | MOD_BIT(KC_RALT))) || \
189 (keyboard_report->mods == (MOD_BIT(KC_RGUI) | MOD_BIT(KC_RGUI))) \
190 )
Imprint / Impressum