aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2014-07-27 17:07:26 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-07-27 17:38:31 +0200
commit7dde35d4f7cc3cc1569a31e752ea4043133b1a72 (patch)
tree9c91ff60feb667492d76ecfe086849e6fba18b68
parent388fe60c67dbc4232a979d3de3b3b161a67871e2 (diff)
downloadqmk_firmware-7dde35d4f7cc3cc1569a31e752ea4043133b1a72.tar.gz
qmk_firmware-7dde35d4f7cc3cc1569a31e752ea4043133b1a72.zip
integrated serial mouse drivers as a feature into the firmware architecture
* can be enabled by defining Makefile macro SERIAL_MOUSE_MICROSOFT_ENABLE or SERIAL_MOUSE_MOUSESYSTEMS_ENABLE. * Serial implementation can be chosen via SERIAL_MOUSE_USE_SOFT and SERIAL_MOUSE_USE_UART macros * UART configuration still has to be done in config.h: I added working clauses for both mouse protocols to ps2_usb's config.h
-rw-r--r--converter/ps2_usb/Makefile13
-rw-r--r--converter/ps2_usb/config.h38
-rw-r--r--protocol.mk20
-rw-r--r--protocol/lufa/lufa.c12
-rw-r--r--protocol/serial_mouse_mousesystems.c2
5 files changed, 84 insertions, 1 deletions
diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile
index 1dd23c157..f20039c6f 100644
--- a/converter/ps2_usb/Makefile
+++ b/converter/ps2_usb/Makefile
@@ -91,6 +91,19 @@ PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomen
91#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin 91#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
92#PS2_USE_BUSYWAIT = yes # uses primitive reference code 92#PS2_USE_BUSYWAIT = yes # uses primitive reference code
93 93
94# Serial Mouse Options
95# You can choose a mouse protocol and the implementation of
96# the underlying serial connection.
97#
98#SERIAL_MOUSE_MICROSOFT_ENABLE = yes # Enable support for Microsoft-compatible mice
99#SERIAL_MOUSE_MOUSESYSTEMS_ENABLE = yes # Enable support for Mousesystems-compatible mice
100#SERIAL_MOUSE_USE_UART = yes # use hardware UART for serial connection
101#SERIAL_MOUSE_USE_SOFT = yes # use software serial implementation
102
103# Optional serial mouse driver features
104# Support scrolling while holding the middle mouse button
105# (currently only supported for Mousesystems mice):
106#OPT_DEFS += -DSERIAL_MOUSE_CENTER_SCROLL
94 107
95# Optimize size but this may cause error "relocation truncated to fit" 108# Optimize size but this may cause error "relocation truncated to fit"
96#EXTRALDFLAGS = -Wl,--relax 109#EXTRALDFLAGS = -Wl,--relax
diff --git a/converter/ps2_usb/config.h b/converter/ps2_usb/config.h
index 889f0c38e..5b644002d 100644
--- a/converter/ps2_usb/config.h
+++ b/converter/ps2_usb/config.h
@@ -170,4 +170,42 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
170#endif 170#endif
171#endif 171#endif
172 172
173#ifdef SERIAL_MOUSE_MICROSOFT
174 /*
175 * Serial(USART) configuration (for Microsoft serial mice)
176 * asynchronous, positive logic, 1200baud, bit order: LSB first
177 * 1-start bit, 7-data bit, no parity, 1-stop bit
178 */
179 #define SERIAL_UART_BAUD 1200
180 #define SERIAL_UART_DATA UDR1
181 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
182 #define SERIAL_UART_RXD_VECT USART1_RX_vect
183 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
184 #define SERIAL_UART_INIT() do { \
185 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
186 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
187 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
188 UCSR1C = (1<<UCSZ11) | (0<<UCSZ10); /* no parity, 1 stop bit, 7-bit characters */ \
189 sei(); \
190 } while(0)
191#elif defined(SERIAL_MOUSE_MOUSESYSTEMS)
192 /*
193 * Serial(USART) configuration (for Mousesystems serial mice)
194 * asynchronous, positive logic, 1200baud, bit order: LSB first
195 * 1-start bit, 8-data bit, no parity, 1-stop bit
196 */
197 #define SERIAL_UART_BAUD 1200
198 #define SERIAL_UART_DATA UDR1
199 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
200 #define SERIAL_UART_RXD_VECT USART1_RX_vect
201 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
202 #define SERIAL_UART_INIT() do { \
203 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
204 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
205 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); /* RX interrupt, RX: enable */ \
206 UCSR1C = (1<<UCSZ11) | (1<<UCSZ10); /* no parity, 1 stop bit, 8-bit characters */ \
207 sei(); \
208 } while(0)
209#endif
210
173#endif 211#endif
diff --git a/protocol.mk b/protocol.mk
index 7f561e62d..de7014e86 100644
--- a/protocol.mk
+++ b/protocol.mk
@@ -23,5 +23,25 @@ ifdef PS2_USE_USART
23endif 23endif
24 24
25 25
26ifdef SERIAL_MOUSE_MICROSOFT_ENABLE
27 SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
28 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
29 -DMOUSE_ENABLE
30endif
31
32ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE
33 SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
34 OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
35 -DMOUSE_ENABLE
36endif
37
38ifdef SERIAL_MOUSE_USE_SOFT
39 SRC += $(PROTOCOL_DIR)/serial_soft.c
40endif
41
42ifdef SERIAL_MOUSE_USE_UART
43 SRC += $(PROTOCOL_DIR)/serial_uart.c
44endif
45
26# Search Path 46# Search Path
27VPATH += $(TOP_DIR)/protocol 47VPATH += $(TOP_DIR)/protocol
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index 16a602df1..58201e5c9 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -49,6 +49,10 @@
49#endif 49#endif
50#include "suspend.h" 50#include "suspend.h"
51 51
52#ifdef SERIAL_MOUSE_ENABLE
53#include "serial_mouse.h"
54#endif
55
52#include "descriptor.h" 56#include "descriptor.h"
53#include "lufa.h" 57#include "lufa.h"
54 58
@@ -571,6 +575,10 @@ int main(void)
571 sleep_led_init(); 575 sleep_led_init();
572#endif 576#endif
573 577
578#ifdef SERIAL_MOUSE_ENABLE
579 serial_mouse_init();
580#endif
581
574 print("Keyboard start.\n"); 582 print("Keyboard start.\n");
575 while (1) { 583 while (1) {
576 while (USB_DeviceState == DEVICE_STATE_Suspended) { 584 while (USB_DeviceState == DEVICE_STATE_Suspended) {
@@ -582,6 +590,10 @@ int main(void)
582 590
583 keyboard_task(); 591 keyboard_task();
584 592
593#ifdef SERIAL_MOUSE_ENABLE
594 serial_mouse_task();
595#endif
596
585#if !defined(INTERRUPT_CONTROL_ENDPOINT) 597#if !defined(INTERRUPT_CONTROL_ENDPOINT)
586 USB_USBTask(); 598 USB_USBTask();
587#endif 599#endif
diff --git a/protocol/serial_mouse_mousesystems.c b/protocol/serial_mouse_mousesystems.c
index ec708c911..68b2b5b35 100644
--- a/protocol/serial_mouse_mousesystems.c
+++ b/protocol/serial_mouse_mousesystems.c
@@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#include "print.h" 27#include "print.h"
28#include "debug.h" 28#include "debug.h"
29 29
30#define SERIAL_MOUSE_CENTER_SCROLL 30//#define SERIAL_MOUSE_CENTER_SCROLL
31 31
32static void print_usb_data(const report_mouse_t *report); 32static void print_usb_data(const report_mouse_t *report);
33 33