diff --git a/keyboards/karlk90/dzzy/config.h b/keyboards/karlk90/dzzy/config.h index d3e105cf89a0..b3dd3d4f7dc3 100644 --- a/keyboards/karlk90/dzzy/config.h +++ b/keyboards/karlk90/dzzy/config.h @@ -3,8 +3,5 @@ #pragma once -/* USB CONFIG */ -#define FORCE_NKRO - /* SPI DRIVER */ #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B12 diff --git a/keyboards/karlk90/dzzy/dzzy.c b/keyboards/karlk90/dzzy/dzzy.c index c014792ae6ce..4942c68bfc2e 100644 --- a/keyboards/karlk90/dzzy/dzzy.c +++ b/keyboards/karlk90/dzzy/dzzy.c @@ -20,39 +20,39 @@ void keyboard_post_init_user(void) { static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; -void matrix_init_custom(void) { +void matrix_init_pins(void) { for (size_t i = 0; i < MATRIX_COLS; i++) { setPinInputLow(col_pins[i]); } for (size_t i = 0; i < MATRIX_ROWS; i++) { - setPinOutput(row_pins[i]); +/* We deliberatly choose "slower" push pull pins, + * those are fast enough but with lower driving currents + * should produce less EMI noise on the lines. */ +#if defined(__riscv) + /* This is actually implemented as a 2MHZ PP output. */ + palSetLineMode(row_pins[i], PAL_MODE_UNCONNECTED); +#else + palSetLineMode(row_pins[i], (PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST)); +#endif writePinLow(row_pins[i]); } } -bool matrix_scan_custom(matrix_row_t current_matrix[]) { - matrix_row_t raw_matrix[MATRIX_ROWS]; - - for (size_t row_idx = 0; row_idx < MATRIX_ROWS; row_idx++) { - writePinHigh(row_pins[row_idx]); - while (readPin(row_pins[row_idx]) != 1) - ; +void matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { + writePinHigh(row_pins[current_row]); + while (readPin(row_pins[current_row]) != 1) + ; - raw_matrix[row_idx] = (matrix_row_t)palReadGroup(GPIOA, 0x3F, 0); + current_matrix[current_row] = (matrix_row_t)palReadGroup(GPIOA, 0x3F, 0); - writePinLow(row_pins[row_idx]); + writePinLow(row_pins[current_row]); - /* Wait until col pins are low again. */ - size_t counter = 0xFF; - while ((palReadGroup(GPIOA, 0x3F, 0) != 0) && counter != 0) { - counter--; + /* Wait until col pins are high again or timer expired. */ + rtcnt_t start = chSysGetRealtimeCounterX(); + rtcnt_t end = start + MS2RTC(REALTIME_COUNTER_CLOCK, 5); + while (chSysIsCounterWithinX(chSysGetRealtimeCounterX(), start, end)) { + if (palReadGroup(GPIOA, 0x3F, 0) == 0) { + break; } } - - if (memcmp(current_matrix, raw_matrix, sizeof(raw_matrix)) != 0) { - memcpy(current_matrix, raw_matrix, sizeof(raw_matrix)); - return true; - } - - return false; } diff --git a/keyboards/karlk90/dzzy/info.json b/keyboards/karlk90/dzzy/info.json index 89ba505ac374..ab10a88df629 100644 --- a/keyboards/karlk90/dzzy/info.json +++ b/keyboards/karlk90/dzzy/info.json @@ -6,12 +6,12 @@ "lto": true }, "debounce": 5, - "diode_direction": "ROW2COL", + "diode_direction": "COL2ROW", "eeprom": { "driver": "spi" }, "features": { - "console": false, + "console": true, "nkro": true }, "matrix_pins": { diff --git a/keyboards/karlk90/dzzy/rules.mk b/keyboards/karlk90/dzzy/rules.mk index e9c94dab0b85..3e930e3aacda 100644 --- a/keyboards/karlk90/dzzy/rules.mk +++ b/keyboards/karlk90/dzzy/rules.mk @@ -1,4 +1,4 @@ # Copyright 2020-2023 Stefan Kerkmann (@karlk90) # SPDX-License-Identifier: GPL-2.0-or-later -CUSTOM_MATRIX = lite +DEBUG_MATRIX_SCAN_RATE_ENABLE = yes