[Keyboard] Handle timeout on UART for Redox Wireless (#17203)

* 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 <tomasz.j@hey.com>
master
Tomasz Janeczko 2022-06-07 19:22:13 +01:00 committed by GitHub
parent 5d767f8361
commit c681b6dbf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -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;
}
}
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