Skip to content

Commit e5d3e5a

Browse files
authored
Add weak refs on reading rows/cols. (#13062)
1 parent d64a853 commit e5d3e5a

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

quantum/matrix.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
4747

4848
#ifdef DIRECT_PINS
4949

50-
static void init_pins(void) {
50+
__attribute__((weak)) void matrix_init_pins(void) {
5151
for (int row = 0; row < MATRIX_ROWS; row++) {
5252
for (int col = 0; col < MATRIX_COLS; col++) {
5353
pin_t pin = direct_pins[row][col];
@@ -58,7 +58,7 @@ static void init_pins(void) {
5858
}
5959
}
6060

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) {
6262
// Start with a clear matrix row
6363
matrix_row_t current_row_value = 0;
6464

@@ -90,14 +90,14 @@ static void unselect_rows(void) {
9090
}
9191
}
9292

93-
static void init_pins(void) {
93+
__attribute__((weak)) void matrix_init_pins(void) {
9494
unselect_rows();
9595
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
9696
setPinInputHigh_atomic(col_pins[x]);
9797
}
9898
}
9999

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) {
101101
// Start with a clear matrix row
102102
matrix_row_t current_row_value = 0;
103103

@@ -138,14 +138,14 @@ static void unselect_cols(void) {
138138
}
139139
}
140140

141-
static void init_pins(void) {
141+
__attribute__((weak)) void matrix_init_pins(void) {
142142
unselect_cols();
143143
for (uint8_t x = 0; x < MATRIX_ROWS; x++) {
144144
setPinInputHigh_atomic(row_pins[x]);
145145
}
146146
}
147147

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) {
149149
bool matrix_changed = false;
150150

151151
// Select col
@@ -190,7 +190,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
190190

191191
void matrix_init(void) {
192192
// initialize key pins
193-
init_pins();
193+
matrix_init_pins();
194194

195195
// initialize matrix state: all keys off
196196
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
@@ -209,12 +209,12 @@ uint8_t matrix_scan(void) {
209209
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
210210
// Set row, read cols
211211
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);
213213
}
214214
#elif (DIODE_DIRECTION == ROW2COL)
215215
// Set col, read rows
216216
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);
218218
}
219219
#endif
220220

quantum/split_common/matrix.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) {
6161

6262
#ifdef DIRECT_PINS
6363

64-
static void init_pins(void) {
64+
__attribute__((weak)) void matrix_init_pins(void) {
6565
for (int row = 0; row < MATRIX_ROWS; row++) {
6666
for (int col = 0; col < MATRIX_COLS; col++) {
6767
pin_t pin = direct_pins[row][col];
@@ -72,7 +72,7 @@ static void init_pins(void) {
7272
}
7373
}
7474

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) {
7676
// Start with a clear matrix row
7777
matrix_row_t current_row_value = 0;
7878

@@ -104,14 +104,14 @@ static void unselect_rows(void) {
104104
}
105105
}
106106

107-
static void init_pins(void) {
107+
__attribute__((weak)) void matrix_init_pins(void) {
108108
unselect_rows();
109109
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
110110
setPinInputHigh_atomic(col_pins[x]);
111111
}
112112
}
113113

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) {
115115
// Start with a clear matrix row
116116
matrix_row_t current_row_value = 0;
117117

@@ -152,14 +152,14 @@ static void unselect_cols(void) {
152152
}
153153
}
154154

155-
static void init_pins(void) {
155+
__attribute__((weak)) void matrix_init_pins(void) {
156156
unselect_cols();
157157
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
158158
setPinInputHigh_atomic(row_pins[x]);
159159
}
160160
}
161161

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) {
163163
bool matrix_changed = false;
164164

165165
// Select col
@@ -233,7 +233,7 @@ void matrix_init(void) {
233233
thatHand = ROWS_PER_HAND - thisHand;
234234

235235
// initialize key pins
236-
init_pins();
236+
matrix_init_pins();
237237

238238
// initialize matrix state: all keys off
239239
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
@@ -293,12 +293,12 @@ uint8_t matrix_scan(void) {
293293
#if defined(DIRECT_PINS) || (DIODE_DIRECTION == COL2ROW)
294294
// Set row, read cols
295295
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);
297297
}
298298
#elif (DIODE_DIRECTION == ROW2COL)
299299
// Set col, read rows
300300
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);
302302
}
303303
#endif
304304

0 commit comments

Comments
 (0)