Synchronous USART support for PS/2 on V-USB stack
[tmk_keyboard.git] / ps2_vusb / config.h
1 #ifndef CONFIG_H
2 #define CONFIG_H
3
4
5 #define VENDOR_ID 0xFEED
6 #define PRODUCT_ID 0x2233
7 // TODO: share these strings with usbconfig.h
8 // Edit usbconfig.h to change these.
9 #define MANUFACTURER t.m.k.
10 #define PRODUCT PS/2 keyboard converter
11 #define DESCRIPTION convert PS/2 keyboard to USB
12
13 /* matrix size */
14 #define MATRIX_ROWS 32 // keycode bit: 3-0
15 #define MATRIX_COLS 8 // keycode bit: 6-4
16
17 /* key combination for command */
18 #define IS_COMMAND() ( \
19 keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
20 keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
21 )
22
23
24 /* USB NKey Rollover */
25 #ifdef USB_NKRO_ENABLE
26 #endif
27
28 /* mouse keys */
29 #ifdef MOUSEKEY_ENABLE
30 # define MOUSEKEY_DELAY_TIME 255
31 #endif
32
33
34 /* PS/2 lines */
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
Imprint / Impressum