summaryrefslogtreecommitdiff
path: root/keyboards/dichotomy
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/dichotomy
parentf6a7bf2a833b588476cd04c13c6b7a65c6305024 (diff)
downloadqmk_firmware-6567b2168881ce8c47e38debcdc89eba1ac80c5a.tar.gz
qmk_firmware-6567b2168881ce8c47e38debcdc89eba1ac80c5a.zip
Move more UART-based keyboards to use timeout correctly. (#17329)
Co-authored-by: Tomasz Janeczko <tomasz.j@hey.com>
Diffstat (limited to 'keyboards/dichotomy')
-rwxr-xr-xkeyboards/dichotomy/matrix.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/keyboards/dichotomy/matrix.c b/keyboards/dichotomy/matrix.c
index dc90e7501e..0799554f0a 100755
--- a/keyboards/dichotomy/matrix.c
+++ b/keyboards/dichotomy/matrix.c
@@ -48,6 +48,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MAIN_ROWMASK 0xFFF0;
#define LOWER_ROWMASK 0x3FC0;
+#define UART_MATRIX_RESPONSE_TIMEOUT 10000
+
/* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS];
@@ -96,8 +98,6 @@ void matrix_init(void) {
uint8_t matrix_scan(void)
{
- //xprintf("\r\nTRYING TO SCAN");
-
uint32_t timeout = 0;
//the s character requests the RF slave to send the matrix
@@ -113,18 +113,22 @@ uint8_t matrix_scan(void)
//harm to leave it in here
while(!uart_available()){
timeout++;
- if (timeout > 10000){
- xprintf("\r\nTime out in keyboard.");
+ 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
//will only show up here if the correct bytes were recieved
uint8_t checksum = 0x00;
- for (uint8_t z=0; z<10; z++){
+ for (uint8_t z = 0; z < 10; z++){
checksum = checksum^uart_data[z];
}
checksum = checksum ^ (uart_data[10] & 0xF0);