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/>.
22 /* USB Device descriptor parameter */
23 #define VENDOR_ID 0xFEED
24 #define PRODUCT_ID 0x1111
25 #define DEVICE_VER 0x0001
26 #define MANUFACTURER geekhack
27 #define PRODUCT Onekey
28 #define DESCRIPTION t.m.k. keyboard firmware for Onekey
34 /* define if matrix has ghost */
35 //#define MATRIX_HAS_GHOST
37 /* Set 0 if debouncing isn't needed */
40 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
41 #define LOCKING_SUPPORT_ENABLE
42 /* Locking resynchronize hack */
43 #define LOCKING_RESYNC_ENABLE
45 /* key combination for command */
46 #define IS_COMMAND() ( \
47 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
53 * Feature disable options
54 * These options are also useful to firmware size reduction.
57 /* disable debug print */
63 /* disable action features */
64 //#define NO_ACTION_LAYER
65 //#define NO_ACTION_TAPPING
66 //#define NO_ACTION_ONESHOT
67 //#define NO_ACTION_MACRO
68 //#define NO_ACTION_FUNCTION
72 #ifdef PS2_USE_BUSYWAIT
73 # define PS2_CLOCK_PORT PORTD
74 # define PS2_CLOCK_PIN PIND
75 # define PS2_CLOCK_DDR DDRD
76 # define PS2_CLOCK_BIT 1
77 # define PS2_DATA_PORT PORTD
78 # define PS2_DATA_PIN PIND
79 # define PS2_DATA_DDR DDRD
80 # define PS2_DATA_BIT 2
84 /* PS/2 mouse interrupt version */
86 /* uses INT1 for clock line(ATMega32U4) */
87 #define PS2_CLOCK_PORT PORTD
88 #define PS2_CLOCK_PIN PIND
89 #define PS2_CLOCK_DDR DDRD
90 #define PS2_CLOCK_BIT 1
91 #define PS2_DATA_PORT PORTD
92 #define PS2_DATA_PIN PIND
93 #define PS2_DATA_DDR DDRD
94 #define PS2_DATA_BIT 2
96 #define PS2_INT_INIT() do { \
97 EICRA |= ((1<<ISC11) | \
100 #define PS2_INT_ON() do { \
101 EIMSK |= (1<<INT1); \
103 #define PS2_INT_OFF() do { \
104 EIMSK &= ~(1<<INT1); \
106 #define PS2_INT_VECT INT1_vect
110 /* PS/2 mouse USART version */
112 #if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
113 /* XCK for clock line and RXD for data line */
114 #define PS2_CLOCK_PORT PORTD
115 #define PS2_CLOCK_PIN PIND
116 #define PS2_CLOCK_DDR DDRD
117 #define PS2_CLOCK_BIT 5
118 #define PS2_DATA_PORT PORTD
119 #define PS2_DATA_PIN PIND
120 #define PS2_DATA_DDR DDRD
121 #define PS2_DATA_BIT 2
123 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
124 /* set DDR of CLOCK as input to be slave */
125 #define PS2_USART_INIT() do { \
126 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
127 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
128 UCSR1C = ((1 << UMSEL10) | \
137 #define PS2_USART_RX_INT_ON() do { \
138 UCSR1B = ((1 << RXCIE1) | \
141 #define PS2_USART_RX_POLL_ON() do { \
142 UCSR1B = (1 << RXEN1); \
144 #define PS2_USART_OFF() do { \
146 UCSR1B &= ~((1 << RXEN1) | \
149 #define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
150 #define PS2_USART_RX_DATA UDR1
151 #define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
152 #define PS2_USART_RX_VECT USART1_RX_vect