diff options
Diffstat (limited to 'quantum/split_common/matrix.c')
| -rw-r--r-- | quantum/split_common/matrix.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/quantum/split_common/matrix.c b/quantum/split_common/matrix.c index 5bad9db08..cd5a024c3 100644 --- a/quantum/split_common/matrix.c +++ b/quantum/split_common/matrix.c | |||
| @@ -45,6 +45,19 @@ uint8_t thisHand, thatHand; | |||
| 45 | // user-defined overridable functions | 45 | // user-defined overridable functions |
| 46 | __attribute__((weak)) void matrix_slave_scan_user(void) {} | 46 | __attribute__((weak)) void matrix_slave_scan_user(void) {} |
| 47 | 47 | ||
| 48 | static inline void setPinOutput_writeLow(pin_t pin) { | ||
| 49 | ATOMIC_BLOCK_FORCEON { | ||
| 50 | setPinOutput(pin); | ||
| 51 | writePinLow(pin); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
| 55 | static inline void setPinInputHigh_atomic(pin_t pin) { | ||
| 56 | ATOMIC_BLOCK_FORCEON { | ||
| 57 | setPinInputHigh(pin); | ||
| 58 | } | ||
| 59 | } | ||
| 60 | |||
| 48 | // matrix code | 61 | // matrix code |
| 49 | 62 | ||
| 50 | #ifdef DIRECT_PINS | 63 | #ifdef DIRECT_PINS |
| @@ -83,22 +96,23 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 83 | # if (DIODE_DIRECTION == COL2ROW) | 96 | # if (DIODE_DIRECTION == COL2ROW) |
| 84 | 97 | ||
| 85 | static void select_row(uint8_t row) { | 98 | static void select_row(uint8_t row) { |
| 86 | setPinOutput(row_pins[row]); | 99 | setPinOutput_writeLow(row_pins[row]); |
| 87 | writePinLow(row_pins[row]); | ||
| 88 | } | 100 | } |
| 89 | 101 | ||
| 90 | static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } | 102 | static void unselect_row(uint8_t row) { |
| 103 | setPinInputHigh_atomic(row_pins[row]); | ||
| 104 | } | ||
| 91 | 105 | ||
| 92 | static void unselect_rows(void) { | 106 | static void unselect_rows(void) { |
| 93 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { | 107 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { |
| 94 | setPinInputHigh(row_pins[x]); | 108 | setPinInputHigh_atomic(row_pins[x]); |
| 95 | } | 109 | } |
| 96 | } | 110 | } |
| 97 | 111 | ||
| 98 | static void init_pins(void) { | 112 | static void init_pins(void) { |
| 99 | unselect_rows(); | 113 | unselect_rows(); |
| 100 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 114 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
| 101 | setPinInputHigh(col_pins[x]); | 115 | setPinInputHigh_atomic(col_pins[x]); |
| 102 | } | 116 | } |
| 103 | } | 117 | } |
| 104 | 118 | ||
| @@ -133,22 +147,23 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 133 | # elif (DIODE_DIRECTION == ROW2COL) | 147 | # elif (DIODE_DIRECTION == ROW2COL) |
| 134 | 148 | ||
| 135 | static void select_col(uint8_t col) { | 149 | static void select_col(uint8_t col) { |
| 136 | setPinOutput(col_pins[col]); | 150 | setPinOutput_writeLow(col_pins[col]); |
| 137 | writePinLow(col_pins[col]); | ||
| 138 | } | 151 | } |
| 139 | 152 | ||
| 140 | static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); } | 153 | static void unselect_col(uint8_t col) { |
| 154 | setPinInputHigh_atomic(col_pins[col]); | ||
| 155 | } | ||
| 141 | 156 | ||
| 142 | static void unselect_cols(void) { | 157 | static void unselect_cols(void) { |
| 143 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 158 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
| 144 | setPinInputHigh(col_pins[x]); | 159 | setPinInputHigh_atomic(col_pins[x]); |
| 145 | } | 160 | } |
| 146 | } | 161 | } |
| 147 | 162 | ||
| 148 | static void init_pins(void) { | 163 | static void init_pins(void) { |
| 149 | unselect_cols(); | 164 | unselect_cols(); |
| 150 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { | 165 | for (uint8_t x = 0; x < ROWS_PER_HAND; x++) { |
| 151 | setPinInputHigh(row_pins[x]); | 166 | setPinInputHigh_atomic(row_pins[x]); |
| 152 | } | 167 | } |
| 153 | } | 168 | } |
| 154 | 169 | ||
