diff options
Diffstat (limited to 'keyboards/mitosis')
-rw-r--r-- | keyboards/mitosis/matrix.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/keyboards/mitosis/matrix.c b/keyboards/mitosis/matrix.c index a92c3e8431..e5389bb113 100644 --- a/keyboards/mitosis/matrix.c +++ b/keyboards/mitosis/matrix.c @@ -20,6 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "matrix.h" #include "uart.h" +#define UART_MATRIX_RESPONSE_TIMEOUT 10000 + void matrix_init_custom(void) { uart_init(1000000); } @@ -34,18 +36,23 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { //trust the external keystates entirely, erase the last data uint8_t uart_data[11] = {0}; - //there are 10 bytes corresponding to 10 columns, and an end byte + //there are 10 bytes corresponding to 10 columns, and then an end byte for (uint8_t i = 0; i < 11; i++) { //wait for the serial data, timeout if it's been too long //this only happened in testing with a loose wire, but does no //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 |