Skip to content

Commit

Permalink
[Keyboard] Handle timeout on UART for Redox Wireless (qmk#17203)
Browse files Browse the repository at this point in the history
* 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

* Remove an explicit cast.

Co-authored-by: Tomasz Janeczko <[email protected]>
  • Loading branch information
2 people authored and ModProg committed Jul 1, 2022
1 parent f032cc7 commit c2ad7f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions keyboards/redox_w/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "matrix.h"
#include "uart.h"

#define UART_MATRIX_RESPONSE_TIMEOUT 10000

void matrix_init_custom(void) {
uart_init(1000000);
}
Expand All @@ -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] = 0x00;
}
}

//check for the end packet, the key state bytes use the LSBs, so 0xE0
Expand Down

0 comments on commit c2ad7f5

Please sign in to comment.