From 24b725b7177b9f600ee5eea609e5f0fd67dea5b4 Mon Sep 17 00:00:00 2001 From: Tomasz Janeczko Date: Tue, 24 May 2022 13:33:28 +0100 Subject: [PATCH 1/2] Handle timeout on UART for Redox Wireless receiver-to-keyboard communication. - This fixes the issue of a keyboard deadlocking on the first matrix scan with Redox Wireless keyboards --- keyboards/redox_w/matrix.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/keyboards/redox_w/matrix.c b/keyboards/redox_w/matrix.c index fd25231d9e3c..bdf7a60ad7cb 100644 --- a/keyboards/redox_w/matrix.c +++ b/keyboards/redox_w/matrix.c @@ -18,6 +18,8 @@ #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -39,11 +41,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] = (uint8_t) 0x00; + } } //check for the end packet, the key state bytes use the LSBs, so 0xE0 From bb0dd8fb16cf37ee4ada3570dd9cc9602429770f Mon Sep 17 00:00:00 2001 From: Tomasz Janeczko Date: Tue, 7 Jun 2022 13:15:10 +0100 Subject: [PATCH 2/2] Remove an explicit cast. --- keyboards/redox_w/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/redox_w/matrix.c b/keyboards/redox_w/matrix.c index bdf7a60ad7cb..6a33e89976a5 100644 --- a/keyboards/redox_w/matrix.c +++ b/keyboards/redox_w/matrix.c @@ -49,7 +49,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { if (timeout < UART_MATRIX_RESPONSE_TIMEOUT) { uart_data[i] = uart_read(); } else { - uart_data[i] = (uint8_t) 0x00; + uart_data[i] = 0x00; } }