aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-11-26 14:31:57 +0900
committertmk <nobody@nowhere>2013-11-26 14:31:57 +0900
commit9d26053f1c14da79336a64f800305660d1a71180 (patch)
treefd65dae1bf3965b8262d1b55bb0185b11241e77f
parent9ae9742ac59b18cf989370f53d669daeb75bd7a3 (diff)
downloadqmk_firmware-9d26053f1c14da79336a64f800305660d1a71180.tar.gz
qmk_firmware-9d26053f1c14da79336a64f800305660d1a71180.zip
Fix ps2_host_recv_response
-rw-r--r--common/print.h4
-rw-r--r--converter/ps2_usb/matrix.c10
-rw-r--r--protocol/ps2_busywait.c11
3 files changed, 12 insertions, 13 deletions
diff --git a/common/print.h b/common/print.h
index a828328b6..930e84be9 100644
--- a/common/print.h
+++ b/common/print.h
@@ -40,10 +40,6 @@
40#endif 40#endif
41#define println(s) print_P(PSTR(s "\n")) 41#define println(s) print_P(PSTR(s "\n"))
42 42
43#ifndef AVR_LIBC_PRINTF
44#define printf(f, ...) xprintf(f, ##__VA_ARGS__)
45#endif
46
47/* for old name */ 43/* for old name */
48#define pdec(data) print_dec(data) 44#define pdec(data) print_dec(data)
49#define pdec16(data) print_dec(data) 45#define pdec16(data) print_dec(data)
diff --git a/converter/ps2_usb/matrix.c b/converter/ps2_usb/matrix.c
index a4c27f5d5..aa0c38c68 100644
--- a/converter/ps2_usb/matrix.c
+++ b/converter/ps2_usb/matrix.c
@@ -217,7 +217,7 @@ uint8_t matrix_scan(void)
217 if (code < 0x80) { 217 if (code < 0x80) {
218 matrix_make(code); 218 matrix_make(code);
219 } else { 219 } else {
220 printf("unexpected scan code at INIT: %02X\n", code); 220 xprintf("unexpected scan code at INIT: %02X\n", code);
221 clear_keyboard(); 221 clear_keyboard();
222 } 222 }
223 state = INIT; 223 state = INIT;
@@ -239,7 +239,7 @@ uint8_t matrix_scan(void)
239 if (code < 0x80) { 239 if (code < 0x80) {
240 matrix_make(code|0x80); 240 matrix_make(code|0x80);
241 } else { 241 } else {
242 printf("unexpected scan code at E0: %02X\n", code); 242 xprintf("unexpected scan code at E0: %02X\n", code);
243 clear_keyboard(); 243 clear_keyboard();
244 } 244 }
245 state = INIT; 245 state = INIT;
@@ -259,7 +259,7 @@ uint8_t matrix_scan(void)
259 if (code < 0x80) { 259 if (code < 0x80) {
260 matrix_break(code); 260 matrix_break(code);
261 } else { 261 } else {
262 printf("unexpected scan code at F0: %02X\n", code); 262 xprintf("unexpected scan code at F0: %02X\n", code);
263 clear_keyboard(); 263 clear_keyboard();
264 } 264 }
265 state = INIT; 265 state = INIT;
@@ -275,7 +275,7 @@ uint8_t matrix_scan(void)
275 if (code < 0x80) { 275 if (code < 0x80) {
276 matrix_break(code|0x80); 276 matrix_break(code|0x80);
277 } else { 277 } else {
278 printf("unexpected scan code at E0_F0: %02X\n", code); 278 xprintf("unexpected scan code at E0_F0: %02X\n", code);
279 clear_keyboard(); 279 clear_keyboard();
280 } 280 }
281 state = INIT; 281 state = INIT;
@@ -371,7 +371,7 @@ uint8_t matrix_scan(void)
371 371
372 if (ps2_error > PS2_ERR_STARTBIT3) { 372 if (ps2_error > PS2_ERR_STARTBIT3) {
373 uint8_t ret = ps2_host_send(PS2_RESEND); 373 uint8_t ret = ps2_host_send(PS2_RESEND);
374 printf("Resend: %02X\n", ret); 374 xprintf("Resend: %02X\n", ret);
375 } 375 }
376 return 1; 376 return 1;
377} 377}
diff --git a/protocol/ps2_busywait.c b/protocol/ps2_busywait.c
index 1e2925889..5ab377877 100644
--- a/protocol/ps2_busywait.c
+++ b/protocol/ps2_busywait.c
@@ -104,6 +104,7 @@ uint8_t ps2_host_send(uint8_t data)
104 WAIT(clock_hi, 50, 8); 104 WAIT(clock_hi, 50, 8);
105 WAIT(data_hi, 50, 9); 105 WAIT(data_hi, 50, 9);
106 106
107 inhibit();
107 res = ps2_host_recv_response(); 108 res = ps2_host_recv_response();
108ERROR: 109ERROR:
109 inhibit(); 110 inhibit();
@@ -113,12 +114,14 @@ ERROR:
113/* receive data when host want else inhibit communication */ 114/* receive data when host want else inhibit communication */
114uint8_t ps2_host_recv_response(void) 115uint8_t ps2_host_recv_response(void)
115{ 116{
116 // TODO:
117 // Command might take 20ms to response([3]p.21) 117 // Command might take 20ms to response([3]p.21)
118 // TrackPoint might take 25ms ([5]2.7) 118 // TrackPoint might take 25ms ([5]2.7)
119 // 250 * 100us(wait for start bit in ps2_host_recv)
119 uint8_t data = 0; 120 uint8_t data = 0;
120 uint8_t try = 200; 121 uint8_t try = 250;
121 while (try-- && (data = ps2_host_recv())) ; 122 do {
123 data = ps2_host_recv();
124 } while (try-- && ps2_error);
122 return data; 125 return data;
123} 126}
124 127
@@ -172,7 +175,7 @@ uint8_t ps2_host_recv(void)
172 return data; 175 return data;
173ERROR: 176ERROR:
174 if (ps2_error > PS2_ERR_STARTBIT3) { 177 if (ps2_error > PS2_ERR_STARTBIT3) {
175 printf("x%02X\n", ps2_error); 178 xprintf("x%02X\n", ps2_error);
176 } 179 }
177 inhibit(); 180 inhibit();
178 return 0; 181 return 0;