Change keymap of ADB converter.
[tmk_keyboard.git] / converter / ps2_usb / config_vusb.h
CommitLineData
0dde25e8 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
4f5f1a53 18#ifndef CONFIG_H
19#define CONFIG_H
20
21
22#define VENDOR_ID 0xFEED
47f5d8b5 23#define PRODUCT_ID 0x2233
24// TODO: share these strings with usbconfig.h
25// Edit usbconfig.h to change these.
4f5f1a53 26#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter
28#define DESCRIPTION convert PS/2 keyboard to USB
29
fb8d23c6 30
4f5f1a53 31/* matrix size */
32#define MATRIX_ROWS 32 // keycode bit: 3-0
33#define MATRIX_COLS 8 // keycode bit: 6-4
9a938eec 34
fb8d23c6 35
9a938eec 36/* key combination for command */
37#define IS_COMMAND() ( \
e67c9888 38 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) || \
39 keyboard_report->mods == (MOD_BIT(KB_LCTRL) | MOD_BIT(KB_RSHIFT)) \
9a938eec 40)
41
4f5f1a53 42
4f5f1a53 43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
2b8cd88a 48
04f351b8 49/* PS/2 lines */
4f5f1a53 50#define PS2_CLOCK_PORT PORTD
51#define PS2_CLOCK_PIN PIND
52#define PS2_CLOCK_DDR DDRD
47f5d8b5 53#define PS2_CLOCK_BIT 4
4f5f1a53 54#define PS2_DATA_PORT PORTD
55#define PS2_DATA_PIN PIND
56#define PS2_DATA_DDR DDRD
47f5d8b5 57#define PS2_DATA_BIT 0
4f5f1a53 58
47f5d8b5 59
60// Synchronous USART is used to receive data from keyboard.
61// Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK.
62// NOTE: This is recomended strongly if you use V-USB library.
63#define PS2_USE_USART
64
65// External or Pin Change Interrupt is used to receive data from keyboard.
66// Use INT1 or PCINTxx for PS/2 CLOCK line. see below.
67//#define PS2_USE_INT
68
69
70#ifdef PS2_USE_USART
71// synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge
72// set DDR of CLOCK as input to be slave
73#define PS2_USART_INIT() do { \
74 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
75 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
76 UCSR0C = ((1 << UMSEL00) | \
77 (3 << UPM00) | \
78 (0 << USBS0) | \
79 (3 << UCSZ00) | \
80 (0 << UCPOL0)); \
81 UCSR0A = 0; \
82 UBRR0H = 0; \
83 UBRR0L = 0; \
04f351b8 84} while (0)
47f5d8b5 85#define PS2_USART_RX_INT_ON() do { \
86 UCSR0B = ((1 << RXCIE0) | \
87 (1 << RXEN0)); \
88} while (0)
89#define PS2_USART_RX_POLL_ON() do { \
90 UCSR0B = (1 << RXEN0); \
91} while (0)
92#define PS2_USART_OFF() do { \
93 UCSR0C = 0; \
94 UCSR0B &= ~((1 << RXEN0) | \
95 (1 << TXEN0)); \
96} while (0)
97#define PS2_USART_RX_READY (UCSR0A & (1<<RXC0))
98#define PS2_USART_RX_DATA UDR0
99#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0)))
100#define PS2_USART_RX_VECT USART_RX_vect
101#endif
2b8cd88a 102
47f5d8b5 103
104#ifdef PS2_USE_INT
105/* INT1
106#define PS2_INT_INIT() do { \
107 EICRA |= ((1<<ISC11) | \
108 (0<<ISC10)); \
109} while (0)
110#define PS2_INT_ON() do { \
111 EIMSK |= (1<<INT1); \
112} while (0)
113#define PS2_INT_OFF() do { \
04f351b8 114 EIMSK &= ~(1<<INT1); \
115} while (0)
116#define PS2_INT_VECT INT1_vect
47f5d8b5 117*/
04f351b8 118
47f5d8b5 119/* PCINT20 */
120#define PS2_INT_INIT() do { \
121 PCICR |= (1<<PCIE2); \
04f351b8 122} while (0)
47f5d8b5 123#define PS2_INT_ON() do { \
124 PCMSK2 |= (1<<PCINT20); \
125} while (0)
126#define PS2_INT_OFF() do { \
127 PCMSK2 &= ~(1<<PCINT20); \
128 PCICR &= ~(1<<PCIE2); \
04f351b8 129} while (0)
130#define PS2_INT_VECT PCINT2_vect
47f5d8b5 131#endif
04f351b8 132
4f5f1a53 133#endif
Imprint / Impressum