aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2021-07-13 18:14:27 +0900
committerGitHub <noreply@github.com>2021-07-13 18:14:27 +0900
commitb89abc402bdc70362dbb6d938eafaa8716b5d4ac (patch)
treef0370521b4492de9ba6fa1b6082f995639597d30
parent6b6ee5fa286c067fbea7da2b5274d47aac84d253 (diff)
downloadqmk_firmware-b89abc402bdc70362dbb6d938eafaa8716b5d4ac.tar.gz
qmk_firmware-b89abc402bdc70362dbb6d938eafaa8716b5d4ac.zip
[Keyboard] Update Symmetric70 keyboard prototype (#12707)
* update handwired/symmetric70_proto/matrix.c * make keyboards/handwired/symmetric70_proto/promicro/ * add symmetric70_proto/debug_config.h, update symmetric70_proto/local_features.mk etc. set MATRIX_IO_DELAY macro make MTEST=mdelay0 symmetric70_proto/promicro:default:flash make MTEST=mdelay1 symmetric70_proto/promicro:default:flash make MTEST=mdelay10 symmetric70_proto/promicro:default:flash make MTEST=mdelay30 symmetric70_proto/promicro:default:flash set DEBUG_MATRIX_SCAN_RATE_ENABLE yes make MTEST=scan symmetric70_proto/promicro:default:flash set MATRIX_DEBUG_DELAY and MATRIX_IO_DELAY macro make MTEST=matrix_debug_delay,mdelay0 symmetric70_proto/promicro:default:flash set MATRIX_DEBUG_SCAN make MTEST=matrix_debug_scan symmetric70_proto/promicro:default:flash * add symmetric70_proto/matrix_debug/readme.md * update symmetric70_proto/matrix_debug/readme.md * update handwired/symmetric70_proto/readme.md * update handwired/symmetric70_proto/readme.md * update handwired/symmetric70_proto/*/readme.md * add handwired/symmetric70_proto/matrix_fast/ * update handwired/symmetric70_proto/matrix_fast/readme.md * fix typo in handwired/symmetric70_proto/matrix_fast/readme.md * update config.h under handwired/symmetric70_proto/promicro * add Proton C support to handwired/symmetric70_proto * add handwired/symmetric70_proto/proton_c/readme.md * add promicro/*/readme.md proton_c/*/readme.md * update handwired/symmetric70_proto/proton_c/proton_c.c support MATRIX_IO_DELAY_DEFAULT for testing. * Added another implementation of 'adaptive_delay'. * update symmetric70_proto/local_features.mk * update symmetric70_proto/matrix_fast/gpio_extr.h * add matrix_output_unselect_delay_ports() * add MTEST=adaptive_delay_fast option * update symmetric70_proto/matrix_debug/readme.md * update symmetric70_proto/matrix_fast/readme.md * update symmetric70_proto/matrix_debug/readme.md * Erase garbage * fix symmetric70_proto/proton_c/proton_c.c * improve adaptive_delay_fast in symmetric70_proto/matrix_debug/matrix.c * update symmetric70_proto/matrix_debug/readme.md * fix symmetric70_proto/matrix_debug/readme.md * Update keyboards/handwired/symmetric70_proto/proton_c/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/handwired/symmetric70_proto/proton_c/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/handwired/symmetric70_proto/local_features.mk Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/local_features.mk Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/local_features.mk Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_debug/readme.md Co-authored-by: Nick Brassel <nick@tzarc.org> * Update keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Nick Brassel <nick@tzarc.org>
-rw-r--r--keyboards/handwired/symmetric70_proto/debug_config.h33
-rw-r--r--keyboards/handwired/symmetric70_proto/local_features.mk108
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_debug/gpio_extr.h10
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c (renamed from keyboards/handwired/symmetric70_proto/matrix.c)152
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_debug/readme.md200
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/cpp_map.h53
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/gpio_extr.h28
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c234
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c234
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extension_74hc15x.c72
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extr.h36
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/readme.md168
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/test_config.h21
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/test_config_74hc157.h28
-rw-r--r--keyboards/handwired/symmetric70_proto/matrix_fast/test_config_direct.h34
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/config.h (renamed from keyboards/handwired/symmetric70_proto/config.h)43
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/fast/config.h52
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/fast/readme.md1
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk6
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/normal/config.h41
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/normal/readme.md1
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk6
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/readme.md27
-rw-r--r--keyboards/handwired/symmetric70_proto/promicro/rules.mk (renamed from keyboards/handwired/symmetric70_proto/rules.mk)5
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/config.h165
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/fast/config.h44
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/fast/readme.md1
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk6
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/normal/config.h36
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/normal/readme.md1
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk6
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/proton_c.c12
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/readme.md26
-rw-r--r--keyboards/handwired/symmetric70_proto/proton_c/rules.mk23
-rw-r--r--keyboards/handwired/symmetric70_proto/readme.md16
35 files changed, 1865 insertions, 64 deletions
diff --git a/keyboards/handwired/symmetric70_proto/debug_config.h b/keyboards/handwired/symmetric70_proto/debug_config.h
new file mode 100644
index 000000000..cba99e402
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/debug_config.h
@@ -0,0 +1,33 @@
1/*
2 * matrix.c testing macros
3 * MATRIX_DEBUG_SCAN: Measuring execution time of `matrix_scan()`
4 * MATRIX_DEBUG_DELAY: Observation of delay after `unselect_row()`
5 */
6#pragma once
7#ifndef __ASSEMBLER__
8#include <gpio.h>
9
10static inline void setDebugPinOutput_Low(void) {
11 setPinOutput(MATRIX_DEBUG_PIN);
12 writePinLow(MATRIX_DEBUG_PIN);
13}
14
15#define MATRIX_DEBUG_PIN_INIT() setDebugPinOutput_Low()
16
17#ifdef MATRIX_DEBUG_SCAN
18# define MATRIX_DEBUG_SCAN_START() writePinHigh(MATRIX_DEBUG_PIN)
19# define MATRIX_DEBUG_SCAN_END() writePinLow(MATRIX_DEBUG_PIN)
20#else
21# define MATRIX_DEBUG_SCAN_START()
22# define MATRIX_DEBUG_SCAN_END()
23#endif
24
25#ifdef MATRIX_DEBUG_DELAY
26# define MATRIX_DEBUG_DELAY_START() writePinHigh(MATRIX_DEBUG_PIN)
27# define MATRIX_DEBUG_DELAY_END() writePinLow(MATRIX_DEBUG_PIN)
28#else
29# define MATRIX_DEBUG_DELAY_START()
30# define MATRIX_DEBUG_DELAY_END()
31#endif
32
33#endif // __ASSEMBLER__
diff --git a/keyboards/handwired/symmetric70_proto/local_features.mk b/keyboards/handwired/symmetric70_proto/local_features.mk
new file mode 100644
index 000000000..e5cd31a61
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/local_features.mk
@@ -0,0 +1,108 @@
1# matrix.c testing options
2# set MATRIX_IO_DELAY macro
3# make MTEST=mdelay0 symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
4# make MTEST=mdelay=1 symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
5# make MTEST=mdelay=10 symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
6# set DEBUG_MATRIX_SCAN_RATE_ENABLE yes
7# make MTEST=scan symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
8# set MATRIX_DEBUG_DELAY and MATRIX_IO_DELAY macro
9# make MTEST=matrix_debug_delay,mdelay0 symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
10# set MATRIX_DEBUG_SCAN
11# make MTEST=matrix_debug_scan symmetric70_proto/{promicro|proton_c}/{fast|normal}:default:flash
12
13ifneq ($(strip $(MTEST)),)
14 define KEYBOARD_OPTION_PARSE
15 # parse 'consle', 'scan', 'no-scan', 'mdelay=?', 'mdelay0',
16 # 'adaptive_delay', 'always_delay', 'matrix_debug_delay', 'matrix_debug_scan'
17 $(if $(SHOW_PARSE),$(info parse .$1.)) #for debug 'make SHOW_PARSE=y ...'
18 ifeq ($(strip $1),console)
19 CONSOLE_ENABLE = yes
20 endif
21 ifeq ($(strip $1),scan)
22 DEBUG_MATRIX_SCAN_RATE_ENABLE = yes
23 endif
24 ifeq ($(strip $1),no-scan)
25 DEBUG_MATRIX_SCAN_RATE_ENABLE = no
26 endif
27 ifneq ($(filter mdelay=%,$1),)
28 MDELAY = $(patsubst mdelay=%,%,$1)
29 endif
30 ifeq ($(strip $1),mdelay0)
31 MDELAY = 0
32 endif
33 ifeq ($(strip $1),common_delay)
34 MATRIX_COMMON_DELAY = yes
35 endif
36 ifeq ($(strip $1),adaptive_delay)
37 ADAPTIVE_DELAY = yes
38 endif
39 ifeq ($(strip $1),adaptive_delay2)
40 ADAPTIVE_DELAY2 = yes
41 endif
42 ifeq ($(strip $1),adaptive_delay_fast)
43 ADAPTIVE_DELAY_FAST = yes
44 endif
45 ifeq ($(strip $1),always_delay)
46 ALWAYS_DELAY = yes
47 endif
48 ifeq ($(strip $1),matrix_debug_delay)
49 MATRIX_DEBUG_DELAY = yes
50 MATRIX_DEBUG_SCAN = no
51 endif
52 ifeq ($(strip $1),matrix_debug_scan)
53 MATRIX_DEBUG_DELAY = no
54 MATRIX_DEBUG_SCAN = yes
55 endif
56 endef # end of KEYMAP_OPTION_PARSE
57
58 COMMA=,
59 $(eval $(foreach A_OPTION_NAME,$(subst $(COMMA), ,$(MTEST)), \
60 $(call KEYBOARD_OPTION_PARSE,$(A_OPTION_NAME))))
61endif
62
63ifneq ($(strip $(MDELAY)),)
64 OPT_DEFS += -DMATRIX_IO_DELAY=$(strip $(MDELAY))
65endif
66
67ifeq ($(strip $(ADAPTIVE_DELAY)),yes)
68 OPT_DEFS += -DMATRIX_IO_DELAY_ADAPTIVE
69endif
70
71ifeq ($(strip $(ADAPTIVE_DELAY2)),yes)
72 OPT_DEFS += -DMATRIX_IO_DELAY_ADAPTIVE2
73endif
74
75ifeq ($(strip $(ADAPTIVE_DELAY_FAST)),yes)
76 OPT_DEFS += -DMATRIX_IO_DELAY_ADAPTIVE_FAST
77endif
78
79ifeq ($(strip $(ALWAYS_DELAY)),yes)
80 OPT_DEFS += -DMATRIX_IO_DELAY_ALWAYS
81endif
82
83ifeq ($(strip $(MATRIX_DEBUG_DELAY)),yes)
84 OPT_DEFS += -DMATRIX_DEBUG_DELAY
85 DEBUG_CONFIG = yes
86endif
87
88ifeq ($(strip $(MATRIX_DEBUG_SCAN)),yes)
89 OPT_DEFS += -DMATRIX_DEBUG_SCAN
90 DEBUG_CONFIG = yes
91endif
92
93ifeq ($(strip $(DEBUG_CONFIG)),yes)
94 # include "debug_config.h" from {promicro|proton_c}/config.h
95 OPT_DEFS += -DDEBUG_CONFIG
96endif
97
98ifeq ($(strip $(MATRIX_COMMON_DELAY)),yes)
99 # use matrix_output_unselect_delay() in matrix_common.c
100 OPT_DEFS += -DMATRIX_IO_DELAY_DEFAULT
101endif
102
103$(info -)
104$(info - DEBUG_MATRIX_SCAN_RATE_ENABLE = $(DEBUG_MATRIX_SCAN_RATE_ENABLE))
105$(info - CONSOLE_ENABLE = $(CONSOLE_ENABLE))
106$(info - MDELAY = $(MDELAY))
107$(info - MATRIX_COMMON_DELAY = $(MATRIX_COMMON_DELAY))
108$(info - OPT_DEFS = $(OPT_DEFS))
diff --git a/keyboards/handwired/symmetric70_proto/matrix_debug/gpio_extr.h b/keyboards/handwired/symmetric70_proto/matrix_debug/gpio_extr.h
new file mode 100644
index 000000000..c7d08309d
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_debug/gpio_extr.h
@@ -0,0 +1,10 @@
1#pragma once
2// clang-format off
3
4#if defined(__AVR__)
5# define readPort(port) PINx_ADDRESS(port)
6typedef uint8_t port_data_t;
7#else
8# define readPort(qmk_pin) palReadPort(PAL_PORT(qmk_pin))
9typedef uint16_t port_data_t;
10#endif
diff --git a/keyboards/handwired/symmetric70_proto/matrix.c b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
index c01612073..c84efe291 100644
--- a/keyboards/handwired/symmetric70_proto/matrix.c
+++ b/keyboards/handwired/symmetric70_proto/matrix_debug/matrix.c
@@ -20,6 +20,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20#include "matrix.h" 20#include "matrix.h"
21#include "debounce.h" 21#include "debounce.h"
22#include "quantum.h" 22#include "quantum.h"
23#ifndef readPort
24# include "gpio_extr.h"
25#endif
26
27#ifndef MATRIX_DEBUG_PIN
28# define MATRIX_DEBUG_PIN_INIT()
29# define MATRIX_DEBUG_SCAN_START()
30# define MATRIX_DEBUG_SCAN_END()
31# define MATRIX_DEBUG_DELAY_START()
32# define MATRIX_DEBUG_DELAY_END()
33# define MATRIX_DEBUG_GAP()
34#else
35# define MATRIX_DEBUG_GAP() asm volatile("nop \n nop":::"memory")
36#endif
37
38#ifndef MATRIX_IO_DELAY_ALWAYS
39# define MATRIX_IO_DELAY_ALWAYS 0
40#endif
23 41
24#ifdef DIRECT_PINS 42#ifdef DIRECT_PINS
25static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS; 43static pin_t direct_pins[MATRIX_ROWS][MATRIX_COLS] = DIRECT_PINS;
@@ -28,16 +46,32 @@ static const pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
28static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; 46static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
29# ifdef MATRIX_MUL_SELECT 47# ifdef MATRIX_MUL_SELECT
30static const pin_t col_sel[MATRIX_COLS] = MATRIX_MUL_SEL; 48static const pin_t col_sel[MATRIX_COLS] = MATRIX_MUL_SEL;
31# ifndef MATRIX_MUL_SELECT_DELAY
32# define MATRIX_MUL_SELECT_DELAY 1
33# endif
34# endif 49# endif
35#endif 50#endif
36 51
52#ifdef MATRIX_IO_DELAY_PORTS
53static const pin_t delay_ports[] = { MATRIX_IO_DELAY_PORTS };
54static const port_data_t delay_masks[] = { MATRIX_IO_DELAY_MASKS };
55# ifdef MATRIX_IO_DELAY_MULSEL
56static const uint8_t delay_sel[] = { MATRIX_IO_DELAY_MULSEL };
57# endif
58#endif
59
37/* matrix state(1:on, 0:off) */ 60/* matrix state(1:on, 0:off) */
38extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values 61extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
39extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values 62extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
40 63
64static inline void setPinOutput_writeLow(pin_t pin) {
65 ATOMIC_BLOCK_FORCEON {
66 setPinOutput(pin);
67 writePinLow(pin);
68 }
69}
70
71static inline void setPinInputHigh_atomic(pin_t pin) {
72 ATOMIC_BLOCK_FORCEON { setPinInputHigh(pin); }
73}
74
41// matrix code 75// matrix code
42 76
43#ifdef DIRECT_PINS 77#ifdef DIRECT_PINS
@@ -75,16 +109,13 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
75#elif defined(DIODE_DIRECTION) 109#elif defined(DIODE_DIRECTION)
76# if (DIODE_DIRECTION == COL2ROW) 110# if (DIODE_DIRECTION == COL2ROW)
77 111
78static void select_row(uint8_t row) { 112static void select_row(uint8_t row) { setPinOutput_writeLow(row_pins[row]); }
79 setPinOutput(row_pins[row]);
80 writePinLow(row_pins[row]);
81}
82 113
83static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } 114static void unselect_row(uint8_t row) { setPinInputHigh_atomic(row_pins[row]); }
84 115
85static void unselect_rows(void) { 116static void unselect_rows(void) {
86 for (uint8_t x = 0; x < MATRIX_ROWS; x++) { 117 for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
87 setPinInputHigh(row_pins[x]); 118 setPinInputHigh_atomic(row_pins[x]);
88 } 119 }
89} 120}
90 121
@@ -95,7 +126,7 @@ static void init_pins(void) {
95#endif 126#endif
96 unselect_rows(); 127 unselect_rows();
97 for (uint8_t x = 0; x < MATRIX_COLS; x++) { 128 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
98 setPinInputHigh(col_pins[x]); 129 setPinInputHigh_atomic(col_pins[x]);
99 } 130 }
100} 131}
101 132
@@ -103,16 +134,16 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
103 // Start with a clear matrix row 134 // Start with a clear matrix row
104 matrix_row_t current_row_value = 0; 135 matrix_row_t current_row_value = 0;
105 136
106 // Select row and wait for row selecton to stabilize 137 // Select row
107 select_row(current_row); 138 select_row(current_row);
108 matrix_io_delay(); 139 matrix_output_select_delay();
109 140
110 // For each col... 141 // For each col...
111 for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) { 142 for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
112 // Select the col pin to read (active low) 143 // Select the col pin to read (active low)
113#ifdef MATRIX_MUL_SELECT 144#ifdef MATRIX_MUL_SELECT
114 writePin(MATRIX_MUL_SELECT,col_sel[col_index]); 145 writePin(MATRIX_MUL_SELECT,col_sel[col_index]);
115 __builtin_avr_delay_cycles(MATRIX_MUL_SELECT_DELAY); 146 waitInputPinDelay();
116#endif 147#endif
117 uint8_t pin_state = readPin(col_pins[col_index]); 148 uint8_t pin_state = readPin(col_pins[col_index]);
118 149
@@ -122,6 +153,60 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
122 153
123 // Unselect row 154 // Unselect row
124 unselect_row(current_row); 155 unselect_row(current_row);
156#ifdef MATRIX_IO_DELAY_PORTS
157 if (current_row_value) { // wait for col signal to go HIGH
158 bool is_pressed;
159 do {
160 MATRIX_DEBUG_DELAY_START();
161 is_pressed = false;
162 for (uint8_t i = 0; i < sizeof(delay_ports)/sizeof(pin_t); i++ ) {
163# ifdef MATRIX_IO_DELAY_MULSEL
164 writePin(MATRIX_MUL_SELECT, delay_sel[i]);
165 waitInputPinDelay();
166# endif
167 is_pressed |= ( (readPort(delay_ports[i]) & delay_masks[i]) != delay_masks[i] );
168 }
169 MATRIX_DEBUG_DELAY_END();
170 } while (is_pressed);
171 }
172#endif
173#ifdef MATRIX_IO_DELAY_ADAPTIVE
174 if (current_row_value) { // wait for col signal to go HIGH
175 for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
176 MATRIX_DEBUG_DELAY_START();
177#ifdef MATRIX_MUL_SELECT
178 writePin(MATRIX_MUL_SELECT,col_sel[col_index]);
179 waitInputPinDelay();
180#endif
181 while (readPin(col_pins[col_index]) == 0) {}
182 MATRIX_DEBUG_DELAY_END();
183 }
184 }
185#endif
186#ifdef MATRIX_IO_DELAY_ADAPTIVE2
187 if (current_row_value) { // wait for col signal to go HIGH
188 pin_t state;
189 do {
190 MATRIX_DEBUG_DELAY_START();
191 state = 0;
192 for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
193 MATRIX_DEBUG_DELAY_END();
194 MATRIX_DEBUG_DELAY_START();
195#ifdef MATRIX_MUL_SELECT
196 writePin(MATRIX_MUL_SELECT,col_sel[col_index]);
197 waitInputPinDelay();
198#endif
199 state |= (readPin(col_pins[col_index]) == 0);
200 }
201 MATRIX_DEBUG_DELAY_END();
202 } while (state);
203 }
204#endif
205 if (MATRIX_IO_DELAY_ALWAYS || current_row + 1 < MATRIX_ROWS) {
206 MATRIX_DEBUG_DELAY_START();
207 matrix_output_unselect_delay(); // wait for col signal to go HIGH
208 MATRIX_DEBUG_DELAY_END();
209 }
125 210
126 // If the row has changed, store the row and return the changed flag. 211 // If the row has changed, store the row and return the changed flag.
127 if (current_matrix[current_row] != current_row_value) { 212 if (current_matrix[current_row] != current_row_value) {
@@ -133,32 +218,29 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
133 218
134# elif (DIODE_DIRECTION == ROW2COL) 219# elif (DIODE_DIRECTION == ROW2COL)
135 220
136static void select_col(uint8_t col) { 221static void select_col(uint8_t col) { setPinOutput_writeLow(col_pins[col]); }
137 setPinOutput(col_pins[col]);
138 writePinLow(col_pins[col]);
139}
140 222
141static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); } 223static void unselect_col(uint8_t col) { setPinInputHigh_atomic(col_pins[col]); }
142 224
143static void unselect_cols(void) { 225static void unselect_cols(void) {
144 for (uint8_t x = 0; x < MATRIX_COLS; x++) { 226 for (uint8_t x = 0; x < MATRIX_COLS; x++) {
145 setPinInputHigh(col_pins[x]); 227 setPinInputHigh_atomic(col_pins[x]);
146 } 228 }
147} 229}
148 230
149static void init_pins(void) { 231static void init_pins(void) {
150 unselect_cols(); 232 unselect_cols();
151 for (uint8_t x = 0; x < MATRIX_ROWS; x++) { 233 for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
152 setPinInputHigh(row_pins[x]); 234 setPinInputHigh_atomic(row_pins[x]);
153 } 235 }
154} 236}
155 237
156static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { 238static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
157 bool matrix_changed = false; 239 bool matrix_changed = false;
158 240
159 // Select col and wait for col selecton to stabilize 241 // Select col
160 select_col(current_col); 242 select_col(current_col);
161 matrix_io_delay(); 243 matrix_output_select_delay();
162 244
163 // For each row... 245 // For each row...
164 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) { 246 for (uint8_t row_index = 0; row_index < MATRIX_ROWS; row_index++) {
@@ -184,6 +266,9 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
184 266
185 // Unselect col 267 // Unselect col
186 unselect_col(current_col); 268 unselect_col(current_col);
269 if (MATRIX_IO_DELAY_ALWAYS || current_col + 1 < MATRIX_COLS) {
270 matrix_output_unselect_delay(); // wait for col signal to go HIGH
271 }
187 272
188 return matrix_changed; 273 return matrix_changed;
189} 274}
@@ -195,7 +280,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
195# error DIODE_DIRECTION is not defined! 280# error DIODE_DIRECTION is not defined!
196#endif 281#endif
197 282
198void matrix_init_custom(void) { 283void matrix_init(void) {
199 // initialize key pins 284 // initialize key pins
200 init_pins(); 285 init_pins();
201 286
@@ -205,22 +290,35 @@ void matrix_init_custom(void) {
205 matrix[i] = 0; 290 matrix[i] = 0;
206 } 291 }
207 292
293 debounce_init(MATRIX_ROWS);
294
295 matrix_init_quantum();
208} 296}
209 297
210bool matrix_scan_custom(matrix_row_t current_matrix[]) { 298uint8_t matrix_scan(void) {
211 bool changed = false; 299 bool changed = false;
300 MATRIX_DEBUG_PIN_INIT();
212 301
302 MATRIX_DEBUG_SCAN_START();
213#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) 303#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
214 // Set row, read cols 304 // Set row, read cols
215 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { 305 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
216 changed |= read_cols_on_row(current_matrix, current_row); 306 changed |= read_cols_on_row(raw_matrix, current_row);
217 } 307 }
218#elif (DIODE_DIRECTION == ROW2COL) 308#elif (DIODE_DIRECTION == ROW2COL)
219 // Set col, read rows 309 // Set col, read rows
220 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { 310 for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
221 changed |= read_rows_on_col(current_matrix, current_col); 311 changed |= read_rows_on_col(raw_matrix, current_col);
222 } 312 }
223#endif 313#endif
314 MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP();
315
316 MATRIX_DEBUG_SCAN_START();
317 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
318 MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP();
224 319
225 return changed; 320 MATRIX_DEBUG_SCAN_START();
321 matrix_scan_quantum();
322 MATRIX_DEBUG_SCAN_END();
323 return (uint8_t)changed;
226} 324}
diff --git a/keyboards/handwired/symmetric70_proto/matrix_debug/readme.md b/keyboards/handwired/symmetric70_proto/matrix_debug/readme.md
new file mode 100644
index 000000000..3e45db87e
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_debug/readme.md
@@ -0,0 +1,200 @@
1# Debug version matrix.c
2
3This matrix.c is quantum/matrix.c with the following additions:
4
5* Added the MATRIX_DEBUG_SCAN_{START/END} macro to measure the execution time of matrix_scan().
6* Added the MATRIX_DEBUG_DELAY_{START/END} macro to measure delay time.
7* Added the MATRIX_MUL_SELECT handling for symmetric70_proto.
8
9## Compile
10
11* Set MATRIX_IO_DELAY value
12 * `make MTEST=mdelay0 handwired/symmetric70_proto/promicro/normal:default:flash`
13 * `make MTEST=mdelay=1 handwired/symmetric70_proto/promicro/normal:default:flash`
14 * `make MTEST=mdelay=2 handwired/symmetric70_proto/promicro/normal:default:flash`
15 * `make MTEST=mdelay=3 handwired/symmetric70_proto/promicro/normal:default:flash`
16 * `make MTEST=mdelay=4 handwired/symmetric70_proto/promicro/normal:default:flash`
17 * `make MTEST=mdelay=5 handwired/symmetric70_proto/promicro/normal:default:flash`
18 * `make MTEST=mdelay=10 handwired/symmetric70_proto/promicro/normal:default:flash`
19 * `make MTEST=mdelay=20 handwired/symmetric70_proto/promicro/normal:default:flash`
20 * `make MTEST=mdelay=30 handwired/symmetric70_proto/promicro/normal:default:flash`
21* Measure the execution time of matrix_scan()
22 * `make MTEST=matrix_debug_scan[,<other options>..] handwired/symmetric70_proto/promicro/normal:default:flash`
23* Measure delay time.
24 * `make MTEST=matrix_debug_delay[,<other options>..] handwired/symmetric70_proto/promicro/normal:default:flash`
25* Change the behavior of delay
26 * `make MTEST=matrix_debug_delay,always_delay handwired/symmetric70_proto/promicro/normal:default:flash`
27 * `make MTEST=matrix_debug_delay,adaptive_delay,mdelay0 handwired/symmetric70_proto/promicro/normal:default:flash`
28 * `make MTEST=matrix_debug_delay,adaptive_delay_fast,mdelay0 handwired/symmetric70_proto/promicro/normal:default:flash`
29
30## Measurement result
31### Pro Micro (ATmega32u4 16Mhz)
32#### Default setting (show `matrix_scan()` time)
33 - `make MTEST=matrix_debug_scan handwired/symmetric70_proto/promicro/normal:default:flash`
34 - CH1: Row 0
35 - CH2: Row 1
36 - CH3: Row 4
37 - CH4: matrix_scan()
38 - Execution time of matrix_scan() 503us
39 - Frequency of matrix scan 1.81kHz (551.0us)
40 ![DS1Z_QuickPrint2](https://user-images.githubusercontent.com/2170248/115994477-0ba64400-a612-11eb-98ba-b8cc362f26ac.png)
41
42#### Always call `matrix_output_unselect_delay()` (show `matrix_scan()` time, default MATRIX_IO_DELAY)
43 - `make MTEST=matrix_debug_scan,always_delay handwired/symmetric70_proto/promicro/normal:default:flash`
44 - CH1: Row 0
45 - CH2: Row 1
46 - CH3: Row 4
47 - CH4: matrix_scan()
48 - Execution time of matrix_scan() 521us
49 - Frequency of matrix scan 1.76kHz (568.5us)
50 ![DS1Z_QuickPrint1](https://user-images.githubusercontent.com/2170248/115994488-1660d900-a612-11eb-83b1-cd820607db03.png)
51
52#### Adaptive delay (show `matrix_scan()` time, MATRIX_IO_DELAY = 0)
53 - `make MTEST=matrix_debug_scan,mdelay0,adaptive_delay handwired/symmetric70_proto/promicro/normal:default:flash`
54 - CH1: Row 0
55 - CH2: Row 1
56 - CH3: Row 4
57 - CH4: matrix_scan()
58 - Execution time of matrix_scan() 383us
59 - Frequency of matrix scan 2.32kHz (431us)
60 ![DS1Z_QuickPrint3](https://user-images.githubusercontent.com/2170248/115994939-034f0880-a614-11eb-861f-b83a31efa51a.png)
61
62#### Adaptive delay (show delay time, MATRIX_IO_DELAY = 0)
63 - `make MTEST=matrix_debug_delay,mdelay0,adaptive_delay handwired/symmetric70_proto/promicro/normal:default:flash`
64
65##### Press R0C1, R1C1 key
66 - CH1: Row 0
67 - CH2: Row 1
68 - CH3: Row 4
69 - CH4: delay time
70 - Delay time 68us
71 - Frequency of matrix scan 1.77kHz (565us)
72 ![DS1Z_QuickPrint55](https://user-images.githubusercontent.com/2170248/119561268-ead33900-bddf-11eb-9cc4-7e04826486cf.png)
73
74#### Fast adaptive delay (show `matrix_scan()` time, MATRIX_IO_DELAY = 0)
75 - `make MTEST=matrix_debug_scan,mdelay0,adaptive_delay_fast handwired/symmetric70_proto/promicro/normal:default:flash`
76 - CH1: Row 0
77 - CH2: Row 1
78 - CH3: Row 4
79 - CH4: matrix_scan()
80 - Execution time of matrix_scan() 382us
81 - Frequency of matrix scan 2.33kHz (428us)
82 ![DS1Z_QuickPrint56](https://user-images.githubusercontent.com/2170248/119561280-eeff5680-bddf-11eb-9576-e4cf64751955.png)
83
84#### Fast adaptive delay (show delay time, MATRIX_IO_DELAY = 0)
85 - `make MTEST=matrix_debug_delay,mdelay0,adaptive_delay_fast handwired/symmetric70_proto/promicro/normal:default:flash`
86
87##### Press R0C1, R1C1 key
88 - CH1: Row 0
89 - CH2: Row 1
90 - CH3: Row 4
91 - CH4: delay time
92 - Delay time 11us
93 - Frequency of matrix scan 2.21kHz (452us)
94 ![DS1Z_QuickPrint57](https://user-images.githubusercontent.com/2170248/119561318-faeb1880-bddf-11eb-8592-694f9ecb2248.png)
95
96### Proton C (STM32F303 72MHz)
97#### Default setting (show `matrix_scan()` time)
98 - `make MTEST=matrix_debug_scan handwired/symmetric70_proto/proton_c/normal:default:flash`
99 - CH1: Row 0
100 - CH2: Row 1
101 - CH3: Row 4
102 - CH4: matrix_scan()
103 - Execution time of matrix_scan() 210us
104 - Frequency of matrix scan 4.35kHz (230.0us)
105 ![DS1Z_QuickPrint16](https://user-images.githubusercontent.com/2170248/116131295-2ad2cd80-a707-11eb-8d0a-6f7912456e03.png)
106
107#### Always call `matrix_output_unselect_delay()` (show `matrix_scan()` time, default MATRIX_IO_DELAY)
108 - `make MTEST=matrix_debug_scan,always_delay handwired/symmetric70_proto/proton_c/normal:default:flash`
109 - CH1: Row 0
110 - CH2: Row 1
111 - CH3: Row 4
112 - CH4: matrix_scan()
113 - Execution time of matrix_scan() 242us
114 - Frequency of matrix scan 3.85kHz (260.0us)
115 ![DS1Z_QuickPrint17](https://user-images.githubusercontent.com/2170248/116131308-31f9db80-a707-11eb-8db7-d1960fa7b068.png)
116
117#### Adaptive delay (show `matrix_scan()` time, MATRIX_IO_DELAY = 0)
118 - `make MTEST=matrix_debug_scan,mdelay0,adaptive_delay handwired/symmetric70_proto/proton_c/normal:default:flash`
119 - CH1: Row 0
120 - CH2: Row 1
121 - CH3: Row 4
122 - CH4: matrix_scan()
123 - Execution time of matrix_scan() 76.4us
124 - Frequency of matrix scan 10.6kHz (94.4us)
125 ![DS1Z_QuickPrint18](https://user-images.githubusercontent.com/2170248/116131369-44741500-a707-11eb-9c74-fa39d9e80947.png)
126
127#### Adaptive delay (show delay time, MATRIX_IO_DELAY = 0)
128 - `make MTEST=matrix_debug_delay,mdelay0,adaptive_delay handwired/symmetric70_proto/proton_c/normal:default:flash`
129
130##### Press R0C1, R1C1 key
131 - CH1: Row 0
132 - CH2: Row 1
133 - CH3: Row 4
134 - CH4: delay time
135 - Delay time 7.6us
136 - Frequency of matrix scan 9.47kHz (105.6us)
137 ![DS1Z_QuickPrint58](https://user-images.githubusercontent.com/2170248/119666783-a3e15400-be70-11eb-9a58-220032117efd.png)
138
139##### Connect a 500pF capacitor between C2 line and GND, Press R0C2, R1C2, R2C2, R3C2, R4C2 keys
140 - CH1: Row 0
141 - CH2: Row 1
142 - CH3: Col 2
143 - CH4: delay time
144 - Delay time 12us + alpha
145 - Frequency of matrix scan 5.45kHz (183us)
146 - Threshold Voltage 1.9V
147 ![DS1Z_QuickPrint59](https://user-images.githubusercontent.com/2170248/119666946-cc694e00-be70-11eb-9b97-4c500416d774.png)
148
149##### Connect a 1000pF capacitor between C2 line and GND, Press R0C2, R1C2, R2C2, R3C2, R4C2 keys
150 - CH1: Row 0
151 - CH2: Row 1
152 - CH3: Col 2
153 - CH4: delay time
154 - Delay time 20us + alpha
155 - Frequency of matrix scan 4.48kHz (223us)
156 - Threshold Voltage 1.9V
157 ![DS1Z_QuickPrint60](https://user-images.githubusercontent.com/2170248/119667127-f3c01b00-be70-11eb-8e7f-6f0a81f95e97.png)
158
159#### Fast adaptive delay (show `matrix_scan()` time, MATRIX_IO_DELAY = 0)
160 - `make MTEST=matrix_debug_scan,mdelay0,adaptive_delay_fast handwired/symmetric70_proto/proton_c/normal:default:flash`
161 - CH1: Row 0
162 - CH2: Row 1
163 - CH3: Row 4
164 - CH4: matrix_scan()
165 - Execution time of matrix_scan() 75.6us
166 - Frequency of matrix scan 10.8kHz (92.2us)
167 ![DS1Z_QuickPrint62](https://user-images.githubusercontent.com/2170248/119667218-0b979f00-be71-11eb-946c-16f0a0454056.png)
168
169#### Fast adaptive delay (show delay time, MATRIX_IO_DELAY = 0)
170 - `make MTEST=matrix_debug_delay,mdelay0,adaptive_delay_fast handwired/symmetric70_proto/proton_c/normal:default:flash`
171
172##### Press R0C1, R1C1 key
173 - CH1: Row 0
174 - CH2: Row 1
175 - CH3: Row 4
176 - CH4: delay time
177 - Delay time 1.6us
178 - Frequency of matrix scan 10.6kHz (94.4us)
179 ![DS1Z_QuickPrint63](https://user-images.githubusercontent.com/2170248/119667378-33870280-be71-11eb-95aa-64213138ddac.png)
180 ![DS1Z_QuickPrint64](https://user-images.githubusercontent.com/2170248/119667504-52859480-be71-11eb-963e-eebc6e3da9dc.png)
181
182##### Connect a 500pF capacitor between C2 line and GND, Press R0C2, R1C2, R2C2, R3C2, R4C2 keys
183 - CH1: Row 0
184 - CH2: Row 1
185 - CH3: Col 2
186 - CH4: delay time
187 - Delay time 13.2us
188 - Frequency of matrix scan 6.58kHz (152.6us)
189 - Threshold Voltage 1.9V
190 ![DS1Z_QuickPrint65](https://user-images.githubusercontent.com/2170248/119667644-72b55380-be71-11eb-8030-854de1900408.png)
191
192##### Connect a 1000pF capacitor between C2 line and GND, Press R0C2, R1C2, R2C2, R3C2, R4C2 keys
193 - CH1: Row 0
194 - CH2: Row 1
195 - CH3: Col 2
196 - CH4: delay time
197 - Delay time 20us
198 - Frequency of matrix scan 5.30kHz (188.8us)
199 - Threshold Voltage 1.9V
200 ![DS1Z_QuickPrint66](https://user-images.githubusercontent.com/2170248/119667785-8f518b80-be71-11eb-8d40-fc3293aa072b.png)
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/cpp_map.h b/keyboards/handwired/symmetric70_proto/matrix_fast/cpp_map.h
new file mode 100644
index 000000000..d197be6d9
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/cpp_map.h
@@ -0,0 +1,53 @@
1/* Copyright 2021 mtei
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16#pragma once
17// clang-format off
18
19#define _MAP1(E, _1) E(_1)
20#define _MAP2(E, _1,_2) E(_1) E(_2)
21#define _MAP3(E, _1,_2,_3) E(_1) E(_2) E(_3)
22#define _MAP4(E, _1,_2,_3,_4) E(_1) E(_2) E(_3) E(_4)
23#define _MAP5(E, _1,_2,_3,_4,_5) E(_1) E(_2) E(_3) E(_4) E(_5)
24#define _MAP6(E, _1,_2,_3,_4,_5,_6) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6)
25#define _MAP7(E, _1,_2,_3,_4,_5,_6,_7) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7)
26#define _MAP8(E, _1,_2,_3,_4,_5,_6,_7,_8) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8)
27#define _MAP9(E, _1,_2,_3,_4,_5,_6,_7,_8,_9) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9)
28#define _MAP10(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10)
29#define _MAP11(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11)
30#define _MAP12(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12)
31#define _MAP13(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13)
32#define _MAP14(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14)
33#define _MAP15(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15)
34#define _MAP16(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16)
35#define _MAP17(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17)
36#define _MAP18(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18)
37#define _MAP19(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19)
38#define _MAP20(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20)
39#define _MAP21(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21)
40#define _MAP22(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22)
41#define _MAP23(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23)
42#define _MAP24(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24)
43#define _MAP25(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25)
44#define _MAP26(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26)
45#define _MAP27(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27)
46#define _MAP28(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27) E(_28)
47#define _MAP29(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27) E(_28) E(_29)
48#define _MAP30(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27) E(_28) E(_29) E(_30)
49#define _MAP31(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27) E(_28) E(_29) E(_30) E(_31)
50#define _MAP32(E, _1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31,_32) E(_1) E(_2) E(_3) E(_4) E(_5) E(_6) E(_7) E(_8) E(_9) E(_10) E(_11) E(_12) E(_13) E(_14) E(_15) E(_16) E(_17) E(_18) E(_19) E(_20) E(_21) E(_22) E(_23) E(_24) E(_25) E(_26) E(_27) E(_28) E(_29) E(_30) E(_31) E(_32)
51
52#define SELECT_MAP(e,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,_27,_28,_29,_30,_31,_32,NAME,...) NAME
53#define MAP(E,...) SELECT_MAP(E,__VA_ARGS__,_MAP32,_MAP31,_MAP30,_MAP29,_MAP28,_MAP27,_MAP26,_MAP25,_MAP24,_MAP23,_MAP22,_MAP21,_MAP20,_MAP19,_MAP18,_MAP17,_MAP16,_MAP15,_MAP14,_MAP13,_MAP12,_MAP11,_MAP10,_MAP9,_MAP8,_MAP7,_MAP6,_MAP5,_MAP4,_MAP3,_MAP2,_MAP1)(E,__VA_ARGS__)
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/gpio_extr.h b/keyboards/handwired/symmetric70_proto/matrix_fast/gpio_extr.h
new file mode 100644
index 000000000..e31cb5f3a
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/gpio_extr.h
@@ -0,0 +1,28 @@
1#pragma once
2// clang-format off
3
4#if defined(__AVR__)
5typedef uint8_t port_data_t;
6
7#define readPort(port) PINx_ADDRESS(port)
8
9#define setPortBitInput(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
10#define setPortBitInputHigh(port, bit) (DDRx_ADDRESS(port) &= ~_BV((bit)&0xF), PORTx_ADDRESS(port) |= _BV((bit)&0xF))
11#define setPortBitOutput(port, bit) (DDRx_ADDRESS(port) |= _BV((bit)&0xF))
12
13#define writePortBitLow(port, bit) (PORTx_ADDRESS(port) &= ~_BV((bit)&0xF))
14#define writePortBitHigh(port, bit) (PORTx_ADDRESS(port) |= _BV((bit)&0xF))
15
16#else
17typedef uint16_t port_data_t;
18
19#define readPort(qmk_pin) palReadPort(PAL_PORT(qmk_pin))
20
21#define setPortBitInput(qmk_pin, bit) palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT)
22#define setPortBitInputHigh(qmk_pin, bit) palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT_PULLUP)
23#define setPortBitInputLow(qmk_pin, bit) palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_INPUT_PULLDOWN)
24#define setPortBitOutput(qmk_pin, bit) palSetPadMode(PAL_PORT(qmk_pin), bit, PAL_MODE_OUTPUT_PUSHPULL)
25
26#define writePortBitLow(qmk_pin, bit) palClearLine(PAL_LINE(PAL_PORT(qmk_pin), bit))
27#define writePortBitHigh(qmk_pin, bit) palSetLine(PAL_LINE(PAL_PORT(qmk_pin), bit))
28#endif
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c
new file mode 100644
index 000000000..cb21bfcf8
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix.c
@@ -0,0 +1,234 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17// clang-format off
18#include <stdint.h>
19#include <stdbool.h>
20#include <gpio.h>
21#ifndef readPort
22# include "gpio_extr.h"
23#endif
24#include "util.h"
25#include "matrix.h"
26#include "matrix_extr.h"
27#include "debounce.h"
28#include "quantum.h"
29
30#define ALWAYS_INLINE inline __attribute__((always_inline))
31#define NO_INLINE __attribute__((noinline))
32#define LOCAL_FUNC static
33#define LOCAL_DATA static
34
35#ifndef _BV
36# define _BV(bit) (1 << (bit))
37#endif
38
39#ifndef MATRIX_DEBUG_PIN
40# define MATRIX_DEBUG_PIN_INIT()
41# define MATRIX_DEBUG_SCAN_START()
42# define MATRIX_DEBUG_SCAN_END()
43# define MATRIX_DEBUG_DELAY_START()
44# define MATRIX_DEBUG_DELAY_END()
45# define MATRIX_DEBUG_GAP()
46#else
47# define MATRIX_DEBUG_GAP() asm volatile("nop \n nop":::"memory")
48#endif
49
50typedef uint16_t port_width_t;
51#if MATRIX_TYPE == DIRECT_SWITCH || MATRIX_TYPE == DIODE_COL2ROW
52# define MATRIX_LINES MATRIX_ROWS
53typedef matrix_row_t matrix_line_t;
54#endif
55#if MATRIX_TYPE == DIODE_ROW2COL
56# define MATRIX_LINES MATRIX_COLS
57typedef matrix_col_t matrix_line_t;
58#endif
59typedef struct _port_descriptor {
60 int device;
61 pin_t port;
62} port_descriptor;
63
64/* matrix state(1:on, 0:off) */
65extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values
66extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values
67
68#define setPortBitOutput_writeLow(port, bit) \
69 do { setPortBitOutput(port, bit); writePortBitLow(port, bit); } while(0)
70#define setPortBitOutput_writeLow_atomic(port, bit) \
71 do { ATOMIC_BLOCK_FORCEON { setPortBitOutput_writeLow(port, bit); } } while(0)
72#define setPortBitInputHigh_atomic(port, bit) \
73 do { ATOMIC_BLOCK_FORCEON { setPortBitInputHigh(port, bit); } } while(0)
74
75#if defined(MATRIX_IN_PORTS) && defined(MATRIX_IN_PINS)
76# include "matrix_config_expand.c"
77#else
78# error matrix.c need defined MATRIX_IN_PORTS and MATRIX_IN_PINS
79#endif
80
81LOCAL_FUNC
82void unselect_output(uint8_t out_index) {
83 unselect_output_inline(out_index);
84}
85
86LOCAL_FUNC
87void init_output_ports(void) {
88 for (int i = 0; i < END_outpin_index; i++) {
89 unselect_output(i);
90 }
91}
92
93LOCAL_FUNC
94void init_all_ports(void) {
95 init_input_ports();
96 init_output_ports();
97 init_inport_mask();
98 init_extension();
99}
100
101LOCAL_FUNC ALWAYS_INLINE void select_line_and_read_input_ports(uint8_t current_line, port_width_t port_buffer[NUM_OF_INPUT_PORTS]);
102LOCAL_FUNC void select_line_and_read_input_ports(uint8_t current_line, port_width_t port_buffer[NUM_OF_INPUT_PORTS]) {
103 // Select row (or col)
104 select_output(current_line);
105 matrix_output_select_delay();
106
107 // Read ports
108 read_all_input_ports(port_buffer, false);
109
110 // Unselect row (or col)
111 unselect_output_inline(current_line);
112}
113
114LOCAL_FUNC ALWAYS_INLINE void read_matrix_line(matrix_line_t phy_matrix[], uint8_t current_line);
115
116#if MATRIX_TYPE == DIODE_ROW2COL || MATRIX_TYPE == DIODE_COL2ROW
117LOCAL_FUNC void read_matrix_line(matrix_line_t phy_matrix[], uint8_t current_line) {
118 // Start with a clear matrix row
119 matrix_line_t current_line_value = 0;
120 port_width_t port_buffer[NUM_OF_INPUT_PORTS];
121
122#ifdef MATRIX_GPIO_NEED_SEPARATE_ATOMIC
123 select_line_and_read_input_ports(current_line, port_buffer);
124#else
125 ATOMIC_BLOCK_FORCEON {
126 select_line_and_read_input_ports(current_line, port_buffer);
127 }
128#endif
129
130 // Build row (or col)
131 current_line_value = build_matrix_line(port_buffer);
132
133 // Wait signal raise up
134 if (current_line_value) {
135 MATRIX_DEBUG_DELAY_START();
136 wait_unselect_done();
137 MATRIX_DEBUG_DELAY_END();
138 }
139 phy_matrix[current_line] = current_line_value;
140}
141#endif // MATRIX_TYPE == DIODE_ROW2COL || MATRIX_TYPE == DIODE_COL2ROW
142
143#if MATRIX_TYPE == DIRECT_SWITCH
144LOCAL_FUNC void read_matrix_line(matrix_line_t phy_matrix[], uint8_t current_line) {
145 port_width_t port_buffer[NUM_OF_INPUT_PORTS];
146
147 if (current_line != 0) {
148 return;
149 }
150
151 for (uint8_t i = 0; i < MATRIX_LINES; i++) {
152 phy_matrix[i] = 0;
153 }
154
155 read_all_input_ports(port_buffer, false);
156
157 // Build matrix
158 build_matrix_direct(port_buffer, phy_matrix);
159}
160#endif // MATRIX_TYPE == DIRECT_SWITCH
161
162void matrix_init(void) {
163 // initialize key pins
164 init_all_ports();
165
166 // initialize matrix state: all keys off
167 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
168 raw_matrix[i] = 0;
169 matrix[i] = 0;
170 }
171
172 debounce_init(MATRIX_ROWS);
173
174 matrix_init_quantum();
175}
176
177uint8_t matrix_scan(void) {
178 matrix_line_t phy_matrix[MATRIX_LINES];
179
180 MATRIX_DEBUG_PIN_INIT();
181
182 MATRIX_DEBUG_SCAN_START();
183
184 // read I/O port to phy_matrix[] (physical matrix)
185 //select line, read inputs
186 for (uint8_t current_line = 0; current_line < MATRIX_LINES; current_line++) {
187 read_matrix_line(phy_matrix, current_line);
188 }
189 MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP(); MATRIX_DEBUG_SCAN_START();
190
191 bool changed = false;
192#if MATRIX_TYPE == DIRECT_SWITCH || MATRIX_TYPE == DIODE_COL2ROW
193 // copy phy_matrix[] to raw_matrix[]
194 for (uint8_t current_line = 0; current_line < MATRIX_ROWS; current_line++) {
195 if (raw_matrix[current_line] != phy_matrix[current_line]) {
196 changed = true;
197 raw_matrix[current_line] = phy_matrix[current_line];
198 }
199 }
200#endif
201#if MATRIX_TYPE == DIODE_ROW2COL
202 // transpose phy_matrix[] to raw_matrix[]
203 matrix_row_t trans_matrix[MATRIX_ROWS];
204 for (uint8_t i = 0; i < MATRIX_ROWS; i++ ) {
205 trans_matrix[i] = 0;
206 }
207 for (uint8_t src_line = 0; src_line < MATRIX_LINES; src_line++) {
208 matrix_line_t src_line_data = phy_matrix[src_line];
209 matrix_row_t dist_bit = MATRIX_ROW_SHIFTER << src_line;
210 for (uint8_t dist_rows = 0; dist_rows < MATRIX_ROWS; dist_rows++) {
211 if ((src_line_data & 1) == 1) {
212 trans_matrix[dist_rows] |= dist_bit;
213 }
214 src_line_data >>= 1;
215 }
216 }
217 for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) {
218 if (raw_matrix[current_row] != trans_matrix[current_row]) {
219 changed = true;
220 raw_matrix[current_row] = trans_matrix[current_row];
221 }
222 }
223#endif
224 MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP(); MATRIX_DEBUG_SCAN_START();
225
226 // debounce raw_matrix[] to matrix[]
227 debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
228 MATRIX_DEBUG_SCAN_END(); MATRIX_DEBUG_GAP();
229
230 MATRIX_DEBUG_SCAN_START();
231 matrix_scan_quantum();
232 MATRIX_DEBUG_SCAN_END();
233 return (uint8_t)changed;
234}
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c
new file mode 100644
index 000000000..0df605db4
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_config_expand.c
@@ -0,0 +1,234 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17// clang-format off
18
19#include "matrix_extr.h"
20
21#ifdef DEBUG_MATRIX_CONFIG
22// config expand debug
23// avr-gcc -DDEBUG_MATRIX_CONFIG=\"test_config.h\" -E -C matrix_config_expand.c
24# include DEBUG_MATRIX_CONFIG
25#endif
26
27#undef NO_PIN /* cancel NO_PIN define in tmk_core/common/pin_defs.h */
28#define NO_PIN NO_PORT, 0
29#if MATRIX_TYPE == DIRECT_SWITCH
30# undef MATRIX_OUT_PORTS
31# define MATRIX_OUT_PINS (0, NO_PIN)
32#endif
33
34#include "cpp_map.h"
35
36#if defined(MATRIX_EXTENSION_74HC157) || defined(MATRIX_EXTENSION_74HC153)
37# define MATRIX_EXTENSION "matrix_extension_74hc15x.c"
38#endif
39
40#ifdef MATRIX_EXTENSION
41# include MATRIX_EXTENSION
42#endif
43
44#ifdef MATRIX_GPIO_NEED_SEPARATE_ATOMIC
45# ifndef setMatrixInputHigh
46# define setMatrixInputHigh(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitInputHigh_atomic(port, bit); }} while(0)
47# endif
48# ifndef setMatrixOutput_writeHighZ
49# define setMatrixOutput_writeHighZ(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitInputHigh_atomic(port, bit); }} while(0)
50# endif
51# ifndef setMatrixOutput_writeLow
52# define setMatrixOutput_writeLow(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitOutput_writeLow_atomic(port, bit); }} while(0)
53# endif
54#else
55# ifndef setMatrixInputHigh
56# define setMatrixInputHigh(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitInputHigh(port, bit); }} while(0)
57# endif
58# ifndef setMatrixOutput_writeHighZ
59# define setMatrixOutput_writeHighZ(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitInputHigh(port, bit); }} while(0)
60# endif
61# ifndef setMatrixOutput_writeLow
62# define setMatrixOutput_writeLow(dev, port, bit) do { if ((dev) == MCU_GPIO) { setPortBitOutput_writeLow(port, bit); }} while(0)
63# endif
64#endif
65
66#ifndef readMatrixPort
67# define readMatrixPort(dev, port) (((dev) == MCU_GPIO) ? readPort(port) : 0)
68#endif
69#ifndef getMatrixInputMaskBit
70# define getMatrixInputMaskBit(dev, bit) (((dev) != NO_DEVICE) ? _BV((bit)&0xF) : 0)
71#endif
72
73#ifndef init_extension
74# define init_extension()
75#endif
76
77enum DEVICE_NAME {
78 MCU_GPIO,
79 NO_DEVICE,
80#ifdef MATRIX_DEVICES
81 MATRIX_DEVICES
82#endif
83};
84
85#define _INPUT_PORTS_ENUM_ELEMENT(name, dev, port) inport_index_##name,
86#define INPUT_PORTS_ENUM_ELEMENT(x) _INPUT_PORTS_ENUM_ELEMENT x
87enum INPUT_PORTS {
88 INPUT_PORTS_ENUM_ELEMENT((NO_PORT, NO_DEVICE, 0))
89 MAP(INPUT_PORTS_ENUM_ELEMENT, MATRIX_IN_PORTS)
90 NUM_OF_INPUT_PORTS
91};
92
93#define _INPUT_PINS_ENUM_ELEMENT(index, port, bit) inpin_index_##index,
94#define INPUT_PINS_ENUM_ELEMENT(x) _INPUT_PINS_ENUM_ELEMENT x
95enum INPUT_PINS {
96 MAP(INPUT_PINS_ENUM_ELEMENT, MATRIX_IN_PINS)
97 END_inpin_index
98};
99
100#define _OUTPUT_PORTS_ENUM_ELEMENT(name, dev, port) outport_index_##name,
101#define OUTPUT_PORTS_ENUM_ELEMENT(x) _OUTPUT_PORTS_ENUM_ELEMENT x
102enum OUTPUT_PORTS {
103 OUTPUT_PORTS_ENUM_ELEMENT((NO_PORT, NO_DEVICE, 0))
104#ifdef MATRIX_OUT_PORTS
105 MAP(OUTPUT_PORTS_ENUM_ELEMENT, MATRIX_OUT_PORTS)
106#endif
107 NUM_OF_OUTPUT_PORTS
108};
109
110#define _OUTPUT_PINS_ENUM_ELEMENT(index, port, bit) outpin_index_##index,
111#define OUTPUT_PINS_ENUM_ELEMENT(x) _OUTPUT_PINS_ENUM_ELEMENT x
112enum OUTPUT_PINS {
113 MAP(OUTPUT_PINS_ENUM_ELEMENT, MATRIX_OUT_PINS)
114 END_outpin_index
115};
116
117port_width_t iport_mask[NUM_OF_INPUT_PORTS];
118
119#define _INPUT_PORTS_LIST_ELEMENT(name, dev, port) \
120 [inport_index_##name] = { dev, port },
121#define INPUT_PORTS_LIST_ELEMENT(x) _INPUT_PORTS_LIST_ELEMENT x
122LOCAL_DATA
123const port_descriptor inport_list[NUM_OF_INPUT_PORTS] = {
124 INPUT_PORTS_LIST_ELEMENT((NO_PORT, NO_DEVICE, 0))
125 MAP(INPUT_PORTS_LIST_ELEMENT, MATRIX_IN_PORTS)
126};
127
128#define _OUTPUT_PORTS_LIST_ELEMENT(name, dev, port) \
129 [outport_index_##name] = { dev, port },
130#define OUTPUT_PORTS_LIST_ELEMENT(x) _OUTPUT_PORTS_LIST_ELEMENT x
131LOCAL_DATA
132const port_descriptor outport_list[NUM_OF_OUTPUT_PORTS] = {
133 OUTPUT_PORTS_LIST_ELEMENT((NO_PORT, NO_DEVICE, 0))
134#ifdef MATRIX_OUT_PORTS
135 MAP(OUTPUT_PORTS_LIST_ELEMENT, MATRIX_OUT_PORTS)
136#endif
137};
138
139#define _SELECT_OUTPUT_PIN(index, pname, bit) \
140 case outpin_index_##index: \
141 setMatrixOutput_writeLow(outport_list[outport_index_##pname].device, \
142 outport_list[outport_index_##pname].port, bit); \
143 break;
144#define SELECT_OUTPUT_PIN(x) _SELECT_OUTPUT_PIN x
145LOCAL_FUNC ALWAYS_INLINE void select_output(uint8_t out_index);
146LOCAL_FUNC
147void select_output(uint8_t out_index) {
148 switch (out_index) {
149 MAP(SELECT_OUTPUT_PIN, MATRIX_OUT_PINS)
150 }
151}
152
153#define _UNSELECT_OUTPUT_PIN(index, pname, bit) \
154 case outpin_index_##index: \
155 setMatrixOutput_writeHighZ(outport_list[outport_index_##pname].device, \
156 outport_list[outport_index_##pname].port, bit); \
157 break;
158#define UNSELECT_OUTPUT_PIN(x) _UNSELECT_OUTPUT_PIN x
159LOCAL_FUNC ALWAYS_INLINE void unselect_output_inline(uint8_t out_index);
160LOCAL_FUNC
161void unselect_output_inline(uint8_t out_index) {
162 switch (out_index) {
163 MAP(UNSELECT_OUTPUT_PIN, MATRIX_OUT_PINS)
164 }
165}
166
167#define _INIT_INPUT_PIN(index, pname, bit) \
168 setMatrixInputHigh(inport_list[inport_index_##pname].device, \
169 inport_list[inport_index_##pname].port, bit);
170#define INIT_INPUT_PIN(x) _INIT_INPUT_PIN x
171LOCAL_FUNC
172void init_input_ports(void) {
173 MAP(INIT_INPUT_PIN, MATRIX_IN_PINS)
174}
175
176#define _INIT_INPORT_MASK(index, pname, bit) \
177 iport_mask[inport_index_##pname] |= getMatrixInputMaskBit(inport_list[inport_index_##pname].device, bit);
178#define INIT_INPORT_MASK(x) _INIT_INPORT_MASK x
179LOCAL_FUNC
180void init_inport_mask(void) {
181 for (int i = 0; i < NUM_OF_INPUT_PORTS; i++ ) {
182 iport_mask[i] = 0;
183 }
184 MAP(INIT_INPORT_MASK, MATRIX_IN_PINS)
185}
186
187#define _READ_INPUT_PORT(name, dev, port) \
188 buffer[inport_index_##name] = readMatrixPort(dev, port);
189#define READ_INPUT_PORT(x) _READ_INPUT_PORT x
190LOCAL_FUNC
191ALWAYS_INLINE void read_all_input_ports(port_width_t buffer[NUM_OF_INPUT_PORTS], bool wait_unselect);
192LOCAL_FUNC
193void read_all_input_ports(port_width_t buffer[NUM_OF_INPUT_PORTS], bool wait_unselect) {
194 READ_INPUT_PORT((NO_PORT, NO_DEVICE, 0))
195 MAP(READ_INPUT_PORT, MATRIX_IN_PORTS)
196}
197
198#define _MASK_INPUT(name, dev, port) \
199 mask |= ((~buffer[inport_index_##name]) & iport_mask[inport_index_##name]);
200#define MASK_INPUT(x) _MASK_INPUT x
201LOCAL_FUNC ALWAYS_INLINE void wait_unselect_done(void);
202LOCAL_FUNC
203void wait_unselect_done(void) {
204 port_width_t mask;
205 port_width_t buffer[NUM_OF_INPUT_PORTS];
206 do {
207 read_all_input_ports(buffer, true);
208 MATRIX_DEBUG_DELAY_END();
209 mask = 0;
210 MAP(MASK_INPUT, MATRIX_IN_PORTS);
211 MATRIX_DEBUG_DELAY_START();
212 } while (mask != 0);
213}
214
215#define _BUILD_INPUT_PORT(index, pname, bit) \
216 result |= (buffer[inport_index_##pname] & _BV(bit)) ? 0 : _BV(inpin_index_##index);
217#define BUILD_INPUT_PORT(x) _BUILD_INPUT_PORT x
218LOCAL_FUNC ALWAYS_INLINE matrix_line_t build_matrix_line(port_width_t buffer[NUM_OF_INPUT_PORTS]);
219LOCAL_FUNC
220matrix_line_t build_matrix_line(port_width_t buffer[NUM_OF_INPUT_PORTS]) {
221 matrix_line_t result = 0;
222 MAP(BUILD_INPUT_PORT, MATRIX_IN_PINS);
223 return result;
224}
225
226#define _BUILD_INPUT_PORT_DIRECT(index, pname, bit) \
227 matrix[(inpin_index_##index)/MATRIX_COLS] \
228 |= (buffer[inport_index_##pname] & _BV(bit)) ? 0 : _BV((inpin_index_##index)%MATRIX_COLS);
229#define BUILD_INPUT_PORT_DIRECT(x) _BUILD_INPUT_PORT_DIRECT x
230LOCAL_FUNC ALWAYS_INLINE void build_matrix_direct(port_width_t buffer[NUM_OF_INPUT_PORTS], matrix_line_t matrix[]);
231LOCAL_FUNC
232void build_matrix_direct(port_width_t buffer[NUM_OF_INPUT_PORTS], matrix_line_t matrix[]) {
233 MAP(BUILD_INPUT_PORT_DIRECT, MATRIX_IN_PINS);
234}
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extension_74hc15x.c b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extension_74hc15x.c
new file mode 100644
index 000000000..bca53da24
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extension_74hc15x.c
@@ -0,0 +1,72 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17// clang-format off
18
19#if defined(MATRIX_EXTENSION_74HC157)
20# define MATRIX_DEVICES MCU_GPIOa, MCU_GPIOb
21# define IS_74HC15x(dev) ((dev)==MCU_GPIOa || (dev)==MCU_GPIOb)
22# define MATRIX_EXT_74HC15x MATRIX_EXTENSION_74HC157
23#elif defined(MATRIX_EXTENSION_74HC153)
24# define MATRIX_DEVICES MCU_GPIOa, MCU_GPIOb, MCU_GPIOc, MCU_GPIOd
25# define IS_74HC15x(dev) ((dev)==MCU_GPIOa || (dev)==MCU_GPIOb || (dev)==MCU_GPIOc || (dev)==MCU_GPIOd)
26# define MATRIX_EXT_74HC15x MATRIX_EXTENSION_74HC153
27#endif
28
29static const pin_t sel_pins[] = { MATRIX_EXT_74HC15x };
30
31#ifdef MATRIX_GPIO_NEED_SEPARATE_ATOMIC
32# define setMatrixInputHigh(dev, port, bit) \
33 do { \
34 if ((dev) == MCU_GPIO || IS_74HC15x(dev)) { \
35 setPortBitInputHigh_atomic(port, bit); \
36 }
37 } while(0)
38#else
39# define setMatrixInputHigh(dev, port, bit) \
40 do { \
41 if ((dev) == MCU_GPIO || IS_74HC15x(dev)) { \
42 setPortBitInputHigh(port, bit); \
43 } \
44 } while(0)
45#endif
46
47LOCAL_FUNC ALWAYS_INLINE void select74HC15x(uint8_t devid);
48LOCAL_FUNC
49void select74HC15x(uint8_t devid) {
50 writePin(sel_pins[0], devid&1);
51#if defined(MATRIX_EXTENSION_74HC153)
52 writePin(sel_pins[1], devid&2);
53#endif
54}
55
56LOCAL_FUNC ALWAYS_INLINE port_width_t readPortMultiplexer(uint8_t devid, pin_t port);
57LOCAL_FUNC port_width_t readPortMultiplexer(uint8_t devid, pin_t port) {
58 select74HC15x(devid);
59 waitInputPinDelay();
60 return readPort(port);
61}
62
63#define readMatrixPort(dev, port) \
64 ((dev) == MCU_GPIO)? readPort(port): (IS_74HC15x(dev))? readPortMultiplexer((dev)-MCU_GPIOa, port):0
65
66#define INIT_74HC15X(x) setPinOutput(x); writePinLow(x);
67LOCAL_FUNC
68void init_74hc15x(void) {
69 MAP(INIT_74HC15X, MATRIX_EXT_74HC15x)
70}
71#define init_extension() init_74hc15x()
72
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extr.h b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extr.h
new file mode 100644
index 000000000..e0cf52891
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/matrix_extr.h
@@ -0,0 +1,36 @@
1#pragma once
2// clang-format off
3
4#define DIRECT_SWITCH 1
5#define DIODE_ROW2COL 2
6#define DIODE_COL2ROW 3
7
8#ifndef ROW2COL
9# define COL2ROW 0
10# define ROW2COL 1
11#endif
12
13#ifdef DIRECT_PINS
14# define MATRIX_TYPE DIRECT_SWITCH
15#else
16# if DIODE_DIRECTION == ROW2COL
17# define MATRIX_TYPE DIODE_ROW2COL
18# endif
19# if DIODE_DIRECTION == COL2ROW
20# define MATRIX_TYPE DIODE_COL2ROW
21# endif
22#endif
23
24#ifndef MATRIX_TYPE
25# error "MATRIX_TYPE could not be determined."
26#endif
27
28#if (MATRIX_ROWS <= 8)
29typedef uint8_t matrix_col_t;
30#elif (MATRIX_ROWS <= 16)
31typedef uint16_t matrix_col_t;
32#elif (MATRIX_ROWS <= 32)
33typedef uint32_t matrix_col_t;
34#else
35# error "MATRIX_ROWS: invalid value"
36#endif
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/readme.md b/keyboards/handwired/symmetric70_proto/matrix_fast/readme.md
new file mode 100644
index 000000000..dc744a4c4
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/readme.md
@@ -0,0 +1,168 @@
1# Fast and extensible matrix.c
2
3This matrix.c is faster and more extensible than the standard quantum/matrix.c.
4
5* The execution speed of the `matrix_scan()` function is several times faster than quantum/matrix.c.
6* In addition to handling MCU GPIOs, it can be extended to handle I/O extenders.
7
8## ToDo list
9- [x] support Pro Micro
10- [x] support Proton-C
11- [x] support DIRECT_PINS
12- [x] support DIODE_DIRECTION == ROW2COL
13- [x] support 74HC157: quadruple 2-line to 1-line data selectors / multiplexers
14- [x] support 74HC153: dual 4-line to 1-line data selectors / multiplexers
15- [ ] support I/O expander (MCP23018)
16- [ ] support MCU & I/O expander (MCP23018) mixture like ErgoDox
17
18## Configuration
19
20This matrix.c requires a different configuration than quantum/matrix.c.
21
22### Output pins configuration
23
24The output pins is the Row pins if `DIODE_DIRECTION == COL2ROW`, and the Col pins if `DIODE_DIRECTION == ROW2COL`. When DIRECT_PINS is defined, the output pins do not need to be set.
25
26Example:
27```c
28// list of OUTPUT(row) ports
29#define MATRIX_OUT_PORTS \
30 (Port_D, MCU_GPIO, D0), \
31 (Port_C, MCU_GPIO, C0), \
32 (Port_E, MCU_GPIO, E0), \
33 (Port_B, MCU_GPIO, B0)
34// list of OUTPUT pins
35#define MATRIX_OUT_PINS \
36 (0, Port_D, 4), \
37 (1, Port_C, 6), \
38 (2, Port_D, 7), \
39 (3, Port_E, 6), \
40 (4, Port_B, 4), \
41 (5, Port_B, 5)
42```
43
44### Input pins configuration
45
46The input pins is the Col pins if `DIODE_DIRECTION == COL2ROW`, and the Row pins if `DIODE_DIRECTION == ROW2COL`. When DIRECT_PINS is defined, the input pin settings will enumerate the connection pins of all switches.
47
48Example:
49```c
50// list of INPUT ports
51#define MATRIX_IN_PORTS (Port_F, MCU_GPIO, F0), (Port_B, MCU_GPIO, B0)
52// list of INPUT pins
53#define MATRIX_IN_PINS \
54 (0, Port_F, 4), \
55 (1, Port_F, 5), \
56 (2, Port_F, 6), \
57 (3, Port_F, 7), \
58 (4, Port_B, 1), \
59 (5, Port_B, 3)
60```
61
62### Multiplexer Extension
63
64By defining the `MATRIX_EXTENSION_74HC157` macro or `MATRIX_EXTENSION_74HC153` macro, you can connect a multiplexer to the GPIO to extend the input pins.
65
66Example:
67```c
68#define MATRIX_EXTENSION_74HC157 B2 /* or #define MATRIX_EXTENSION_74HC153 B2, B6 */
69
70// list of OUTPUT ports
71#define MATRIX_OUT_PORTS (Port_D, MCU_GPIO, D0), (Port_C, MCU_GPIO, C0), (Port_E, MCU_GPIO, E0), (Port_B, MCU_GPIO, B0)
72// list of OUTPUT pins
73#define MATRIX_OUT_PINS (0, Port_D, 4), (1, Port_C, 6), (2, Port_D, 7), (3, Port_E, 6), (4, Port_B, 4), (5, Port_B, 5)
74
75// list of INPUT ports
76#define MATRIX_IN_PORTS \
77 (Port_Fa, MCU_GPIOa, F0), \
78 (Port_Ba, MCU_GPIOa, B0), \
79 (Port_Fb, MCU_GPIOb, F0), \
80 (Port_Bb, MCU_GPIOb, B0)
81// list of INPUT pins
82#define MATRIX_IN_PINS \
83 (0, Port_Fa, 4), \
84 (1, Port_Fb, 5), \
85 (2, Port_Fb, 6), \
86 (3, Port_Fa, 7), \
87 (4, Port_Ba, 1), \
88 (5, Port_Bb, 3)
89```
90
91### I/O expander Extension
92
93I plan to provide extensions to support I/O expanders such as MCP23018 and PCA9555.
94
95## Compile
96
97* Measure the execution time of matrix_scan()
98 * `make MTEST=matrix_debug_scan[,<other options>..] handwired/symmetric70_proto/promicro/fast:default:flash`
99* Measure delay time.
100 * `make MTEST=matrix_debug_delay[,<other options>..] handwired/symmetric70_proto/promicro/fast:default:flash`
101
102## Measurement result
103### Pro Micro (ATmega32u4 16Mhz)
104#### Default setting (show `matrix_scan()` time)
105 - `make MTEST=matrix_debug_scan handwired/symmetric70_proto/promicro/fast:default:flash`
106 - CH1: Row 0
107 - CH2: Row 1
108 - CH3: Row 4
109 - CH4: matrix_scan()
110 - Execution time of matrix_scan() 75.6us
111 - Frequency of matrix scan 8.09kHz (123.6us)
112 ![DS1Z_QuickPrint7](https://user-images.githubusercontent.com/2170248/116003927-538d9100-a63b-11eb-9b36-7db47d9b1541.png)
113
114#### Default setting (show delay time)
115 - `make MTEST=matrix_debug_delay handwired/symmetric70_proto/promicro/fast:default:flash`
116##### Press R0C0 key
117 - CH1: Row 0
118 - CH2: Row 1
119 - CH3: Row 4
120 - CH4: delay time
121 - Frequency of matrix scan 7.84kHz (127.6us)
122
123![DS1Z_QuickPrint9](https://user-images.githubusercontent.com/2170248/116003974-99e2f000-a63b-11eb-9c9e-3b3b1025db66.png)
124![DS1Z_QuickPrint10](https://user-images.githubusercontent.com/2170248/116003978-a1a29480-a63b-11eb-97d8-5a6e11c0db2f.png)
125
126### Proton C
127#### Default setting (show `matrix_scan()` time)
128 - `make MTEST=matrix_debug_scan handwired/symmetric70_proto/proton_c/fast:default:flash`
129 - CH1: Row 0
130 - CH2: Row 1
131 - CH3: Row 4
132 - CH4: matrix_scan()
133 - Execution time of matrix_scan() 49.8us
134 - Frequency of matrix scan 15.1kHz (66.2.6us)
135
136![DS1Z_QuickPrint11](https://user-images.githubusercontent.com/2170248/116088141-8cca0d80-a6dc-11eb-8782-1d29c57690b8.png)
137
138#### Default setting (show delay time)
139 - `make MTEST=matrix_debug_delay handwired/symmetric70_proto/proton_c/fast:default:flash`
140##### Press R0C0 key
141 - CH1: Row 0
142 - CH2: Row 1
143 - CH3: Row 4
144 - CH4: delay time
145 - Frequency of matrix scan 13.9kHz (71.8us)
146
147![DS1Z_QuickPrint12](https://user-images.githubusercontent.com/2170248/116088247-a8cdaf00-a6dc-11eb-8a47-104694a40117.png)
148![DS1Z_QuickPrint13](https://user-images.githubusercontent.com/2170248/116088262-ac613600-a6dc-11eb-804c-7dcbd71c83d5.png)
149
150##### Connect a 500pF capacitor between C0 line and GND, Press R0C0, R1C0, R2C0, R3C0, R4C0 keys
151 - CH1: Row 0
152 - CH2: Row 1
153 - CH3: Col 0
154 - CH4: delay time
155 - Delay time 11.6us
156 - Threshold Voltage 1.9V
157
158![DS1Z_QuickPrint14](https://user-images.githubusercontent.com/2170248/116089205-90aa5f80-a6dd-11eb-89c4-72315c80ba0e.png)
159
160##### Connect a 1000pF capacitor between C0 line and GND, Press R0C0, R1C0, R2C0, R3C0, R4C0 keys
161 - CH1: Row 0
162 - CH2: Row 1
163 - CH3: Col 0
164 - CH4: delay time
165 - Delay time 18.6us
166 - Threshold Voltage 1.9V
167
168![DS1Z_QuickPrint15](https://user-images.githubusercontent.com/2170248/116089229-96a04080-a6dd-11eb-8b63-f91b03a9db0c.png)
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/test_config.h b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config.h
new file mode 100644
index 000000000..25b5d4e01
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config.h
@@ -0,0 +1,21 @@
1// list of OUTPUT(row) ports
2#define MATRIX_OUT_PORTS (Port_D, MCU_GPIO, D0), (Port_C, MCU_GPIO, C0), (Port_E, MCU_GPIO, E0), (Port_B, MCU_GPIO, B0)
3// list of OUTPUT(row) pins
4#define MATRIX_OUT_PINS \
5 (0, Port_D, 4), \
6 (1, Port_C, 6), \
7 (2, Port_D, 7), \
8 (3, Port_E, 6), \
9 (4, Port_B, 4), \
10 (5, Port_B, 5)
11
12// list of INPUT(col) ports
13#define MATRIX_IN_PORTS (Port_F, MCU_GPIO, F0), (Port_B, MCU_GPIO, B0)
14// list of INPUT(col) pins
15#define MATRIX_IN_PINS \
16 (0, Port_F, 4), \
17 (1, Port_F, 5), \
18 (2, Port_F, 6), \
19 (3, Port_F, 7), \
20 (4, Port_B, 1), \
21 (5, Port_B, 3)
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_74hc157.h b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_74hc157.h
new file mode 100644
index 000000000..6abc25b86
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_74hc157.h
@@ -0,0 +1,28 @@
1#define MATRIX_EXTENSION_74HC157 B2
2// #define MATRIX_EXTENSION_74HC153 B2, B6
3
4// list of OUTPUT(row) ports
5#define MATRIX_OUT_PORTS (Port_D, MCU_GPIO, D0), (Port_C, MCU_GPIO, C0), (Port_E, MCU_GPIO, E0), (Port_B, MCU_GPIO, B0)
6// list of OUTPUT(row) pins
7#define MATRIX_OUT_PINS \
8 (0, Port_D, 4), \
9 (1, Port_C, 6), \
10 (2, Port_D, 7), \
11 (3, Port_E, 6), \
12 (4, Port_B, 4), \
13 (5, Port_B, 5)
14
15// list of INPUT(col) ports
16#define MATRIX_IN_PORTS \
17 (Port_Fa, MCU_GPIOa, F0), \
18 (Port_Ba, MCU_GPIOa, B0), \
19 (Port_Fb, MCU_GPIOb, F0), \
20 (Port_Bb, MCU_GPIOb, B0)
21// list of INPUT(col) pins
22#define MATRIX_IN_PINS \
23 (0, Port_Fa, 4), \
24 (1, Port_Fb, 5), \
25 (2, Port_Fb, 6), \
26 (3, Port_Fa, 7), \
27 (4, Port_Ba, 1), \
28 (5, Port_Bb, 3)
diff --git a/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_direct.h b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_direct.h
new file mode 100644
index 000000000..aeea12950
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/matrix_fast/test_config_direct.h
@@ -0,0 +1,34 @@
1#if defined(__AVR__)
2/* -------------------- AVR (Pro Micro) ----------------------- */
3
4// old style
5#define DIRECT_PINS { { F4, NO_PIN, F5 }, { NO_PIN, F6, F7 }, { B1, B3, NO_PIN } }
6
7// new style
8// #define DIRECT_PINS
9#define MATRIX_IN_PORTS \
10 (Port_F, MCU_GPIO, F0), \
11 (Port_B, MCU_GPIO, B0)
12#define MATRIX_IN_PINS \
13 (0, Port_F, 4), (1, NO_PIN ), (2, Port_F, 5), \
14 (3, NO_PIN ), (4, Port_F, 6), (5, Port_F, 7), \
15 (6, Port_B, 1), (7, Port_B, 3), (8, NO_PIN )
16
17#else
18/* -------------------- ARM (PROTON-C) ----------------------- */
19
20// old style
21#define DIRECT_PINS { { A2, NO_PIN, A1 }, { NO_PIN, A0, B8 }, { B13, B14, NO_PIN } }
22
23// new style
24// #define DIRECT_PINS
25#define MATRIX_IN_PORTS \
26 (Port_A, MCU_GPIO, A0), \
27 (Port_B, MCU_GPIO, B0)
28#define MATRIX_IN_PINS \
29 (0, Port_A, 2), (1, NO_PIN ), (2, Port_A, 1), \
30 (3, NO_PIN ), (4, Port_A, 0), (5, Port_B, 8), \
31 (6, Port_B, 13), (7, Port_B, 14), (8, NO_PIN )
32
33#endif
34
diff --git a/keyboards/handwired/symmetric70_proto/config.h b/keyboards/handwired/symmetric70_proto/promicro/config.h
index 2cdce5802..2060c6260 100644
--- a/keyboards/handwired/symmetric70_proto/config.h
+++ b/keyboards/handwired/symmetric70_proto/promicro/config.h
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2020 mtei 2Copyright 2020-2021 mtei
3 3
4This program is free software: you can redistribute it and/or modify 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by 5it under the terms of the GNU General Public License as published by
@@ -24,29 +24,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
24#define PRODUCT_ID 0x2BE5 24#define PRODUCT_ID 0x2BE5
25#define DEVICE_VER 0x0001 25#define DEVICE_VER 0x0001
26#define MANUFACTURER mtei 26#define MANUFACTURER mtei
27#define PRODUCT Symmetric70 prototype 27#define PRODUCT Symmetric70 prototype promicro
28 28
29/* key matrix size */ 29/* key matrix size */
30#define MATRIX_ROWS 5 30#define MATRIX_ROWS 5
31#define MATRIX_COLS 16 31#define MATRIX_COLS 16
32 32
33/* 33/* Pro Micro **************************
34 * Keyboard Matrix Assignments 34 ====
35 * 35 +-------====------+
36 * Change this to how you wired your keyboard 36 MDEBUG | D3/TXO RAW |
37 * COLS: AVR pins used for columns, left to right 37 | D2/RXI GND |
38 * ROWS: AVR pins used for rows, top to bottom 38 | GND RST |
39 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) 39 | GND Vcc |
40 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) 40 | D1/SDA F4 | COL_0_1_L
41 * 41 | D0/SCL F5 | COL_2_3_L
42 */ 42 ROW_0 | D4 F6 | COL_4_5_L
43#define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 } 43 ROW_1 | C6 F7 | COL_6_7_L
44#define MATRIX_COL_PINS { F4,F4,F5,F5, F6,F6,F7,F7, B6,B6,B2,B2, B3,B3,B1,B1 } 44 ROW_2 | D7 SCK/B1 | COL_6_7_R
45#define UNUSED_PINS 45 ROW_3 | E6 MISO/B3 | COL_4_5_R
46 ROW_4 | B4 MOSI/B2 | COL_2_3_R
47 SEL_AB | B5 B6 | COL_0_1_R
48 +-----------------+
49***************************************/
46 50
47#define MATRIX_MUL_SEL { 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 } 51#define UNUSED_PINS
48/* use 74HC157: quadruple 2-line to 1-line data selectors / multiplexers */
49#define MATRIX_MUL_SELECT B5 /* 74HC157 pin1:~A/B */
50 52
51/* COL2ROW, ROW2COL */ 53/* COL2ROW, ROW2COL */
52#define DIODE_DIRECTION COL2ROW 54#define DIODE_DIRECTION COL2ROW
@@ -148,3 +150,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
148/* Bootmagic Lite key configuration */ 150/* Bootmagic Lite key configuration */
149//#define BOOTMAGIC_LITE_ROW 0 151//#define BOOTMAGIC_LITE_ROW 0
150//#define BOOTMAGIC_LITE_COLUMN 0 152//#define BOOTMAGIC_LITE_COLUMN 0
153
154#ifdef DEBUG_CONFIG
155# define MATRIX_DEBUG_PIN D3
156# include "../debug_config.h"
157#endif
diff --git a/keyboards/handwired/symmetric70_proto/promicro/fast/config.h b/keyboards/handwired/symmetric70_proto/promicro/fast/config.h
new file mode 100644
index 000000000..2553de1ab
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/fast/config.h
@@ -0,0 +1,52 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19#define MATRIX_OUT_PORTS \
20 (Port_D, MCU_GPIO, D0), \
21 (Port_C, MCU_GPIO, C0), \
22 (Port_E, MCU_GPIO, E0), \
23 (Port_B, MCU_GPIO, B0)
24#define MATRIX_OUT_PINS \
25 (0, Port_D, 4), \
26 (1, Port_C, 6), \
27 (2, Port_D, 7), \
28 (3, Port_E, 6), \
29 (4, Port_B, 4)
30#define MATRIX_EXTENSION_74HC157 B5
31#define MATRIX_IN_PORTS \
32 (Port_Fa, MCU_GPIOa, F0), \
33 (Port_Fb, MCU_GPIOb, F0), \
34 (Port_Ba, MCU_GPIOa, B0), \
35 (Port_Bb, MCU_GPIOb, B0)
36#define MATRIX_IN_PINS \
37 (0, Port_Fa, 4), \
38 (1, Port_Fb, 4), \
39 (2, Port_Fa, 5), \
40 (3, Port_Fb, 5), \
41 (4, Port_Fa, 6), \
42 (5, Port_Fb, 6), \
43 (6, Port_Fa, 7), \
44 (7, Port_Fb, 7), \
45 (8, Port_Bb, 6), \
46 (9, Port_Ba, 6), \
47 (10, Port_Bb, 2), \
48 (11, Port_Ba, 2), \
49 (12, Port_Bb, 3), \
50 (13, Port_Ba, 3), \
51 (14, Port_Bb, 1), \
52 (15, Port_Ba, 1)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/fast/readme.md b/keyboards/handwired/symmetric70_proto/promicro/fast/readme.md
new file mode 100644
index 000000000..9d1a8d8eb
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/fast/readme.md
@@ -0,0 +1 @@
[Look here](../readme.md)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk b/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk
new file mode 100644
index 000000000..de489fcab
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/fast/rules.mk
@@ -0,0 +1,6 @@
1CUSTOM_MATRIX = yes
2SRC += matrix_common.c
3SRC += matrix_fast/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/normal/config.h b/keyboards/handwired/symmetric70_proto/promicro/normal/config.h
new file mode 100644
index 000000000..e03f68584
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/normal/config.h
@@ -0,0 +1,41 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19/*
20 * Keyboard Matrix Assignments
21 *
22 * Change this to how you wired your keyboard
23 * COLS: AVR pins used for columns, left to right
24 * ROWS: AVR pins used for rows, top to bottom
25 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
26 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
27 *
28 */
29#define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 }
30#define MATRIX_COL_PINS { F4,F4,F5,F5, F6,F6,F7,F7, B6,B6,B2,B2, B3,B3,B1,B1 }
31
32#define MATRIX_MUL_SEL { 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 }
33/* use 74HC157: quadruple 2-line to 1-line data selectors / multiplexers */
34#define MATRIX_MUL_SELECT B5 /* 74HC157 pin1:~A/B */
35
36#ifdef MATRIX_IO_DELAY_ADAPTIVE_FAST
37# define MATRIX_IO_DELAY_PORTS B0, B0, F0, F0
38# define MATRIX_IO_DELAY_MULSEL 0, 1, 0, 1
39// 76543210 76543210 76543210 76543210
40# define MATRIX_IO_DELAY_MASKS 0b01001110, 0b01001110, 0b11110000, 0b11110000
41#endif
diff --git a/keyboards/handwired/symmetric70_proto/promicro/normal/readme.md b/keyboards/handwired/symmetric70_proto/promicro/normal/readme.md
new file mode 100644
index 000000000..9d1a8d8eb
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/normal/readme.md
@@ -0,0 +1 @@
[Look here](../readme.md)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk b/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk
new file mode 100644
index 000000000..0b2b707ef
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/normal/rules.mk
@@ -0,0 +1,6 @@
1CUSTOM_MATRIX = yes
2SRC += matrix_common.c
3SRC += matrix_debug/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/promicro/readme.md b/keyboards/handwired/symmetric70_proto/promicro/readme.md
new file mode 100644
index 000000000..c74063b99
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/promicro/readme.md
@@ -0,0 +1,27 @@
1# Pro Micro version of symmetric70_proto
2
3![symmetric70_proto](https://i.imgur.com/Br4pH9ol.jpg)
4<img width="80%" alt="matrix_74HC157d" src="https://user-images.githubusercontent.com/2170248/115988014-a3943580-a5f2-11eb-9a0a-038f7ea6a8d9.png">
5
6A compact 70keys keyboard (prototype) designed by mtei
7
8* Keyboard Maintainer: [mtei](https://github.com/mtei)
9* Hardware Supported: Pro Micro (ATmega32U4) & 74HC157
10* Hardware Availability: This is just prototype
11
12Make example for this keyboard (after setting up your build environment):
13
14 make handwired/symmetric70_proto/promicro/normal:default
15 make handwired/symmetric70_proto/promicro/fast:default
16
17Flashing example for this keyboard:
18
19 make handwired/symmetric70_proto/promicro/normal:default:flash
20 make handwired/symmetric70_proto/promicro/fast:default:flash
21
22Testing options: (see more options: [local_features.mk](../local_features.mk), [matrix_debug](../matrix_debug/readme.md) and [matrix_fast](../matrix_fast/readme.md) )
23
24 make MTEST=mdelay0 handwired/symmetric70_proto/promicro/normal:default:flash
25 make MTEST=mdelay0 handwired/symmetric70_proto/promicro/fast:default:flash
26
27See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/handwired/symmetric70_proto/rules.mk b/keyboards/handwired/symmetric70_proto/promicro/rules.mk
index 494dc6fba..822b1a84d 100644
--- a/keyboards/handwired/symmetric70_proto/rules.mk
+++ b/keyboards/handwired/symmetric70_proto/promicro/rules.mk
@@ -20,8 +20,3 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
20RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow 20RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
21BLUETOOTH_ENABLE = no # Enable Bluetooth 21BLUETOOTH_ENABLE = no # Enable Bluetooth
22AUDIO_ENABLE = no # Audio output 22AUDIO_ENABLE = no # Audio output
23
24CUSTOM_MATRIX = lite
25SRC += matrix.c
26
27## CONSOLE_ENABLE = yes # matrix dump
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/config.h b/keyboards/handwired/symmetric70_proto/proton_c/config.h
new file mode 100644
index 000000000..84586854f
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/config.h
@@ -0,0 +1,165 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include "config_common.h"
21
22/* USB Device descriptor parameter */
23#define VENDOR_ID 0xFEED
24#define PRODUCT_ID 0x2BE5
25#define DEVICE_VER 0x0001
26#define MANUFACTURER mtei
27#define PRODUCT Symmetric70 prototype proton-c
28
29/* key matrix size */
30#define MATRIX_ROWS 5
31#define MATRIX_COLS 16
32
33/* Proton-C **************************
34 ====
35 +-------====------+
36 DEBUG | A9/TX/SCL2 5V | (VUSB)
37 | A10/RX/SDA2 GND |
38 | GND FLASH |
39 | GND 3.3V | (VCC)
40 C15 | B7/SDA1 A2 | C0
41 C14 | B6/SCL1 A1 | C1
42 C13 | B5 A0 | C2
43 C12 | B4 SCL1/B8 | C3
44 C11 | B3 SCLK/B13 | C4
45 C10 | B2 MISO/B14 | C5
46 C9 | B1 MOSI/B15 | C6
47 C8 | B0 SDA1/B9 | C7
48 +---+ +---+
49 +---+ +---+
50 R0 | A4 B10 |
51 R1 | A5 B11 |
52 R2 | A6 B12 |
53 R3 | A7 A14 |
54 R4 | A8 A13 |
55 | A15 RST |
56 +-----------------+
57***************************************/
58
59#define UNUSED_PINS
60
61/* COL2ROW, ROW2COL */
62#define DIODE_DIRECTION COL2ROW
63
64/*
65 * Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
66 */
67//#define SOFT_SERIAL_PIN D0 // or D1, D2, D3, E6
68
69//#define BACKLIGHT_PIN B7
70//#define BACKLIGHT_LEVELS 3
71//#define BACKLIGHT_BREATHING
72
73//#define RGB_DI_PIN E2
74//#ifdef RGB_DI_PIN
75//# define RGBLED_NUM 16
76//# define RGBLIGHT_HUE_STEP 8
77//# define RGBLIGHT_SAT_STEP 8
78//# define RGBLIGHT_VAL_STEP 8
79//# define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
80//# define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
81/*== all animations enable ==*/
82//# define RGBLIGHT_ANIMATIONS
83/*== or choose animations ==*/
84//# define RGBLIGHT_EFFECT_BREATHING
85//# define RGBLIGHT_EFFECT_RAINBOW_MOOD
86//# define RGBLIGHT_EFFECT_RAINBOW_SWIRL
87//# define RGBLIGHT_EFFECT_SNAKE
88//# define RGBLIGHT_EFFECT_KNIGHT
89//# define RGBLIGHT_EFFECT_CHRISTMAS
90//# define RGBLIGHT_EFFECT_STATIC_GRADIENT
91//# define RGBLIGHT_EFFECT_RGB_TEST
92//# define RGBLIGHT_EFFECT_ALTERNATING
93/*== customize breathing effect ==*/
94/*==== (DEFAULT) use fixed table instead of exp() and sin() ====*/
95//# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256(default) or 128 or 64
96/*==== use exp() and sin() ====*/
97//# define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 // 1 to 2.7
98//# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0 to 255
99//#endif
100
101/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
102#define DEBOUNCE 5
103
104/* define if matrix has ghost (lacks anti-ghosting diodes) */
105//#define MATRIX_HAS_GHOST
106
107/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
108#define LOCKING_SUPPORT_ENABLE
109/* Locking resynchronize hack */
110#define LOCKING_RESYNC_ENABLE
111
112/* If defined, GRAVE_ESC will always act as ESC when CTRL is held.
113 * This is useful for the Windows task manager shortcut (ctrl+shift+esc).
114 */
115//#define GRAVE_ESC_CTRL_OVERRIDE
116
117/*
118 * Force NKRO
119 *
120 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
121 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
122 * makefile for this to work.)
123 *
124 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
125 * until the next keyboard reset.
126 *
127 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
128 * fully operational during normal computer usage.
129 *
130 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
131 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
132 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
133 * power-up.
134 *
135 */
136//#define FORCE_NKRO
137
138/*
139 * Feature disable options
140 * These options are also useful to firmware size reduction.
141 */
142
143/* disable debug print */
144//#define NO_DEBUG
145
146/* disable print */
147//#define NO_PRINT
148
149/* disable action features */
150//#define NO_ACTION_LAYER
151//#define NO_ACTION_TAPPING
152//#define NO_ACTION_ONESHOT
153
154/* disable these deprecated features by default */
155#define NO_ACTION_MACRO
156#define NO_ACTION_FUNCTION
157
158/* Bootmagic Lite key configuration */
159//#define BOOTMAGIC_LITE_ROW 0
160//#define BOOTMAGIC_LITE_COLUMN 0
161
162#ifdef DEBUG_CONFIG
163# define MATRIX_DEBUG_PIN A9
164# include "../debug_config.h"
165#endif
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/fast/config.h b/keyboards/handwired/symmetric70_proto/proton_c/fast/config.h
new file mode 100644
index 000000000..48c3ec1c0
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/fast/config.h
@@ -0,0 +1,44 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19#define MATRIX_OUT_PORTS (Port_A, MCU_GPIO, A0)
20#define MATRIX_OUT_PINS \
21 (0, Port_A, 4), \
22 (1, Port_A, 5), \
23 (2, Port_A, 6), \
24 (3, Port_A, 7), \
25 (4, Port_A, 8)
26#define MATRIX_IN_PORTS \
27 (Port_A, MCU_GPIO, A0), (Port_B, MCU_GPIO, B0)
28#define MATRIX_IN_PINS \
29 (0, Port_A, 2), \
30 (1, Port_A, 1), \
31 (2, Port_A, 0), \
32 (3, Port_B, 8), \
33 (4, Port_B, 13), \
34 (5, Port_B, 14), \
35 (6, Port_B, 15), \
36 (7, Port_B, 9), \
37 (8, Port_B, 0), \
38 (9, Port_B, 1), \
39 (10, Port_B, 2), \
40 (11, Port_B, 3), \
41 (12, Port_B, 4), \
42 (13, Port_B, 5), \
43 (14, Port_B, 6), \
44 (15, Port_B, 7)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/fast/readme.md b/keyboards/handwired/symmetric70_proto/proton_c/fast/readme.md
new file mode 100644
index 000000000..9d1a8d8eb
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/fast/readme.md
@@ -0,0 +1 @@
[Look here](../readme.md)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk b/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk
new file mode 100644
index 000000000..de489fcab
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/fast/rules.mk
@@ -0,0 +1,6 @@
1CUSTOM_MATRIX = yes
2SRC += matrix_common.c
3SRC += matrix_fast/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/normal/config.h b/keyboards/handwired/symmetric70_proto/proton_c/normal/config.h
new file mode 100644
index 000000000..942e54c79
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/normal/config.h
@@ -0,0 +1,36 @@
1/*
2Copyright 2021 mtei
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19/*
20 * Keyboard Matrix Assignments
21 *
22 * Change this to how you wired your keyboard
23 * COLS: AVR pins used for columns, left to right
24 * ROWS: AVR pins used for rows, top to bottom
25 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
26 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
27 *
28 */
29#define MATRIX_ROW_PINS { A4, A5, A6, A7, A8 }
30#define MATRIX_COL_PINS { A2, A1, A0, B8, B13, B14, B15, B9, B0, B1, B2, B3, B4, B5, B6, B7 }
31
32#ifdef MATRIX_IO_DELAY_ADAPTIVE_FAST
33# define MATRIX_IO_DELAY_PORTS A0, B0
34// fedcba9876543210 fedcba9876543210
35# define MATRIX_IO_DELAY_MASKS 0b0000000000000111, 0b1110001111111111
36#endif
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/normal/readme.md b/keyboards/handwired/symmetric70_proto/proton_c/normal/readme.md
new file mode 100644
index 000000000..9d1a8d8eb
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/normal/readme.md
@@ -0,0 +1 @@
[Look here](../readme.md)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk b/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk
new file mode 100644
index 000000000..0b2b707ef
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/normal/rules.mk
@@ -0,0 +1,6 @@
1CUSTOM_MATRIX = yes
2SRC += matrix_common.c
3SRC += matrix_debug/matrix.c
4
5KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))../../local_features.mk
6include $(KEYBOARD_LOCAL_FEATURES_MK)
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/proton_c.c b/keyboards/handwired/symmetric70_proto/proton_c/proton_c.c
new file mode 100644
index 000000000..3fe5bc297
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/proton_c.c
@@ -0,0 +1,12 @@
1#include "quantum.h"
2
3#ifndef MATRIX_IO_DELAY_DEFAULT
4/* In tmk_core/common/wait.h, the implementation for PROTOCOL_CHIBIOS
5 * calls 'chThdSleepMicroseconds(1)' when 'wait_us(0)'.
6 * However, 'wait_us(0)' should do nothing. */
7void matrix_output_unselect_delay(void) {
8# if !defined(MATRIX_IO_DELAY) || MATRIX_IO_DELAY > 0
9 matrix_io_delay();
10# endif
11}
12#endif
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/readme.md b/keyboards/handwired/symmetric70_proto/proton_c/readme.md
new file mode 100644
index 000000000..fc10a2e63
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/readme.md
@@ -0,0 +1,26 @@
1# Proton C version of symmetric70_proto
2
3![symmetric70_proto](https://i.imgur.com/SCtlXOS.jpg)
4
5A compact 70keys keyboard (prototype) designed by mtei
6
7* Keyboard Maintainer: [mtei](https://github.com/mtei)
8* Hardware Supported: Proton C (STM32F303CCT6)
9* Hardware Availability: This is just prototype
10
11Make example for this keyboard (after setting up your build environment):
12
13 make handwired/symmetric70_proto/proton_c/normal:default
14 make handwired/symmetric70_proto/proton_c/fast:default
15
16Flashing example for this keyboard:
17
18 make handwired/symmetric70_proto/proton_c/normal:default:flash
19 make handwired/symmetric70_proto/proton_c/fast:default:flash
20
21Testing options: (see more options: [local_features.mk](../local_features.mk), [matrix_debug](../matrix_debug/readme.md) and [matrix_fast](../matrix_fast/readme.md) )
22
23 make MTEST=mdelay0 handwired/symmetric70_proto/proton_c/normal:default:flash
24 make MTEST=mdelay0 handwired/symmetric70_proto/proton_c/fast:default:flash
25
26See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
diff --git a/keyboards/handwired/symmetric70_proto/proton_c/rules.mk b/keyboards/handwired/symmetric70_proto/proton_c/rules.mk
new file mode 100644
index 000000000..e8b094846
--- /dev/null
+++ b/keyboards/handwired/symmetric70_proto/proton_c/rules.mk
@@ -0,0 +1,23 @@
1# MCU name
2MCU = STM32F303
3BOARD = QMK_PROTON_C
4
5# Bootloader selection
6BOOTLOADER = stm32-dfu
7
8# Build Options
9# change yes to no to disable
10#
11BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = no # Mouse keys
13EXTRAKEY_ENABLE = no # Audio control and System control
14CONSOLE_ENABLE = no # Console for debug
15COMMAND_ENABLE = no # Commands for debug and configuration
16# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
17SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
18# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
19NKRO_ENABLE = no # USB Nkey Rollover
20BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
21RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
22BLUETOOTH_ENABLE = no # Enable Bluetooth
23AUDIO_ENABLE = no # Audio output
diff --git a/keyboards/handwired/symmetric70_proto/readme.md b/keyboards/handwired/symmetric70_proto/readme.md
index 01c2889c2..1bb56cf4f 100644
--- a/keyboards/handwired/symmetric70_proto/readme.md
+++ b/keyboards/handwired/symmetric70_proto/readme.md
@@ -1,20 +1,8 @@
1# symmetric70_proto 1# symmetric70_proto
2 2
3![symmetric70_proto](https://i.imgur.com/Br4pH9ol.jpg) 3![symmetric70_proto](https://i.imgur.com/Br4pH9ol.jpg)
4![74HC157_schematic](https://i.imgur.com/8IU8Jgcl.jpg)
5 4
6A compact 70keys keyboard (prototype) designed by mtei 5A compact 70keys keyboard (prototype) designed by mtei
7 6
8* Keyboard Maintainer: [mtei](https://github.com/mtei) 7* [Pro Micro version of symmetric70_proto](promicro/readme.md)
9* Hardware Supported: Pro Micro (ATmega32U4) & 74HC157 8* [Proton-C version of symmetric70_proto](proton_c/readme.md)
10* Hardware Availability: This is just prototype
11
12Make example for this keyboard (after setting up your build environment):
13
14 make symmetric70_proto:default
15
16Flashing example for this keyboard:
17
18 make symmetric70_proto:default:flash
19
20See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).