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 | |
| 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')
| -rw-r--r-- | src/keymat.c | 10 | ||||
| -rw-r--r-- | src/main.c | 18 |
2 files changed, 28 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); } } @@ -24,6 +24,23 @@ void cdc_task(void); +static void +unassigned_init(void) +{ +#ifdef BAD_GPIO_MITIGATION +#pragma message("Enabled bad gpio mitigation to swap gpio pins 5 & 9") + const uint unassigned[] = { 8, 5, 23, 21 }; +#else + const uint unassigned[] = { 8, 9, 23, 21 }; +#endif + uint i; + + for (i = 0; i < ARRLEN(unassigned); i++) { + gpio_init(unassigned[i]); + gpio_set_dir(unassigned[i], GPIO_IN); + } +} + int main(void) { @@ -36,6 +53,7 @@ main(void) keymat_init(); split_init(); hid_init(); + unassigned_init(); led_start_blip(HARD_WHITE, 500); |
