aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_ps2_mouse.md34
-rw-r--r--docs/ja/feature_ps2_mouse.md31
-rw-r--r--keyboards/converter/ibm_terminal/config.h33
-rw-r--r--keyboards/evyd13/gh80_3700/keymaps/ps2/config.h10
-rw-r--r--keyboards/handwired/108key_trackpoint/config.h10
-rw-r--r--keyboards/handwired/promethium/config.h30
-rw-r--r--keyboards/handwired/trackpoint/config.h10
-rwxr-xr-xkeyboards/kapcave/paladin64/config.h20
-rw-r--r--tmk_core/protocol/ps2_interrupt.c18
-rw-r--r--tmk_core/protocol/ps2_io_avr.c49
-rw-r--r--tmk_core/protocol/ps2_io_chibios.c28
-rw-r--r--tmk_core/protocol/ps2_usart.c13
12 files changed, 94 insertions, 192 deletions
diff --git a/docs/feature_ps2_mouse.md b/docs/feature_ps2_mouse.md
index 433a47fa9..c980705ae 100644
--- a/docs/feature_ps2_mouse.md
+++ b/docs/feature_ps2_mouse.md
@@ -39,14 +39,8 @@ In your keyboard config.h:
39 39
40```c 40```c
41#ifdef PS2_USE_BUSYWAIT 41#ifdef PS2_USE_BUSYWAIT
42# define PS2_CLOCK_PORT PORTD 42# define PS2_CLOCK_PIN D1
43# define PS2_CLOCK_PIN PIND 43# define PS2_DATA_PIN D2
44# define PS2_CLOCK_DDR DDRD
45# define PS2_CLOCK_BIT 1
46# define PS2_DATA_PORT PORTD
47# define PS2_DATA_PIN PIND
48# define PS2_DATA_DDR DDRD
49# define PS2_DATA_BIT 2
50#endif 44#endif
51``` 45```
52 46
@@ -65,14 +59,8 @@ In your keyboard config.h:
65 59
66```c 60```c
67#ifdef PS2_USE_INT 61#ifdef PS2_USE_INT
68#define PS2_CLOCK_PORT PORTD 62#define PS2_CLOCK_PIN D2
69#define PS2_CLOCK_PIN PIND 63#define PS2_DATA_PIN D5
70#define PS2_CLOCK_DDR DDRD
71#define PS2_CLOCK_BIT 2
72#define PS2_DATA_PORT PORTD
73#define PS2_DATA_PIN PIND
74#define PS2_DATA_DDR DDRD
75#define PS2_DATA_BIT 5
76 64
77#define PS2_INT_INIT() do { \ 65#define PS2_INT_INIT() do { \
78 EICRA |= ((1<<ISC21) | \ 66 EICRA |= ((1<<ISC21) | \
@@ -102,8 +90,8 @@ PS2_USE_INT = yes
102In your keyboard config.h: 90In your keyboard config.h:
103 91
104```c 92```c
105#define PS2_CLOCK A8 93#define PS2_CLOCK_PIN A8
106#define PS2_DATA A9 94#define PS2_DATA_PIN A9
107``` 95```
108 96
109And in the chibios specifig halconf.h: 97And in the chibios specifig halconf.h:
@@ -127,14 +115,8 @@ In your keyboard config.h:
127 115
128```c 116```c
129#ifdef PS2_USE_USART 117#ifdef PS2_USE_USART
130#define PS2_CLOCK_PORT PORTD 118#define PS2_CLOCK_PIN D5
131#define PS2_CLOCK_PIN PIND 119#define PS2_DATA_PIN D2
132#define PS2_CLOCK_DDR DDRD
133#define PS2_CLOCK_BIT 5
134#define PS2_DATA_PORT PORTD
135#define PS2_DATA_PIN PIND
136#define PS2_DATA_DDR DDRD
137#define PS2_DATA_BIT 2
138 120
139/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 121/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
140/* set DDR of CLOCK as input to be slave */ 122/* set DDR of CLOCK as input to be slave */
diff --git a/docs/ja/feature_ps2_mouse.md b/docs/ja/feature_ps2_mouse.md
index 3d6941130..569934c18 100644
--- a/docs/ja/feature_ps2_mouse.md
+++ b/docs/ja/feature_ps2_mouse.md
@@ -43,14 +43,8 @@ PS2_USE_BUSYWAIT = yes
43 43
44```c 44```c
45#ifdef PS2_USE_BUSYWAIT 45#ifdef PS2_USE_BUSYWAIT
46# define PS2_CLOCK_PORT PORTD 46# define PS2_CLOCK_PIN D1
47# define PS2_CLOCK_PIN PIND 47# define PS2_DATA_PIN D2
48# define PS2_CLOCK_DDR DDRD
49# define PS2_CLOCK_BIT 1
50# define PS2_DATA_PORT PORTD
51# define PS2_DATA_PIN PIND
52# define PS2_DATA_DDR DDRD
53# define PS2_DATA_BIT 2
54#endif 48#endif
55``` 49```
56 50
@@ -69,14 +63,8 @@ PS2_USE_INT = yes
69 63
70```c 64```c
71#ifdef PS2_USE_INT 65#ifdef PS2_USE_INT
72#define PS2_CLOCK_PORT PORTD 66#define PS2_CLOCK_PIN D2
73#define PS2_CLOCK_PIN PIND 67#define PS2_DATA_PIN D5
74#define PS2_CLOCK_DDR DDRD
75#define PS2_CLOCK_BIT 2
76#define PS2_DATA_PORT PORTD
77#define PS2_DATA_PIN PIND
78#define PS2_DATA_DDR DDRD
79#define PS2_DATA_BIT 5
80 68
81#define PS2_INT_INIT() do { \ 69#define PS2_INT_INIT() do { \
82 EICRA |= ((1<<ISC21) | \ 70 EICRA |= ((1<<ISC21) | \
@@ -107,14 +95,9 @@ PS2_USE_USART = yes
107 95
108```c 96```c
109#ifdef PS2_USE_USART 97#ifdef PS2_USE_USART
110#define PS2_CLOCK_PORT PORTD 98#ifdef PS2_USE_USART
111#define PS2_CLOCK_PIN PIND 99#define PS2_CLOCK_PIN D5
112#define PS2_CLOCK_DDR DDRD 100#define PS2_DATA_PIN D2
113#define PS2_CLOCK_BIT 5
114#define PS2_DATA_PORT PORTD
115#define PS2_DATA_PIN PIND
116#define PS2_DATA_DDR DDRD
117#define PS2_DATA_BIT 2
118 101
119/* 同期、奇数パリティ、1-bit ストップ、8-bit データ、立ち下がりエッジでサンプル */ 102/* 同期、奇数パリティ、1-bit ストップ、8-bit データ、立ち下がりエッジでサンプル */
120/* CLOCK の DDR を入力としてスレーブに設定 */ 103/* CLOCK の DDR を入力としてスレーブに設定 */
diff --git a/keyboards/converter/ibm_terminal/config.h b/keyboards/converter/ibm_terminal/config.h
index 6895f08e7..2cd36c5fb 100644
--- a/keyboards/converter/ibm_terminal/config.h
+++ b/keyboards/converter/ibm_terminal/config.h
@@ -45,15 +45,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
45 */ 45 */
46#ifdef PS2_USE_USART 46#ifdef PS2_USE_USART
47/* XCK for clock line */ 47/* XCK for clock line */
48#define PS2_CLOCK_PORT PORTD 48#define PS2_CLOCK_PIN D5
49#define PS2_CLOCK_PIN PIND 49#define PS2_DATA_PIN D2
50#define PS2_CLOCK_DDR DDRD
51#define PS2_CLOCK_BIT 5
52/* RXD for data line */
53#define PS2_DATA_PORT PORTD
54#define PS2_DATA_PIN PIND
55#define PS2_DATA_DDR DDRD
56#define PS2_DATA_BIT 2
57 50
58/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 51/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
59/* set DDR of CLOCK as input to be slave */ 52/* set DDR of CLOCK as input to be slave */
@@ -93,15 +86,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
93 */ 86 */
94#ifdef PS2_USE_INT 87#ifdef PS2_USE_INT
95/* uses INT1 for clock line(ATMega32U4) */ 88/* uses INT1 for clock line(ATMega32U4) */
96#define PS2_CLOCK_PORT PORTD 89#define PS2_CLOCK_PIN D1
97#define PS2_CLOCK_PIN PIND 90#define PS2_DATA_PIN D0
98#define PS2_CLOCK_DDR DDRD
99#define PS2_CLOCK_BIT 1
100
101#define PS2_DATA_PORT PORTD
102#define PS2_DATA_PIN PIND
103#define PS2_DATA_DDR DDRD
104#define PS2_DATA_BIT 0
105 91
106#define PS2_INT_INIT() do { \ 92#define PS2_INT_INIT() do { \
107 EICRA |= ((1<<ISC11) | \ 93 EICRA |= ((1<<ISC11) | \
@@ -121,13 +107,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
121 * PS/2 Busywait configuration 107 * PS/2 Busywait configuration
122 */ 108 */
123#ifdef PS2_USE_BUSYWAIT 109#ifdef PS2_USE_BUSYWAIT
124#define PS2_CLOCK_PORT PORTD 110#define PS2_CLOCK_PIN D1
125#define PS2_CLOCK_PIN PIND 111#define PS2_DATA_PIN D0
126#define PS2_CLOCK_DDR DDRD
127#define PS2_CLOCK_BIT 1
128
129#define PS2_DATA_PORT PORTD
130#define PS2_DATA_PIN PIND
131#define PS2_DATA_DDR DDRD
132#define PS2_DATA_BIT 0
133#endif 112#endif
diff --git a/keyboards/evyd13/gh80_3700/keymaps/ps2/config.h b/keyboards/evyd13/gh80_3700/keymaps/ps2/config.h
index 44ac7dcd0..b77ac95d7 100644
--- a/keyboards/evyd13/gh80_3700/keymaps/ps2/config.h
+++ b/keyboards/evyd13/gh80_3700/keymaps/ps2/config.h
@@ -17,14 +17,8 @@
17#pragma once 17#pragma once
18 18
19#ifdef PS2_USE_USART 19#ifdef PS2_USE_USART
20#define PS2_CLOCK_PORT PORTD 20#define PS2_CLOCK_PIN D5
21#define PS2_CLOCK_PIN PIND 21#define PS2_DATA_PIN D2
22#define PS2_CLOCK_DDR DDRD
23#define PS2_CLOCK_BIT 5
24#define PS2_DATA_PORT PORTD
25#define PS2_DATA_PIN PIND
26#define PS2_DATA_DDR DDRD
27#define PS2_DATA_BIT 2
28 22
29/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 23/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
30/* set DDR of CLOCK as input to be slave */ 24/* set DDR of CLOCK as input to be slave */
diff --git a/keyboards/handwired/108key_trackpoint/config.h b/keyboards/handwired/108key_trackpoint/config.h
index b1ac790d7..b5bf98271 100644
--- a/keyboards/handwired/108key_trackpoint/config.h
+++ b/keyboards/handwired/108key_trackpoint/config.h
@@ -12,14 +12,8 @@
12#define MATRIX_COLS 23 12#define MATRIX_COLS 23
13 13
14#ifdef PS2_USE_USART 14#ifdef PS2_USE_USART
15 #define PS2_CLOCK_PORT PORTD 15#define PS2_CLOCK_PIN D5
16 #define PS2_CLOCK_PIN PIND 16#define PS2_DATA_PIN D2
17 #define PS2_CLOCK_DDR DDRD
18 #define PS2_CLOCK_BIT 5
19 #define PS2_DATA_PORT PORTD
20 #define PS2_DATA_PIN PIND
21 #define PS2_DATA_DDR DDRD
22 #define PS2_DATA_BIT 2
23 17
24 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 18 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
25 /* set DDR of CLOCK as input to be slave */ 19 /* set DDR of CLOCK as input to be slave */
diff --git a/keyboards/handwired/promethium/config.h b/keyboards/handwired/promethium/config.h
index b146767d6..612675c63 100644
--- a/keyboards/handwired/promethium/config.h
+++ b/keyboards/handwired/promethium/config.h
@@ -224,27 +224,15 @@ enum led_sequence {
224 224
225/* PS/2 mouse */ 225/* PS/2 mouse */
226#ifdef PS2_USE_BUSYWAIT 226#ifdef PS2_USE_BUSYWAIT
227# define PS2_CLOCK_PORT PORTD 227# define PS2_CLOCK_PIN D3
228# define PS2_CLOCK_PIN PIND 228# define PS2_DATA_PIN D2
229# define PS2_CLOCK_DDR DDRD
230# define PS2_CLOCK_BIT 3
231# define PS2_DATA_PORT PORTD
232# define PS2_DATA_PIN PIND
233# define PS2_DATA_DDR DDRD
234# define PS2_DATA_BIT 2
235#endif 229#endif
236 230
237/* PS/2 mouse interrupt version */ 231/* PS/2 mouse interrupt version */
238#ifdef PS2_USE_INT 232#ifdef PS2_USE_INT
239/* uses INT1 for clock line(ATMega32U4) */ 233/* uses INT1 for clock line(ATMega32U4) */
240# define PS2_CLOCK_PORT PORTD 234# define PS2_CLOCK_PIN D3
241# define PS2_CLOCK_PIN PIND 235# define PS2_DATA_PIN D2
242# define PS2_CLOCK_DDR DDRD
243# define PS2_CLOCK_BIT 3
244# define PS2_DATA_PORT PORTD
245# define PS2_DATA_PIN PIND
246# define PS2_DATA_DDR DDRD
247# define PS2_DATA_BIT 2
248 236
249# define PS2_INT_INIT() \ 237# define PS2_INT_INIT() \
250 do { \ 238 do { \
@@ -264,14 +252,8 @@ enum led_sequence {
264/* PS/2 mouse USART version */ 252/* PS/2 mouse USART version */
265#ifdef PS2_USE_USART 253#ifdef PS2_USE_USART
266/* XCK for clock line and RXD for data line */ 254/* XCK for clock line and RXD for data line */
267# define PS2_CLOCK_PORT PORTD 255#define PS2_CLOCK_PIN D5
268# define PS2_CLOCK_PIN PIND 256#define PS2_DATA_PIN D2
269# define PS2_CLOCK_DDR DDRD
270# define PS2_CLOCK_BIT 5
271# define PS2_DATA_PORT PORTD
272# define PS2_DATA_PIN PIND
273# define PS2_DATA_DDR DDRD
274# define PS2_DATA_BIT 2
275 257
276/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 258/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
277/* set DDR of CLOCK as input to be slave */ 259/* set DDR of CLOCK as input to be slave */
diff --git a/keyboards/handwired/trackpoint/config.h b/keyboards/handwired/trackpoint/config.h
index 1429136f4..cf8b5605f 100644
--- a/keyboards/handwired/trackpoint/config.h
+++ b/keyboards/handwired/trackpoint/config.h
@@ -12,14 +12,8 @@
12#define MATRIX_COLS 3 12#define MATRIX_COLS 3
13 13
14#ifdef PS2_USE_USART 14#ifdef PS2_USE_USART
15 #define PS2_CLOCK_PORT PORTD 15#define PS2_CLOCK_PIN D5
16 #define PS2_CLOCK_PIN PIND 16#define PS2_DATA_PIN D2
17 #define PS2_CLOCK_DDR DDRD
18 #define PS2_CLOCK_BIT 5
19 #define PS2_DATA_PORT PORTD
20 #define PS2_DATA_PIN PIND
21 #define PS2_DATA_DDR DDRD
22 #define PS2_DATA_BIT 2
23 17
24 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 18 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
25 /* set DDR of CLOCK as input to be slave */ 19 /* set DDR of CLOCK as input to be slave */
diff --git a/keyboards/kapcave/paladin64/config.h b/keyboards/kapcave/paladin64/config.h
index 2685be96c..7c3d1a0fa 100755
--- a/keyboards/kapcave/paladin64/config.h
+++ b/keyboards/kapcave/paladin64/config.h
@@ -34,14 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
34 34
35/* Only required if you add in a trackpoint hardware to the pcb */ 35/* Only required if you add in a trackpoint hardware to the pcb */
36#ifdef PS2_USE_USART 36#ifdef PS2_USE_USART
37 #define PS2_CLOCK_PORT PORTD 37#define PS2_CLOCK_PIN D5
38 #define PS2_CLOCK_PIN PIND 38#define PS2_DATA_PIN D2
39 #define PS2_CLOCK_DDR DDRD
40 #define PS2_CLOCK_BIT 5
41 #define PS2_DATA_PORT PORTD
42 #define PS2_DATA_PIN PIND
43 #define PS2_DATA_DDR DDRD
44 #define PS2_DATA_BIT 2
45 39
46 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling 40 /* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling
47 * edge */ 41 * edge */
@@ -77,14 +71,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
77#endif 71#endif
78 72
79#ifdef PS2_USE_INT 73#ifdef PS2_USE_INT
80#define PS2_CLOCK_PORT PORTD 74#define PS2_CLOCK_PIN D2
81#define PS2_CLOCK_PIN PIND 75#define PS2_DATA_PIN D5
82#define PS2_CLOCK_DDR DDRD
83#define PS2_CLOCK_BIT 2
84#define PS2_DATA_PORT PORTD
85#define PS2_DATA_PIN PIND
86#define PS2_DATA_DDR DDRD
87#define PS2_DATA_BIT 5
88 76
89 #define PS2_INT_INIT() do { \ 77 #define PS2_INT_INIT() do { \
90 EICRA |= ((1<<ISC21) | \ 78 EICRA |= ((1<<ISC21) | \
diff --git a/tmk_core/protocol/ps2_interrupt.c b/tmk_core/protocol/ps2_interrupt.c
index 780040d15..70debd02f 100644
--- a/tmk_core/protocol/ps2_interrupt.c
+++ b/tmk_core/protocol/ps2_interrupt.c
@@ -73,17 +73,17 @@ static inline void pbuf_clear(void);
73void ps2_interrupt_service_routine(void); 73void ps2_interrupt_service_routine(void);
74void palCallback(void *arg) { ps2_interrupt_service_routine(); } 74void palCallback(void *arg) { ps2_interrupt_service_routine(); }
75 75
76# define PS2_INT_INIT() \ 76# define PS2_INT_INIT() \
77 { palSetLineMode(PS2_CLOCK, PAL_MODE_INPUT); } \ 77 { palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT); } \
78 while (0) 78 while (0)
79# define PS2_INT_ON() \ 79# define PS2_INT_ON() \
80 { \ 80 { \
81 palEnableLineEvent(PS2_CLOCK, PAL_EVENT_MODE_FALLING_EDGE); \ 81 palEnableLineEvent(PS2_CLOCK_PIN, PAL_EVENT_MODE_FALLING_EDGE); \
82 palSetLineCallback(PS2_CLOCK, palCallback, NULL); \ 82 palSetLineCallback(PS2_CLOCK_PIN, palCallback, NULL); \
83 } \ 83 } \
84 while (0) 84 while (0)
85# define PS2_INT_OFF() \ 85# define PS2_INT_OFF() \
86 { palDisableLineEvent(PS2_CLOCK); } \ 86 { palDisableLineEvent(PS2_CLOCK_PIN); } \
87 while (0) 87 while (0)
88#endif // PROTOCOL_CHIBIOS 88#endif // PROTOCOL_CHIBIOS
89 89
diff --git a/tmk_core/protocol/ps2_io_avr.c b/tmk_core/protocol/ps2_io_avr.c
index a9ac5d338..7c826fbf1 100644
--- a/tmk_core/protocol/ps2_io_avr.c
+++ b/tmk_core/protocol/ps2_io_avr.c
@@ -1,14 +1,15 @@
1#include <stdbool.h> 1#include <stdbool.h>
2#include <avr/io.h> 2#include "ps2_io.h"
3#include <util/delay.h> 3#include "gpio.h"
4#include "wait.h"
4 5
5/* Check port settings for clock and data line */ 6/* Check port settings for clock and data line */
6#if !(defined(PS2_CLOCK_PORT) && defined(PS2_CLOCK_PIN) && defined(PS2_CLOCK_DDR) && defined(PS2_CLOCK_BIT)) 7#if !(defined(PS2_CLOCK_PIN))
7# error "PS/2 clock port setting is required in config.h" 8# error "PS/2 clock setting is required in config.h"
8#endif 9#endif
9 10
10#if !(defined(PS2_DATA_PORT) && defined(PS2_DATA_PIN) && defined(PS2_DATA_DDR) && defined(PS2_DATA_BIT)) 11#if !(defined(PS2_DATA_PIN))
11# error "PS/2 data port setting is required in config.h" 12# error "PS/2 data setting is required in config.h"
12#endif 13#endif
13 14
14/* 15/*
@@ -17,21 +18,17 @@
17void clock_init(void) {} 18void clock_init(void) {}
18 19
19void clock_lo(void) { 20void clock_lo(void) {
20 PS2_CLOCK_PORT &= ~(1 << PS2_CLOCK_BIT); 21 // Transition from input with pull-up to output low via Hi-Z instead of output high
21 PS2_CLOCK_DDR |= (1 << PS2_CLOCK_BIT); 22 writePinLow(PS2_CLOCK_PIN);
23 setPinOutput(PS2_CLOCK_PIN);
22} 24}
23 25
24void clock_hi(void) { 26void clock_hi(void) { setPinInputHigh(PS2_CLOCK_PIN); }
25 /* input with pull up */
26 PS2_CLOCK_DDR &= ~(1 << PS2_CLOCK_BIT);
27 PS2_CLOCK_PORT |= (1 << PS2_CLOCK_BIT);
28}
29 27
30bool clock_in(void) { 28bool clock_in(void) {
31 PS2_CLOCK_DDR &= ~(1 << PS2_CLOCK_BIT); 29 setPinInputHigh(PS2_CLOCK_PIN);
32 PS2_CLOCK_PORT |= (1 << PS2_CLOCK_BIT); 30 wait_us(1);
33 _delay_us(1); 31 return readPin(PS2_CLOCK_PIN);
34 return PS2_CLOCK_PIN & (1 << PS2_CLOCK_BIT);
35} 32}
36 33
37/* 34/*
@@ -40,19 +37,15 @@ bool clock_in(void) {
40void data_init(void) {} 37void data_init(void) {}
41 38
42void data_lo(void) { 39void data_lo(void) {
43 PS2_DATA_PORT &= ~(1 << PS2_DATA_BIT); 40 // Transition from input with pull-up to output low via Hi-Z instead of output high
44 PS2_DATA_DDR |= (1 << PS2_DATA_BIT); 41 writePinLow(PS2_DATA_PIN);
42 setPinOutput(PS2_DATA_PIN);
45} 43}
46 44
47void data_hi(void) { 45void data_hi(void) { setPinInputHigh(PS2_DATA_PIN); }
48 /* input with pull up */
49 PS2_DATA_DDR &= ~(1 << PS2_DATA_BIT);
50 PS2_DATA_PORT |= (1 << PS2_DATA_BIT);
51}
52 46
53bool data_in(void) { 47bool data_in(void) {
54 PS2_DATA_DDR &= ~(1 << PS2_DATA_BIT); 48 setPinInputHigh(PS2_DATA_PIN);
55 PS2_DATA_PORT |= (1 << PS2_DATA_BIT); 49 wait_us(1);
56 _delay_us(1); 50 return readPin(PS2_DATA_PIN);
57 return PS2_DATA_PIN & (1 << PS2_DATA_BIT);
58} 51}
diff --git a/tmk_core/protocol/ps2_io_chibios.c b/tmk_core/protocol/ps2_io_chibios.c
index b672bd1f4..906d85d84 100644
--- a/tmk_core/protocol/ps2_io_chibios.c
+++ b/tmk_core/protocol/ps2_io_chibios.c
@@ -6,11 +6,11 @@
6#include "hal.h" 6#include "hal.h"
7 7
8/* Check port settings for clock and data line */ 8/* Check port settings for clock and data line */
9#if !(defined(PS2_CLOCK)) 9#if !(defined(PS2_CLOCK_PIN))
10# error "PS/2 clock setting is required in config.h" 10# error "PS/2 clock setting is required in config.h"
11#endif 11#endif
12 12
13#if !(defined(PS2_DATA)) 13#if !(defined(PS2_DATA_PIN))
14# error "PS/2 data setting is required in config.h" 14# error "PS/2 data setting is required in config.h"
15#endif 15#endif
16 16
@@ -20,18 +20,18 @@
20void clock_init(void) {} 20void clock_init(void) {}
21 21
22void clock_lo(void) { 22void clock_lo(void) {
23 palSetLineMode(PS2_CLOCK, PAL_MODE_OUTPUT_OPENDRAIN); 23 palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_OUTPUT_OPENDRAIN);
24 palWriteLine(PS2_CLOCK, PAL_LOW); 24 palWriteLine(PS2_CLOCK_PIN, PAL_LOW);
25} 25}
26 26
27void clock_hi(void) { 27void clock_hi(void) {
28 palSetLineMode(PS2_CLOCK, PAL_MODE_OUTPUT_OPENDRAIN); 28 palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_OUTPUT_OPENDRAIN);
29 palWriteLine(PS2_CLOCK, PAL_HIGH); 29 palWriteLine(PS2_CLOCK_PIN, PAL_HIGH);
30} 30}
31 31
32bool clock_in(void) { 32bool clock_in(void) {
33 palSetLineMode(PS2_CLOCK, PAL_MODE_INPUT); 33 palSetLineMode(PS2_CLOCK_PIN, PAL_MODE_INPUT);
34 return palReadLine(PS2_CLOCK); 34 return palReadLine(PS2_CLOCK_PIN);
35} 35}
36 36
37/* 37/*
@@ -40,16 +40,16 @@ bool clock_in(void) {
40void data_init(void) {} 40void data_init(void) {}
41 41
42void data_lo(void) { 42void data_lo(void) {
43 palSetLineMode(PS2_DATA, PAL_MODE_OUTPUT_OPENDRAIN); 43 palSetLineMode(PS2_DATA_PIN, PAL_MODE_OUTPUT_OPENDRAIN);
44 palWriteLine(PS2_DATA, PAL_LOW); 44 palWriteLine(PS2_DATA_PIN, PAL_LOW);
45} 45}
46 46
47void data_hi(void) { 47void data_hi(void) {
48 palSetLineMode(PS2_DATA, PAL_MODE_OUTPUT_OPENDRAIN); 48 palSetLineMode(PS2_DATA_PIN, PAL_MODE_OUTPUT_OPENDRAIN);
49 palWriteLine(PS2_DATA, PAL_HIGH); 49 palWriteLine(PS2_DATA_PIN, PAL_HIGH);
50} 50}
51 51
52bool data_in(void) { 52bool data_in(void) {
53 palSetLineMode(PS2_DATA, PAL_MODE_INPUT); 53 palSetLineMode(PS2_DATA_PIN, PAL_MODE_INPUT);
54 return palReadLine(PS2_DATA); 54 return palReadLine(PS2_DATA_PIN);
55} 55}
diff --git a/tmk_core/protocol/ps2_usart.c b/tmk_core/protocol/ps2_usart.c
index 6a66dc4a1..5f7008369 100644
--- a/tmk_core/protocol/ps2_usart.c
+++ b/tmk_core/protocol/ps2_usart.c
@@ -46,6 +46,19 @@ POSSIBILITY OF SUCH DAMAGE.
46#include "ps2_io.h" 46#include "ps2_io.h"
47#include "print.h" 47#include "print.h"
48 48
49#ifndef PS2_CLOCK_DDR
50# define PS2_CLOCK_DDR PORTx_ADDRESS(PS2_CLOCK_PIN)
51#endif
52#ifndef PS2_CLOCK_BIT
53# define PS2_CLOCK_BIT (PS2_CLOCK_PIN & 0xF)
54#endif
55#ifndef PS2_DATA_DDR
56# define PS2_DATA_DDR PORTx_ADDRESS(PS2_DATA_PIN)
57#endif
58#ifndef PS2_DATA_BIT
59# define PS2_DATA_BIT (PS2_DATA_PIN & 0xF)
60#endif
61
49#define WAIT(stat, us, err) \ 62#define WAIT(stat, us, err) \
50 do { \ 63 do { \
51 if (!wait_##stat(us)) { \ 64 if (!wait_##stat(us)) { \