aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--Makefile11
-rw-r--r--src/keymat.c10
-rw-r--r--src/main.c18
4 files changed, 35 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ca1787..182eaaf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,10 +52,7 @@ target_compile_options(pico_stdio INTERFACE
-Wno-unused-parameter
)
-target_compile_options(${PROJECT} PRIVATE "-DSPLIT_SIDE=${SPLIT_SIDE}")
-if(DEFINED SPLIT_ROLE)
-target_compile_options(${PROJECT} PRIVATE "-DSPLIT_ROLE=${SPLIT_ROLE}")
-endif(DEFINED SPLIT_ROLE)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_EXTRA_FLAGS}")
family_configure_target(${PROJECT})
family_add_default_example_warnings(${PROJECT})
diff --git a/Makefile b/Makefile
index bb83a18..d96cb5b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
FAMILY ?= rp2040
SIDE ?= left
-SPLIT_SIDE = $(shell echo "$(SIDE)" | tr a-z A-Z)
PICO_SDK_PATH ?= lib/picosdk
TINYUSB_PATH ?= lib/tinyusb
@@ -10,10 +9,12 @@ PICO_SDK_FILES = $(PICO_SDK_PATH)/CMakeLists.txt
TINYUSB_FILES = $(TINYUSB_PATH)/hw/bsp/family_support.cmake
CMAKE_FLAGS = -DFAMILY=$(FAMILY) -DPICO_SDK_PATH=$(PICO_SDK_PATH)
-CMAKE_FLAGS += -DSPLIT_SIDE=$(SPLIT_SIDE) $(CMAKE_FLAGS_LEFT_EXTRA)
+CMAKE_C_FLAGS = -DSPLIT_SIDE=$(shell echo "$(SIDE)" | tr a-z A-Z)
ifdef ROLE
-SPLIT_ROLE = $(shell echo "$(ROLE)" | tr a-z A-Z)
-CMAKE_FLAGS += -DSPLIT_ROLE=$(SPLIT_ROLE)
+CMAKE_C_FLAGS += -DSPLIT_ROLE=$(shell echo "$(ROLE)" | tr a-z A-Z)
+endif
+ifdef GPIO_MOD
+CMAKE_C_FLAGS += -DBAD_GPIO_MITIGATION=1
endif
all: build flash
@@ -22,7 +23,7 @@ clean:
rm -rf .build
build: | $(PICO_SDK_FILES) $(TINYUSB_FILES) .build/$(SIDE)
- cmake -B .build/$(SIDE) $(CMAKE_FLAGS)
+ cmake -B .build/$(SIDE) $(CMAKE_FLAGS) -DCMAKE_C_EXTRA_FLAGS="$(CMAKE_C_FLAGS)"
make -C .build/$(SIDE)
flash:
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);
}
}
diff --git a/src/main.c b/src/main.c
index 0422fdb..6f7044b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);