aboutsummaryrefslogtreecommitdiff
path: root/keyboard/onekey
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/onekey')
-rw-r--r--keyboard/onekey/Makefile.lufa33
-rw-r--r--keyboard/onekey/Makefile.pjrc33
-rw-r--r--keyboard/onekey/config.h86
-rw-r--r--keyboard/onekey/matrix.c1
4 files changed, 112 insertions, 41 deletions
diff --git a/keyboard/onekey/Makefile.lufa b/keyboard/onekey/Makefile.lufa
index 03cfd83a5..60a84ba00 100644
--- a/keyboard/onekey/Makefile.lufa
+++ b/keyboard/onekey/Makefile.lufa
@@ -93,7 +93,7 @@ ARCH = AVR8
93F_USB = $(F_CPU) 93F_USB = $(F_CPU)
94 94
95# Interrupt driven control endpoint task(+60) 95# Interrupt driven control endpoint task(+60)
96#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT 96OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
97 97
98 98
99# Boot Section Size in *bytes* 99# Boot Section Size in *bytes*
@@ -108,34 +108,25 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
108# Build Options 108# Build Options
109# comment out to disable the options. 109# comment out to disable the options.
110# 110#
111BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) 111#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
112MOUSEKEY_ENABLE = yes # Mouse keys(+4700) 112#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
113EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 113#EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
114CONSOLE_ENABLE = yes # Console for debug(+400) 114CONSOLE_ENABLE = yes # Console for debug(+400)
115COMMAND_ENABLE = yes # Commands for debug and configuration 115#COMMAND_ENABLE = yes # Commands for debug and configuration
116SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 116#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
117#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA 117#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
118 118
119PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
120PS2_USE_BUSYWAIT = yes # uses primitive reference code
121#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
122#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
119 123
120# Optimize size but this may cause error "relocation truncated to fit"
121#EXTRALDFLAGS = -Wl,--relax
122 124
123# Search Path 125# Search Path
124VPATH += $(TARGET_DIR) 126VPATH += $(TARGET_DIR)
125VPATH += $(TOP_DIR) 127VPATH += $(TOP_DIR)
126 128
127include $(TOP_DIR)/protocol/lufa.mk
128include $(TOP_DIR)/common.mk 129include $(TOP_DIR)/common.mk
130include $(TOP_DIR)/protocol.mk
131include $(TOP_DIR)/protocol/lufa.mk
129include $(TOP_DIR)/rules.mk 132include $(TOP_DIR)/rules.mk
130
131plain: OPT_DEFS += -DKEYMAP_PLAIN
132plain: all
133
134poker: OPT_DEFS += -DKEYMAP_POKER
135poker: all
136
137poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
138poker_set: all
139
140poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
141poker_bit: all
diff --git a/keyboard/onekey/Makefile.pjrc b/keyboard/onekey/Makefile.pjrc
index 194a2b975..24ade3350 100644
--- a/keyboard/onekey/Makefile.pjrc
+++ b/keyboard/onekey/Makefile.pjrc
@@ -79,32 +79,25 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
79# Build Options 79# Build Options
80# comment out to disable the options. 80# comment out to disable the options.
81# 81#
82BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) 82#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
83MOUSEKEY_ENABLE = yes # Mouse keys(+5000) 83#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
84EXTRAKEY_ENABLE = yes # Audio control and System control(+600) 84#EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
85CONSOLE_ENABLE = yes # Console for debug 85CONSOLE_ENABLE = yes # Console for debug
86COMMAND_ENABLE = yes # Commands for debug and configuration 86#COMMAND_ENABLE = yes # Commands for debug and configuration
87SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend 87#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
88NKRO_ENABLE = yes # USB Nkey Rollover(+500) 88#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
89#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support 89
90PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
91PS2_USE_BUSYWAIT = yes # uses primitive reference code
92#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
93#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
90 94
91 95
92# Search Path 96# Search Path
93VPATH += $(TARGET_DIR) 97VPATH += $(TARGET_DIR)
94VPATH += $(TOP_DIR) 98VPATH += $(TOP_DIR)
95 99
96include $(TOP_DIR)/protocol/pjrc.mk
97include $(TOP_DIR)/common.mk 100include $(TOP_DIR)/common.mk
101include $(TOP_DIR)/protocol.mk
102include $(TOP_DIR)/protocol/pjrc.mk
98include $(TOP_DIR)/rules.mk 103include $(TOP_DIR)/rules.mk
99
100plain: OPT_DEFS += -DKEYMAP_PLAIN
101plain: all
102
103poker: OPT_DEFS += -DKEYMAP_POKER
104poker: all
105
106poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
107poker_set: all
108
109poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
110poker_bit: all
diff --git a/keyboard/onekey/config.h b/keyboard/onekey/config.h
index c5bc64de9..1d2e052bf 100644
--- a/keyboard/onekey/config.h
+++ b/keyboard/onekey/config.h
@@ -67,4 +67,90 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67//#define NO_ACTION_MACRO 67//#define NO_ACTION_MACRO
68//#define NO_ACTION_FUNCTION 68//#define NO_ACTION_FUNCTION
69 69
70
71/* PS/2 mouse */
72#ifdef PS2_USE_BUSYWAIT
73# define PS2_CLOCK_PORT PORTD
74# define PS2_CLOCK_PIN PIND
75# define PS2_CLOCK_DDR DDRD
76# define PS2_CLOCK_BIT 5
77# define PS2_DATA_PORT PORTD
78# define PS2_DATA_PIN PIND
79# define PS2_DATA_DDR DDRD
80# define PS2_DATA_BIT 2
81#endif
82
83
84/* PS/2 mouse interrupt version */
85#ifdef PS2_USE_INT
86/* uses INT1 for clock line(ATMega32U4) */
87#define PS2_CLOCK_PORT PORTD
88#define PS2_CLOCK_PIN PIND
89#define PS2_CLOCK_DDR DDRD
90#define PS2_CLOCK_BIT 5
91#define PS2_DATA_PORT PORTD
92#define PS2_DATA_PIN PIND
93#define PS2_DATA_DDR DDRD
94#define PS2_DATA_BIT 2
95
96#define PS2_INT_INIT() do { \
97 EICRA |= ((1<<ISC11) | \
98 (0<<ISC10)); \
99} while (0)
100#define PS2_INT_ON() do { \
101 EIMSK |= (1<<INT1); \
102} while (0)
103#define PS2_INT_OFF() do { \
104 EIMSK &= ~(1<<INT1); \
105} while (0)
106#define PS2_INT_VECT INT1_vect
107#endif
108
109
110/* PS/2 mouse USART version */
111#ifdef PS2_USE_USART
112#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
113/* XCK for clock line and RXD for data line */
114#define PS2_CLOCK_PORT PORTD
115#define PS2_CLOCK_PIN PIND
116#define PS2_CLOCK_DDR DDRD
117#define PS2_CLOCK_BIT 5
118#define PS2_DATA_PORT PORTD
119#define PS2_DATA_PIN PIND
120#define PS2_DATA_DDR DDRD
121#define PS2_DATA_BIT 2
122
123/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
124/* set DDR of CLOCK as input to be slave */
125#define PS2_USART_INIT() do { \
126 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
127 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
128 UCSR1C = ((1 << UMSEL10) | \
129 (3 << UPM10) | \
130 (0 << USBS1) | \
131 (3 << UCSZ10) | \
132 (0 << UCPOL1)); \
133 UCSR1A = 0; \
134 UBRR1H = 0; \
135 UBRR1L = 0; \
136} while (0)
137#define PS2_USART_RX_INT_ON() do { \
138 UCSR1B = ((1 << RXCIE1) | \
139 (1 << RXEN1)); \
140} while (0)
141#define PS2_USART_RX_POLL_ON() do { \
142 UCSR1B = (1 << RXEN1); \
143} while (0)
144#define PS2_USART_OFF() do { \
145 UCSR1C = 0; \
146 UCSR1B &= ~((1 << RXEN1) | \
147 (1 << TXEN1)); \
148} while (0)
149#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
150#define PS2_USART_RX_DATA UDR1
151#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
152#define PS2_USART_RX_VECT USART1_RX_vect
153#endif
154#endif
155
70#endif 156#endif
diff --git a/keyboard/onekey/matrix.c b/keyboard/onekey/matrix.c
index cd0789c60..a0a14ff82 100644
--- a/keyboard/onekey/matrix.c
+++ b/keyboard/onekey/matrix.c
@@ -59,6 +59,7 @@ void matrix_init(void)
59{ 59{
60 debug_enable = true; 60 debug_enable = true;
61 debug_matrix = true; 61 debug_matrix = true;
62 debug_mouse = true;
62 // initialize row and col 63 // initialize row and col
63 unselect_rows(); 64 unselect_rows();
64 init_cols(); 65 init_cols();