2 Copyright 2012 Jun Wako <wakojun@gmail.com>
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "config_common.h"
23 #define USB_VENDOR_ID_LENOVO 0x17ef
24 #define USB_DEVICE_ID_LENOVO_TPKBD 0x6009
25 #define USB_DEVICE_ID_LENOVO_CUSBKBD 0x6047
26 #define USB_DEVICE_ID_LENOVO_CBTKBD 0x6048
27 #define USB_DEVICE_ID_LENOVO_TPPRODOCK 0x6067
29 /* USB Device descriptor parameter */
30 #define VENDOR_ID USB_VENDOR_ID_LENOVO
31 #define PRODUCT_ID USB_DEVICE_ID_LENOVO_CBTKBD
32 #define DEVICE_VER 0x0001
33 #define MANUFACTURER Priyadi
34 #define PRODUCT Promethium Keyboard
42 #define MATRIX_COL_PINS { B6, B7, D6, C7, F6, F7 }
43 #define MATRIX_ROW_PINS { D7, C6, D0, D1, F5, F4, F1, F0 }
47 * Keyboard Matrix Assignments
49 * Change this to how you wired your keyboard
50 * COLS: AVR pins used for columns, left to right
51 * ROWS: AVR pins used for rows, top to bottom
52 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
53 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
56 #define DIODE_DIRECTION COL2ROW
58 // #define BACKLIGHT_PIN B7
59 // #define BACKLIGHT_BREATHING
60 // #define BACKLIGHT_LEVELS 3
62 /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
63 #define DEBOUNCING_DELAY 5
65 /* define if matrix has ghost (lacks anti-ghosting diodes) */
66 //#define MATRIX_HAS_GHOST
68 /* number of backlight levels */
70 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
71 // #define LOCKING_SUPPORT_ENABLE
72 /* Locking resynchronize hack */
73 // #define LOCKING_RESYNC_ENABLE
78 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
79 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
80 * makefile for this to work.)
82 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
83 * until the next keyboard reset.
85 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
86 * fully operational during normal computer usage.
88 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
89 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
90 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
96 /* key combination for command */
97 #define IS_COMMAND() ( \
98 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RCTRL)) \
101 /* control how magic key switches layers */
102 //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
103 //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
104 //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
106 /* override magic key keymap */
107 //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
108 //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
109 //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
110 //#define MAGIC_KEY_HELP1 H
111 //#define MAGIC_KEY_HELP2 SLASH
112 //#define MAGIC_KEY_DEBUG D
113 //#define MAGIC_KEY_DEBUG_MATRIX X
114 //#define MAGIC_KEY_DEBUG_KBD K
115 //#define MAGIC_KEY_DEBUG_MOUSE M
116 //#define MAGIC_KEY_VERSION V
117 //#define MAGIC_KEY_STATUS S
118 //#define MAGIC_KEY_CONSOLE C
119 //#define MAGIC_KEY_LAYER0_ALT1 ESC
120 //#define MAGIC_KEY_LAYER0_ALT2 GRAVE
121 //#define MAGIC_KEY_LAYER0 0
122 //#define MAGIC_KEY_LAYER1 1
123 //#define MAGIC_KEY_LAYER2 2
124 //#define MAGIC_KEY_LAYER3 3
125 //#define MAGIC_KEY_LAYER4 4
126 //#define MAGIC_KEY_LAYER5 5
127 //#define MAGIC_KEY_LAYER6 6
128 //#define MAGIC_KEY_LAYER7 7
129 //#define MAGIC_KEY_LAYER8 8
130 //#define MAGIC_KEY_LAYER9 9
131 //#define MAGIC_KEY_BOOTLOADER PAUSE
132 //#define MAGIC_KEY_LOCK CAPS
133 //#define MAGIC_KEY_EEPROM E
134 //#define MAGIC_KEY_NKRO N
135 //#define MAGIC_KEY_SLEEP_LED Z
138 * Feature disable options
139 * These options are also useful to firmware size reduction.
142 /* disable debug print */
148 /* disable action features */
149 //#define NO_ACTION_LAYER
150 //#define NO_ACTION_TAPPING
151 //#define NO_ACTION_ONESHOT
152 //#define NO_ACTION_MACRO
153 //#define NO_ACTION_FUNCTION
155 #define PS2_INIT_DELAY 2000
156 #define BATTERY_PIN 9
157 #define BATTERY_POLL 30000
158 #define MAX_VOLTAGE 4.2
159 #define MIN_VOLTAGE 3.2
162 k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, \
163 k21, k22, k23, k24, k25, k26, k27, k28, k29, k2a, k2b, k2c, \
164 k31, k32, k33, k34, k35, k36, k37, k38, k39, k3a, k3b, k3c, \
165 k41, k42, k43, k44, k45, k46, k47, k48, k49, k4a, k4b, k4c \
168 {k11, k12, k13, k14, k15, k16}, \
169 {k21, k22, k23, k24, k25, k26}, \
170 {k31, k32, k33, k34, k35, k36}, \
171 {k41, k42, k43, k44, k45, k46}, \
172 {k17, k18, k19, k1a, k1b, k1c}, \
173 {k27, k28, k29, k2a, k2b, k2c}, \
174 {k37, k38, k39, k3a, k3b, k3c}, \
175 {k47, k48, k49, k4a, k4b, k4c} \
178 #ifndef __ASSEMBLER__ // assembler doesn't like enum in .h file
255 #define RGB_DI_PIN B5
256 #define RGBSPS_NUM LED_TOTAL
260 #ifdef PS2_USE_BUSYWAIT
261 # define PS2_CLOCK_PORT PORTD
262 # define PS2_CLOCK_PIN PIND
263 # define PS2_CLOCK_DDR DDRD
264 # define PS2_CLOCK_BIT 1
265 # define PS2_DATA_PORT PORTD
266 # define PS2_DATA_PIN PIND
267 # define PS2_DATA_DDR DDRD
268 # define PS2_DATA_BIT 2
271 /* PS/2 mouse interrupt version */
273 /* uses INT1 for clock line(ATMega32U4) */
274 #define PS2_CLOCK_PORT PORTD
275 #define PS2_CLOCK_PIN PIND
276 #define PS2_CLOCK_DDR DDRD
277 #define PS2_CLOCK_BIT 3
278 #define PS2_DATA_PORT PORTD
279 #define PS2_DATA_PIN PIND
280 #define PS2_DATA_DDR DDRD
281 #define PS2_DATA_BIT 2
283 #define PS2_INT_INIT() do { \
284 EICRA |= ((1<<ISC31) | \
287 #define PS2_INT_ON() do { \
288 EIMSK |= (1<<INT3); \
290 #define PS2_INT_OFF() do { \
291 EIMSK &= ~(1<<INT3); \
293 #define PS2_INT_VECT INT3_vect
296 /* PS/2 mouse USART version */
298 /* XCK for clock line and RXD for data line */
299 #define PS2_CLOCK_PORT PORTD
300 #define PS2_CLOCK_PIN PIND
301 #define PS2_CLOCK_DDR DDRD
302 #define PS2_CLOCK_BIT 5
303 #define PS2_DATA_PORT PORTD
304 #define PS2_DATA_PIN PIND
305 #define PS2_DATA_DDR DDRD
306 #define PS2_DATA_BIT 2
308 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
309 /* set DDR of CLOCK as input to be slave */
310 #define PS2_USART_INIT() do { \
311 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
312 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
313 UCSR1C = ((1 << UMSEL10) | \
322 #define PS2_USART_RX_INT_ON() do { \
323 UCSR1B = ((1 << RXCIE1) | \
326 #define PS2_USART_RX_POLL_ON() do { \
327 UCSR1B = (1 << RXEN1); \
329 #define PS2_USART_OFF() do { \
331 UCSR1B &= ~((1 << RXEN1) | \
334 #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
335 #define PS2_USART_RX_DATA UDR1
336 #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
337 #define PS2_USART_RX_VECT USART1_RX_vect