]> git.donarmstrong.com Git - tmk_firmware.git/blob - keyboard/onekey/config.h
1d2e052bf0961ced26e0aac96ca2bf62c07afa98
[tmk_firmware.git] / keyboard / onekey / config.h
1 /*
2 Copyright 2012 Jun Wako <wakojun@gmail.com>
3
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.
8
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.
13
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/>.
16 */
17
18 #ifndef CONFIG_H
19 #define CONFIG_H
20
21
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
29
30 /* key matrix size */
31 #define MATRIX_ROWS 1
32 #define MATRIX_COLS 1
33
34 /* define if matrix has ghost */
35 //#define MATRIX_HAS_GHOST
36
37 /* Set 0 if debouncing isn't needed */
38 #define DEBOUNCE    5
39
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
44
45 /* key combination for command */
46 #define IS_COMMAND() ( \
47     keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
48 )
49
50
51
52 /*
53  * Feature disable options
54  *  These options are also useful to firmware size reduction.
55  */
56
57 /* disable debug print */
58 //#define NO_DEBUG
59
60 /* disable print */
61 //#define NO_PRINT
62
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
69
70
71 /* PS/2 mouse */
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   5
77 #   define PS2_DATA_PORT   PORTD
78 #   define PS2_DATA_PIN    PIND
79 #   define PS2_DATA_DDR    DDRD
80 #   define PS2_DATA_BIT    2
81 #endif
82
83
84 /* PS/2 mouse interrupt version */
85 #ifdef PS2_USE_INT
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   5
91 #define PS2_DATA_PORT   PORTD
92 #define PS2_DATA_PIN    PIND
93 #define PS2_DATA_DDR    DDRD
94 #define PS2_DATA_BIT    2
95
96 #define PS2_INT_INIT()  do {    \
97     EICRA |= ((1<<ISC11) |      \
98               (0<<ISC10));      \
99 } while (0)
100 #define PS2_INT_ON()  do {      \
101     EIMSK |= (1<<INT1);         \
102 } while (0)
103 #define PS2_INT_OFF() do {      \
104     EIMSK &= ~(1<<INT1);        \
105 } while (0)
106 #define PS2_INT_VECT    INT1_vect
107 #endif
108
109
110 /* PS/2 mouse USART version */
111 #ifdef PS2_USE_USART
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
122
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) |  \
129               (3 << UPM10)   |  \
130               (0 << USBS1)   |  \
131               (3 << UCSZ10)  |  \
132               (0 << UCPOL1));   \
133     UCSR1A = 0;                 \
134     UBRR1H = 0;                 \
135     UBRR1L = 0;                 \
136 } while (0)
137 #define PS2_USART_RX_INT_ON() do {  \
138     UCSR1B = ((1 << RXCIE1) |       \
139               (1 << RXEN1));        \
140 } while (0)
141 #define PS2_USART_RX_POLL_ON() do { \
142     UCSR1B = (1 << RXEN1);          \
143 } while (0)
144 #define PS2_USART_OFF() do {    \
145     UCSR1C = 0;                 \
146     UCSR1B &= ~((1 << RXEN1) |  \
147                 (1 << TXEN1));  \
148 } while (0)
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
153 #endif
154 #endif
155
156 #endif