]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - hhkb/config_vusb.h
3b44b94a310a0eac71f54dcd83167032f88c8f84
[max/tmk_keyboard.git] / hhkb / config_vusb.h
1 #ifndef CONFIG_H
2 #define CONFIG_H
3
4
5 #define VENDOR_ID       0xFEED
6 #define PRODUCT_ID      0xC0FE
7 // TODO: share these strings with usbconfig.h
8 // Edit usbconfig.h to change these.
9 #define MANUFACTURER    t.m.k.
10 #define PRODUCT         HHKB mod
11 #define DESCRIPTION     t.m.k. keyboard firmware for HHKB mod
12
13
14 /* matrix size */
15 #define MATRIX_ROWS 8
16 #define MATRIX_COLS 8
17
18
19 /* key combination for command */
20 #define IS_COMMAND() ( \
21     keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
22     keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
23 )
24
25
26 /* mouse keys */
27 #ifdef MOUSEKEY_ENABLE
28 #   define MOUSEKEY_DELAY_TIME 255
29 #endif
30
31
32 /* PS/2 lines */
33 #ifdef PS2_MOUSE_ENABLE
34
35 #define PS2_CLOCK_PORT  PORTD
36 #define PS2_CLOCK_PIN   PIND
37 #define PS2_CLOCK_DDR   DDRD
38 #define PS2_CLOCK_BIT   4
39 #define PS2_DATA_PORT   PORTD
40 #define PS2_DATA_PIN    PIND
41 #define PS2_DATA_DDR    DDRD
42 #define PS2_DATA_BIT    0
43
44
45 // Synchronous USART is used to receive data from keyboard.
46 // Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK.
47 // NOTE: This is recomended strongly if you use V-USB library.
48 #define PS2_USE_USART
49
50 // External or Pin Change Interrupt is used to receive data from keyboard.
51 // Use INT1 or PCINTxx for PS/2 CLOCK line. see below.
52 //#define PS2_USE_INT
53
54
55 #ifdef PS2_USE_USART
56 // synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge
57 // set DDR of CLOCK as input to be slave
58 #define PS2_USART_INIT() do {   \
59     PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT);   \
60     PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT);     \
61     UCSR0C = ((1 << UMSEL00) |  \
62               (3 << UPM00)   |  \
63               (0 << USBS0)   |  \
64               (3 << UCSZ00)  |  \
65               (0 << UCPOL0));   \
66     UCSR0A = 0;                 \
67     UBRR0H = 0;                 \
68     UBRR0L = 0;                 \
69 } while (0)
70 #define PS2_USART_RX_INT_ON() do {  \
71     UCSR0B = ((1 << RXCIE0) |       \
72               (1 << RXEN0));        \
73 } while (0)
74 #define PS2_USART_RX_POLL_ON() do { \
75     UCSR0B = (1 << RXEN0);          \
76 } while (0)
77 #define PS2_USART_OFF() do {    \
78     UCSR0C = 0;                 \
79     UCSR0B &= ~((1 << RXEN0) |  \
80                 (1 << TXEN0));  \
81 } while (0)
82 #define PS2_USART_RX_READY      (UCSR0A & (1<<RXC0))
83 #define PS2_USART_RX_DATA       UDR0
84 #define PS2_USART_ERROR         (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0)))
85 #define PS2_USART_RX_VECT       USART_RX_vect
86 #endif
87
88
89 #ifdef PS2_USE_INT
90 /* INT1
91 #define PS2_INT_INIT()  do {    \
92     EICRA |= ((1<<ISC11) |      \
93               (0<<ISC10));      \
94 } while (0)
95 #define PS2_INT_ON()  do {      \
96     EIMSK |= (1<<INT1);         \
97 } while (0)
98 #define PS2_INT_OFF() do {      \
99     EIMSK &= ~(1<<INT1);        \
100 } while (0)
101 #define PS2_INT_VECT    INT1_vect
102 */
103
104 /* PCINT20 */
105 #define PS2_INT_INIT()  do {    \
106     PCICR  |= (1<<PCIE2);       \
107 } while (0)
108 #define PS2_INT_ON()  do {      \
109     PCMSK2 |= (1<<PCINT20);     \
110 } while (0)
111 #define PS2_INT_OFF() do {      \
112     PCMSK2 &= ~(1<<PCINT20);    \
113     PCICR  &= ~(1<<PCIE2);      \
114 } while (0)
115 #define PS2_INT_VECT    PCINT2_vect
116 #endif
117
118 #endif
119
120 #endif