]> git.gir.st - tmk_keyboard.git/blob - orphan/serialmouse_usb/config.h
Move some projects to 'orphan' directory
[tmk_keyboard.git] / orphan / serialmouse_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 #include <avr/interrupt.h>
22
23 #define VENDOR_ID 0xFEED
24 #define PRODUCT_ID 0x2222
25 #define DEVICE_VER 0x0001
26 #define MANUFACTURER t.m.k.
27 #define PRODUCT serial mouse converter
28 #define DESCRIPTION convert serial mouse into USB
29
30
31 /* matrix size */
32 #define MATRIX_ROWS 0
33 #define MATRIX_COLS 0
34
35
36 /* key combination for command */
37 #define IS_COMMAND() false
38
39
40
41 #ifdef SERIAL_MOUSE_MICROSOFT
42 /*
43 * Serial(USART) configuration (for Microsoft serial mice)
44 * asynchronous, positive logic, 1200baud, bit order: LSB first
45 * 1-start bit, 7-data bit, no parity, 1-stop bit
46 */
47 #define SERIAL_UART_BAUD 1200
48 #define SERIAL_UART_DATA UDR1
49 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
50 #define SERIAL_UART_RXD_VECT USART1_RX_vect
51 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
52 #define SERIAL_UART_INIT() do { \
53 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
54 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
55 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
56 UCSR1C = (1<<UCSZ11) | (0<<UCSZ10); /* no parity, 1 stop bit, 7-bit characters */ \
57 sei(); \
58 } while(0)
59
60 // for Microsoft mouse protocol
61 /* Serial(USART) configuration
62 * asynchronous, negative logic, 1200baud, no flow control
63 * 1-start bit, 7-data bit, non parity, 1-stop bit
64 */
65 #define SERIAL_SOFT_BAUD 1200
66 #define SERIAL_SOFT_DATA_7BIT
67 #define SERIAL_SOFT_PARITY_NONE
68 #define SERIAL_SOFT_BIT_ORDER_LSB
69 #define SERIAL_SOFT_LOGIC_NEGATIVE
70 /* RXD Port */
71 #define SERIAL_SOFT_RXD_DDR DDRD
72 #define SERIAL_SOFT_RXD_PORT PORTD
73 #define SERIAL_SOFT_RXD_PIN PIND
74 #define SERIAL_SOFT_RXD_BIT 2
75 #define SERIAL_SOFT_RXD_VECT INT2_vect
76 /* RXD Interupt */
77 #define SERIAL_SOFT_RXD_INIT() do { \
78 /* pin configuration: input with pull-up */ \
79 SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
80 SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
81 /* enable interrupt: INT2(rising edge) */ \
82 EICRA |= ((1<<ISC21)|(1<<ISC20)); \
83 EIMSK |= (1<<INT2); \
84 sei(); \
85 } while (0)
86 #define SERIAL_SOFT_RXD_INT_ENTER()
87 #define SERIAL_SOFT_RXD_INT_EXIT() do { \
88 /* clear interrupt flag */ \
89 EIFR = (1<<INTF2); \
90 } while (0)
91 #define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
92 /* TXD Port */
93 #define SERIAL_SOFT_TXD_HI()
94 #define SERIAL_SOFT_TXD_LO()
95 #define SERIAL_SOFT_TXD_INIT()
96 #elif defined(SERIAL_MOUSE_MOUSESYSTEMS)
97 /*
98 * Serial(USART) configuration (for Mousesystems serial mice)
99 * asynchronous, positive logic, 1200baud, bit order: LSB first
100 * 1-start bit, 8-data bit, no parity, 1-stop bit
101 */
102 #define SERIAL_UART_BAUD 1200
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 UCSR1C = (1<<UCSZ11) | (1<<UCSZ10); /* no parity, 1 stop bit, 8-bit characters */ \
112 sei(); \
113 } while(0)
114 #endif
115
116
117
118
119 #endif
Imprint / Impressum