summaryrefslogtreecommitdiff
path: root/keyboards/sirius/uni660
diff options
context:
space:
mode:
authorTomasz Janeczko <janecztom@gmail.com>2022-06-08 22:51:41 +0100
committerGitHub <noreply@github.com>2022-06-08 14:51:41 -0700
commit6567b2168881ce8c47e38debcdc89eba1ac80c5a (patch)
tree12326ddd1ce2ee0da1cd8ae1063b35223e05f479 /keyboards/sirius/uni660
parentf6a7bf2a833b588476cd04c13c6b7a65c6305024 (diff)
Move more UART-based keyboards to use timeout correctly. (#17329)
Co-authored-by: Tomasz Janeczko <tomasz.j@hey.com>
Diffstat (limited to 'keyboards/sirius/uni660')
-rw-r--r--keyboards/sirius/uni660/rev1/matrix.c11
-rw-r--r--keyboards/sirius/uni660/rev2/matrix.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/keyboards/sirius/uni660/rev1/matrix.c b/keyboards/sirius/uni660/rev1/matrix.c
index 919db5c80d..f65bf0f26a 100644
--- a/keyboards/sirius/uni660/rev1/matrix.c
+++ b/keyboards/sirius/uni660/rev1/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);
}
@@ -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/sirius/uni660/rev2/matrix.c b/keyboards/sirius/uni660/rev2/matrix.c
index 919db5c80d..f65bf0f26a 100644
--- a/keyboards/sirius/uni660/rev2/matrix.c
+++ b/keyboards/sirius/uni660/rev2/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);
}
@@ -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