]> git.donarmstrong.com Git - tmk_firmware.git/blob - converter/pc98_usb/config.h
6f9f8fc3cf17d948634cc7730dfaa3e924a62c40
[tmk_firmware.git] / converter / pc98_usb / 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 #define VENDOR_ID       0xFEED
22 #define PRODUCT_ID      0x3333
23 #define DEVICE_VER      0x0100
24 #define MANUFACTURER    t.m.k.
25 #define PRODUCT         PC98 keyboard converter
26 #define DESCRIPTION     converts PC98 keyboard protocol into USB
27
28
29 /* matrix size */
30 #define MATRIX_ROWS 16
31 #define MATRIX_COLS 8
32
33
34 /* key combination for command */
35 #define IS_COMMAND() ( \
36     keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
37     keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
38     keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
39 )
40
41 /* PC98 control */
42 #define PC98_RST_DDR    DDRD
43 #define PC98_RST_PORT   PORTD
44 #define PC98_RST_BIT    1
45 #define PC98_RDY_DDR    DDRD
46 #define PC98_RDY_PORT   PORTD
47 #define PC98_RDY_BIT    4
48 #define PC98_RTY_DDR    DDRD
49 #define PC98_RTY_PORT   PORTD
50 #define PC98_RTY_BIT    5
51
52 /* Serial(USART) configuration
53  *     asynchronous, negative logic, 19200baud, no flow control
54  *     1-start bit, 8-data bit, odd parity, 1-stop bit
55  */
56 #define SERIAL_BAUD 19200
57 #define SERIAL_PARITY_ODD
58 #define SERIAL_BIT_ORDER_LSB
59
60 #define SERIAL_RXD_DDR  DDRD
61 #define SERIAL_RXD_PORT PORTD
62 #define SERIAL_RXD_PIN  PIND
63 #define SERIAL_RXD_BIT  2
64 #define SERIAL_RXD_VECT INT2_vect
65 #define SERIAL_RXD_INIT()  do { \
66     /* pin configuration: input with pull-up */ \
67     SERIAL_RXD_DDR &= ~(1<<SERIAL_RXD_BIT);     \
68     SERIAL_RXD_PORT |= (1<<SERIAL_RXD_BIT);     \
69     /* enable interrupt: INT2(rising edge) */   \
70     /*EICRA |= ((1<<ISC21)|(1<<ISC20));*/           \
71     /* enable interrupt: INT2(falling edge) */  \
72     EICRA |= ((1<<ISC21)|(0<<ISC20));           \
73     EIMSK |= (1<<INT2);                         \
74 } while (0)
75 #define SERIAL_RXD_INT_ENTER()
76 #define SERIAL_RXD_INT_EXIT() do {  \
77     /* clear interrupt  flag */     \
78     EIFR = (1<<INTF2);              \
79 } while (0)
80 //#define SERIAL_RXD_READ()    (~SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT))
81 #define SERIAL_RXD_READ()    ((SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT)))
82
83 #define SERIAL_TXD_DDR  DDRD
84 #define SERIAL_TXD_PORT PORTD
85 #define SERIAL_TXD_PIN  PIND
86 #define SERIAL_TXD_BIT  3
87 /* negative logic */
88 #define SERIAL_TXD_ON()     do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0)
89 #define SERIAL_TXD_OFF()    do { SERIAL_TXD_PORT |=  (1<<SERIAL_TXD_BIT); } while (0)
90 #define SERIAL_TXD_INIT()   do { \
91     /* pin configuration: output */         \
92     SERIAL_TXD_DDR |= (1<<SERIAL_TXD_BIT);  \
93     /* idle */                              \
94     SERIAL_TXD_ON();                        \
95 } while (0)
96
97 #endif