]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - converter/pc88_usb/config.h
ibmpc_usb: Add prebuilt firmware files
[max/tmk_keyboard.git] / converter / pc88_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      0x8801
23 #define DEVICE_VER      0x0101
24 #define MANUFACTURER    t.m.k.
25 #define PRODUCT         PC88 keyboard converter
26 #define DESCRIPTION     converts PC88 keyboard protocol into USB
27
28
29 /* matrix size */
30 #define MATRIX_ROWS     16
31 #define MATRIX_COLS     8
32
33 /* key combination for command */
34 #define IS_COMMAND()    ( \
35     keyboard_report->keys[0] == KC_STOP || \
36     keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \
37 )
38
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
46 /*
47  * PC88 Serial(USART) configuration
48  *     asynchronous, positive logic, 20800baud, bit order: LSB first
49  *     1-start bit, 8-data bit, non parity, 1-stop bit
50  */
51
52 /*
53  * Software Serial
54  *   Add protocol/serial_soft.c to SRC in Makefile
55  */
56 #define SERIAL_SOFT_BAUD                20800
57 #define SERIAL_SOFT_PARITY_NONE
58 #define SERIAL_SOFT_BIT_ORDER_LSB
59 #define SERIAL_SOFT_LOGIC_POSITIVE
60 /* RXD Port */
61 #define SERIAL_SOFT_RXD_DDR             DDRD
62 #define SERIAL_SOFT_RXD_PORT            PORTD
63 #define SERIAL_SOFT_RXD_PIN             PIND
64 #define SERIAL_SOFT_RXD_BIT             2
65 #define SERIAL_SOFT_RXD_READ()          (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
66 /* RXD Interupt */
67 #define SERIAL_SOFT_RXD_VECT            INT2_vect
68 #define SERIAL_SOFT_RXD_INIT()          do { \
69     /* pin configuration: input with pull-up */ \
70     SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
71     SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
72     /* enable interrupt: INT2(falling edge) */ \
73     EICRA |= ((1<<ISC21)|(0<<ISC20)); \
74     EIMSK |= (1<<INT2); \
75     sei(); \
76 } while (0)
77 #define SERIAL_SOFT_RXD_INT_ENTER()
78 #define SERIAL_SOFT_RXD_INT_EXIT()      do { \
79     /* clear interrupt  flag */ \
80     EIFR = (1<<INTF2); \
81 } while (0)
82 /* TXD Port */
83 #define SERIAL_SOFT_TXD_DDR             DDRD
84 #define SERIAL_SOFT_TXD_PORT            PORTD
85 #define SERIAL_SOFT_TXD_PIN             PIND
86 #define SERIAL_SOFT_TXD_BIT             3
87 #define SERIAL_SOFT_TXD_HI()            do { SERIAL_SOFT_TXD_PORT |=  (1<<SERIAL_SOFT_TXD_BIT); } while (0)
88 #define SERIAL_SOFT_TXD_LO()            do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
89 #define SERIAL_SOFT_TXD_INIT()          do { \
90     /* pin configuration: output */ \
91     SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
92     /* idle */ \
93     SERIAL_SOFT_TXD_ON(); \
94 } while (0)
95
96
97 /*
98  * Hardware Serial(UART)
99  *   Add protocol/serial_uart.c to SRC in Makefile
100  */
101 #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
102     #define SERIAL_UART_BAUD       20800
103     #define SERIAL_UART_DATA       UDR1
104     #define SERIAL_UART_UBRR       ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
105     #define SERIAL_UART_RXD_VECT   USART1_RX_vect
106     #define SERIAL_UART_TXD_READY  (UCSR1A&(1<<UDRE1))
107     #define SERIAL_UART_INIT()     do { \
108         UBRR1L = (uint8_t) SERIAL_UART_UBRR;       /* baud rate */ \
109         UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8);  /* baud rate */ \
110         UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
111         UCSR1B |= (0<<TXCIE1) | (1<<TXEN1); /* TX interrupt, TX: enable */ \
112         UCSR1C |= (0<<UPM11) | (0<<UPM10);  /* parity: none(00), even(01), odd(11) */ \
113         DDRD  &= ~(1<<2); PORTD |=  (1<<2); /* Pull-up RXD pin */ \
114         sei(); \
115     } while(0)
116 #else
117     #error "USART configuration is needed."
118 #endif
119
120
121 #endif