diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-12-09 02:48:25 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-12-09 02:48:25 +0100 |
| commit | d51388c63ceb1646753878810e4b40f7dfb3c0bc (patch) | |
| tree | efcde4f7da733c12121eea2aa47c97a538a97123 /src/keymat.c | |
| parent | e5022d756a6a884d7d380c5f945284068962c9f1 (diff) | |
| download | sxkbd-d51388c63ceb1646753878810e4b40f7dfb3c0bc.tar.gz sxkbd-d51388c63ceb1646753878810e4b40f7dfb3c0bc.zip | |
Add mitigation for gpio pin that fails to pull low
Diffstat (limited to 'src/keymat.c')
| -rw-r--r-- | src/keymat.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/keymat.c b/src/keymat.c index 3686053..4b78e16 100644 --- a/src/keymat.c +++ b/src/keymat.c @@ -9,7 +9,12 @@ #include <string.h> +#ifdef BAD_GPIO_MITIGATION +static const uint keymat_row_pins[] = { 4, 9, 6, 7 }; +#else static const uint keymat_row_pins[] = { 4, 5, 6, 7 }; +#endif + static const uint keymat_col_pins[] = { 29, 28, 27, 26, 22, 20 }; static_assert(ARRLEN(keymat_row_pins) == KEY_ROWS_HALF); static_assert(ARRLEN(keymat_col_pins) == KEY_COLS); @@ -25,12 +30,17 @@ keymat_init(void) for (x = 0; x < KEY_COLS; x++) { gpio_init(keymat_col_pins[x]); gpio_set_dir(keymat_col_pins[x], GPIO_IN); + gpio_set_drive_strength(keymat_col_pins[x], GPIO_DRIVE_STRENGTH_2MA); + gpio_set_slew_rate(keymat_col_pins[x], GPIO_SLEW_RATE_FAST); gpio_pull_up(keymat_col_pins[x]); } for (y = 0; y < KEY_ROWS_HALF; y++) { gpio_init(keymat_row_pins[y]); gpio_set_dir(keymat_row_pins[y], GPIO_OUT); + gpio_set_drive_strength(keymat_col_pins[x], GPIO_DRIVE_STRENGTH_2MA); + gpio_set_slew_rate(keymat_row_pins[y], GPIO_SLEW_RATE_FAST); + gpio_put(keymat_row_pins[y], 0); } } |
