diff options
author | Nick Brassel <nick@tzarc.org> | 2021-06-01 15:10:39 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 15:10:39 +1000 |
commit | e5d3e5a98969e59d702fefb2690ec582699e129b (patch) | |
tree | 005fee48c797c276b816a75520a55b90cefe6c43 | |
parent | d64a853b552885ed8d154793fc2506f727a670a7 (diff) | |
download | qmk_firmware-e5d3e5a98969e59d702fefb2690ec582699e129b.tar.gz qmk_firmware-e5d3e5a98969e59d702fefb2690ec582699e129b.zip |
Add weak refs on reading rows/cols. (#13062)
-rw-r--r-- | quantum/matrix.c | 18 | ||||
-rw-r--r-- | quantum/split_common/matrix.c | 18 |
2 files changed, 18 insertions, 18 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index 34d6af2e6..9298661ad 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
@@ -47,7 +47,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) { | |||
47 | 47 | ||
48 | #ifdef DIRECT_PINS | 48 | #ifdef DIRECT_PINS |
49 | 49 | ||
50 | static void init_pins(void) { | 50 | __attribute__((weak)) void matrix_init_pins(void) { |
51 | for (int row = 0; row < MATRIX_ROWS; row++) { | 51 | for (int row = 0; row < MATRIX_ROWS; row++) { |
52 | for (int col = 0; col < MATRIX_COLS; col++) { | 52 | for (int col = 0; col < MATRIX_COLS; col++) { |
53 | pin_t pin = direct_pins[row][col]; | 53 | pin_t pin = direct_pins[row][col]; |
@@ -58,7 +58,7 @@ static void init_pins(void) { | |||
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | 61 | __attribute__((weak)) bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
62 | // Start with a clear matrix row | 62 | // Start with a clear matrix row |
63 | matrix_row_t current_row_value = 0; | 63 | matrix_row_t current_row_value = 0; |
64 | 64 | ||
@@ -90,14 +90,14 @@ static void unselect_rows(void) { | |||
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
93 | static void init_pins(void) { | 93 | __attribute__((weak)) void matrix_init_pins(void) { |
94 | unselect_rows(); | 94 | unselect_rows(); |
95 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 95 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
96 | setPinInputHigh_atomic(col_pins[x]); | 96 | setPinInputHigh_atomic(col_pins[x]); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | 100 | __attribute__((weak)) bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
101 | // Start with a clear matrix row | 101 | // Start with a clear matrix row |
102 | matrix_row_t current_row_value = 0; | 102 | matrix_row_t current_row_value = 0; |
103 | 103 | ||
@@ -138,14 +138,14 @@ static void unselect_cols(void) { | |||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
141 | static void init_pins(void) { | 141 | __attribute__((weak)) void matrix_init_pins(void) { |
142 | unselect_cols(); | 142 | unselect_cols(); |
143 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { | 143 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { |
144 | setPinInputHigh_atomic(row_pins[x]); | 144 | setPinInputHigh_atomic(row_pins[x]); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | 147 | ||
148 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { | 148 | __attribute__((weak)) bool matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { |
149 | bool matrix_changed = false; | 149 | bool matrix_changed = false; |
150 | 150 | ||
151 | // Select col | 151 | // Select col |
@@ -190,7 +190,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) | |||
190 | 190 | ||
191 | void matrix_init(void) { | 191 | void matrix_init(void) { |
192 | // initialize key pins | 192 | // initialize key pins |
193 | init_pins(); | 193 | matrix_init_pins(); |
194 | 194 | ||
195 | // initialize matrix state: all keys off | 195 | // initialize matrix state: all keys off |
196 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 196 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
@@ -209,12 +209,12 @@ uint8_t matrix_scan(void) { | |||
209 | #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) | 209 | #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) |
210 | // Set row, read cols | 210 | // Set row, read cols |
211 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | 211 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { |
212 | changed |= read_cols_on_row(raw_matrix, current_row); | 212 | changed |= matrix_read_cols_on_row(raw_matrix, current_row); |
213 | } | 213 | } |
214 | #elif (DIODE_DIRECTION == ROW2COL) | 214 | #elif (DIODE_DIRECTION == ROW2COL) |
215 | // Set col, read rows | 215 | // Set col, read rows |
216 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 216 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { |
217 | changed |= read_rows_on_col(raw_matrix, current_col); | 217 | changed |= matrix_read_rows_on_col(raw_matrix, current_col); |
218 | } | 218 | } |
219 | #endif | 219 | #endif |
220 | 220 | ||
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 039e7d977..a54ea90b3 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c | |||
@@ -61,7 +61,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) { | |||
61 | 61 | ||
62 | #ifdef DIRECT_PINS | 62 | #ifdef DIRECT_PINS |
63 | 63 | ||
64 | static void init_pins(void) { | 64 | __attribute__((weak)) void matrix_init_pins(void) { |
65 | for (int row = 0; row < MATRIX_ROWS; row++) { | 65 | for (int row = 0; row < MATRIX_ROWS; row++) { |
66 | for (int col = 0; col < MATRIX_COLS; col++) { | 66 | for (int col = 0; col < MATRIX_COLS; col++) { |
67 | pin_t pin = direct_pins[row][col]; | 67 | pin_t pin = direct_pins[row][col]; |
@@ -72,7 +72,7 @@ static void init_pins(void) { | |||
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | 75 | __attribute__((weak)) bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
76 | // Start with a clear matrix row | 76 | // Start with a clear matrix row |
77 | matrix_row_t current_row_value = 0; | 77 | matrix_row_t current_row_value = 0; |
78 | 78 | ||
@@ -104,14 +104,14 @@ static void unselect_rows(void) { | |||
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | static void init_pins(void) { | 107 | __attribute__((weak)) void matrix_init_pins(void) { |
108 | unselect_rows(); | 108 | unselect_rows(); |
109 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 109 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
110 | setPinInputHigh_atomic(col_pins[x]); | 110 | setPinInputHigh_atomic(col_pins[x]); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { | 114 | __attribute__((weak)) bool matrix_read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) { |
115 | // Start with a clear matrix row | 115 | // Start with a clear matrix row |
116 | matrix_row_t current_row_value = 0; | 116 | matrix_row_t current_row_value = 0; |
117 | 117 | ||
@@ -152,14 +152,14 @@ static void unselect_cols(void) { | |||
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | static void init_pins(void) { | 155 | __attribute__((weak)) void matrix_init_pins(void) { |
156 | unselect_cols(); | 156 | unselect_cols(); |
157 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { | 157 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { |
158 | setPinInputHigh_atomic(row_pins[x]); | 158 | setPinInputHigh_atomic(row_pins[x]); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { | 162 | __attribute__((weak)) bool matrix_read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) { |
163 | bool matrix_changed = false; | 163 | bool matrix_changed = false; |
164 | 164 | ||
165 | // Select col | 165 | // Select col |
@@ -233,7 +233,7 @@ void matrix_init(void) { | |||
233 | thatHand = ROWS_PER_HAND - thisHand; | 233 | thatHand = ROWS_PER_HAND - thisHand; |
234 | 234 | ||
235 | // initialize key pins | 235 | // initialize key pins |
236 | init_pins(); | 236 | matrix_init_pins(); |
237 | 237 | ||
238 | // initialize matrix state: all keys off | 238 | // initialize matrix state: all keys off |
239 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 239 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
@@ -293,12 +293,12 @@ uint8_t matrix_scan(void) { | |||
293 | #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) | 293 | #if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW) |
294 | // Set row, read cols | 294 | // Set row, read cols |
295 | for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { | 295 | for (uint8_t current_row = 0; current_row < ROWS_PER_HAND; current_row++) { |
296 | local_changed |= read_cols_on_row(raw_matrix, current_row); | 296 | local_changed |= matrix_read_cols_on_row(raw_matrix, current_row); |
297 | } | 297 | } |
298 | #elif (DIODE_DIRECTION == ROW2COL) | 298 | #elif (DIODE_DIRECTION == ROW2COL) |
299 | // Set col, read rows | 299 | // Set col, read rows |
300 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { | 300 | for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) { |
301 | local_changed |= read_rows_on_col(raw_matrix, current_col); | 301 | local_changed |= matrix_read_rows_on_col(raw_matrix, current_col); |
302 | } | 302 | } |
303 | #endif | 303 | #endif |
304 | 304 | ||