pana_m8: Add initial files
[tmk_keyboard.git] / converter / sun_usb / config.h
CommitLineData
97ee1be5 1/*
2Copyright 2012 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
18#ifndef CONFIG_H
19#define CONFIG_H
20
97ee1be5 21#define VENDOR_ID 0xFEED
22#define PRODUCT_ID 0x3333
b56717b8 23#define DEVICE_VER 0x0100
97ee1be5 24#define MANUFACTURER t.m.k.
25#define PRODUCT Sun keyboard converter
26#define DESCRIPTION converts Sun keyboard protocol into USB
27
97ee1be5 28/* matrix size */
29#define MATRIX_ROWS 16
30#define MATRIX_COLS 8
31
97ee1be5 32/* key combination for command */
33#define IS_COMMAND() ( \
34 keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
b56717b8 35 keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
36 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
97ee1be5 37)
38
1d5bbb55 39/* legacy keymap support */
40#define USE_LEGACY_KEYMAP
41
d3332d32
JH
42/* HARDWARE_SERAIL assumes that a logic inverter (7404) is placed
43 * in front of RX/TX to produce the positive logic the MCU expects.
44 * The default is Software Serial.
97ee1be5 45 */
d3332d32
JH
46#if defined(HARDWARE_SERIAL)
47
48 /* Hardware Serial (USART) configuration
49 * asynchronous, negative logic, 1200baud, no flow control
50 * 1-start bit, 8-data bit, non parity, 1-stop bit
51 *
52 */
53 #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__)
54 #define SERIAL_UART_BAUD 1200
55 #define SERIAL_UART_DATA UDR1
56 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
57 #define SERIAL_UART_RXD_VECT USART1_RX_vect
58 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
59 #define SERIAL_UART_INIT() do { \
60 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
61 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
62 UCSR1B = (1<<RXCIE1) | (1<<RXEN1) | /* RX: interrupt, RX: enable */ \
63 (1<<TXEN1); /* TX: enable */ \
64 UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
65 (0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
66 sei(); \
67 } while(0)
68 #else
69 # error "USART configuration is needed."
70 #endif
71
37af8821 72#else
d3332d32
JH
73 /* Software Serial configuration
74 * asynchronous, negative logic, 1200baud, no flow control
75 * 1-start bit, 8-data bit, non parity, 1-stop bit
76 */
77 #define SERIAL_SOFT_BAUD 1200
78 #define SERIAL_SOFT_PARITY_NONE
79 #define SERIAL_SOFT_BIT_ORDER_LSB
80 #define SERIAL_SOFT_LOGIC_NEGATIVE
81 /* RXD Port */
82 #define SERIAL_SOFT_RXD_ENABLE
83 #define SERIAL_SOFT_RXD_DDR DDRD
84 #define SERIAL_SOFT_RXD_PORT PORTD
85 #define SERIAL_SOFT_RXD_PIN PIND
86 #define SERIAL_SOFT_RXD_BIT 2
87 #define SERIAL_SOFT_RXD_VECT INT2_vect
88 /* RXD Interupt */
89 #ifdef SERIAL_SOFT_LOGIC_NEGATIVE
90 /* enable interrupt: INT2(rising edge) */
91 #define INTR_TRIG_EDGE ((1<<ISC21)|(1<<ISC20))
92 #else
93 /* enable interrupt: INT2(falling edge) */
94 #define INTR_TRIG_EDGE ((1<<ISC21)|(0<<ISC20))
95 #endif
96 #define SERIAL_SOFT_RXD_INIT() do { \
97 /* pin configuration: input with pull-up */ \
98 SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
99 SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
100 EICRA |= INTR_TRIG_EDGE; \
101 EIMSK |= (1<<INT2); \
102 sei(); \
103 } while (0)
104 #define SERIAL_SOFT_RXD_INT_ENTER()
105 #define SERIAL_SOFT_RXD_INT_EXIT() do { \
106 /* clear interrupt flag */ \
107 EIFR = (1<<INTF2); \
108 } while (0)
109 #define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
110 /* TXD Port */
111 #define SERIAL_SOFT_TXD_ENABLE
112 #define SERIAL_SOFT_TXD_DDR DDRD
113 #define SERIAL_SOFT_TXD_PORT PORTD
114 #define SERIAL_SOFT_TXD_PIN PIND
115 #define SERIAL_SOFT_TXD_BIT 3
116 #define SERIAL_SOFT_TXD_HI() do { SERIAL_SOFT_TXD_PORT |= (1<<SERIAL_SOFT_TXD_BIT); } while (0)
117 #define SERIAL_SOFT_TXD_LO() do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
118 #define SERIAL_SOFT_TXD_INIT() do { \
119 /* pin configuration: output */ \
120 SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
121 /* idle */ \
122 SERIAL_SOFT_TXD_ON(); \
123 } while (0)
97ee1be5 124
d3332d32
JH
125#endif //hardware serial
126#endif //config.h
Imprint / Impressum