From 6567b2168881ce8c47e38debcdc89eba1ac80c5a Mon Sep 17 00:00:00 2001 From: Tomasz Janeczko Date: Wed, 8 Jun 2022 22:51:41 +0100 Subject: Move more UART-based keyboards to use timeout correctly. (#17329) Co-authored-by: Tomasz Janeczko --- keyboards/glenpickle/chimera_ergo/matrix.c | 11 +++++++++-- keyboards/glenpickle/chimera_ls/matrix.c | 11 +++++++++-- keyboards/glenpickle/chimera_ortho/matrix.c | 11 +++++++++-- keyboards/glenpickle/chimera_ortho_plus/matrix.c | 11 +++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) (limited to 'keyboards/glenpickle') diff --git a/keyboards/glenpickle/chimera_ergo/matrix.c b/keyboards/glenpickle/chimera_ergo/matrix.c index 603ad0f386..32d7b09310 100644 --- a/keyboards/glenpickle/chimera_ergo/matrix.c +++ b/keyboards/glenpickle/chimera_ergo/matrix.c @@ -20,6 +20,8 @@ along with this program. If not, see . #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -41,11 +43,16 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { //harm to leave it in here while (!uart_available()) { timeout++; - if (timeout > 10000) { + if (timeout > UART_MATRIX_RESPONSE_TIMEOUT) { break; } } - uart_data[i] = uart_read(); + + if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) { + uart_data[i] = uart_read(); + } else { + uart_data[i] = 0x00; + } } //check for the end packet, the key state bytes use the LSBs, so 0xE0 diff --git a/keyboards/glenpickle/chimera_ls/matrix.c b/keyboards/glenpickle/chimera_ls/matrix.c index a92c3e8431..9a69724eb7 100644 --- a/keyboards/glenpickle/chimera_ls/matrix.c +++ b/keyboards/glenpickle/chimera_ls/matrix.c @@ -20,6 +20,8 @@ along with this program. If not, see . #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -41,11 +43,16 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { //harm to leave it in here while (!uart_available()) { timeout++; - if (timeout > 10000) { + if (timeout > UART_MATRIX_RESPONSE_TIMEOUT) { break; } } - uart_data[i] = uart_read(); + + if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) { + uart_data[i] = uart_read(); + } else { + uart_data[i] = 0x00; + } } //check for the end packet, the key state bytes use the LSBs, so 0xE0 diff --git a/keyboards/glenpickle/chimera_ortho/matrix.c b/keyboards/glenpickle/chimera_ortho/matrix.c index a92c3e8431..9a69724eb7 100644 --- a/keyboards/glenpickle/chimera_ortho/matrix.c +++ b/keyboards/glenpickle/chimera_ortho/matrix.c @@ -20,6 +20,8 @@ along with this program. If not, see . #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -41,11 +43,16 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { //harm to leave it in here while (!uart_available()) { timeout++; - if (timeout > 10000) { + if (timeout > UART_MATRIX_RESPONSE_TIMEOUT) { break; } } - uart_data[i] = uart_read(); + + if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) { + uart_data[i] = uart_read(); + } else { + uart_data[i] = 0x00; + } } //check for the end packet, the key state bytes use the LSBs, so 0xE0 diff --git a/keyboards/glenpickle/chimera_ortho_plus/matrix.c b/keyboards/glenpickle/chimera_ortho_plus/matrix.c index 603ad0f386..32d7b09310 100644 --- a/keyboards/glenpickle/chimera_ortho_plus/matrix.c +++ b/keyboards/glenpickle/chimera_ortho_plus/matrix.c @@ -20,6 +20,8 @@ along with this program. If not, see . #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -41,11 +43,16 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { //harm to leave it in here while (!uart_available()) { timeout++; - if (timeout > 10000) { + if (timeout > UART_MATRIX_RESPONSE_TIMEOUT) { break; } } - uart_data[i] = uart_read(); + + if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) { + uart_data[i] = uart_read(); + } else { + uart_data[i] = 0x00; + } } //check for the end packet, the key state bytes use the LSBs, so 0xE0 -- cgit v1.2.3