diff options
Diffstat (limited to 'quantum/matrix.c')
| -rw-r--r-- | quantum/matrix.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index c68c56cac..cab0d2ddc 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c | |||
| @@ -32,6 +32,19 @@ static const pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; | |||
| 32 | extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values | 32 | extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values |
| 33 | extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values | 33 | extern matrix_row_t matrix[MATRIX_ROWS]; // debounced values |
| 34 | 34 | ||
| 35 | static inline void setPinOutput_writeLow(pin_t pin) { | ||
| 36 | ATOMIC_BLOCK_FORCEON { | ||
| 37 | setPinOutput(pin); | ||
| 38 | writePinLow(pin); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | static inline void setPinInputHigh_atomic(pin_t pin) { | ||
| 43 | ATOMIC_BLOCK_FORCEON { | ||
| 44 | setPinInputHigh(pin); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 35 | // matrix code | 48 | // matrix code |
| 36 | 49 | ||
| 37 | #ifdef DIRECT_PINS | 50 | #ifdef DIRECT_PINS |
| @@ -70,22 +83,23 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 70 | # if (DIODE_DIRECTION == COL2ROW) | 83 | # if (DIODE_DIRECTION == COL2ROW) |
| 71 | 84 | ||
| 72 | static void select_row(uint8_t row) { | 85 | static void select_row(uint8_t row) { |
| 73 | setPinOutput(row_pins[row]); | 86 | setPinOutput_writeLow(row_pins[row]); |
| 74 | writePinLow(row_pins[row]); | ||
| 75 | } | 87 | } |
| 76 | 88 | ||
| 77 | static void unselect_row(uint8_t row) { setPinInputHigh(row_pins[row]); } | 89 | static void unselect_row(uint8_t row) { |
| 90 | setPinInputHigh_atomic(row_pins[row]); | ||
| 91 | } | ||
| 78 | 92 | ||
| 79 | static void unselect_rows(void) { | 93 | static void unselect_rows(void) { |
| 80 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { | 94 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { |
| 81 | setPinInputHigh(row_pins[x]); | 95 | setPinInputHigh_atomic(row_pins[x]); |
| 82 | } | 96 | } |
| 83 | } | 97 | } |
| 84 | 98 | ||
| 85 | static void init_pins(void) { | 99 | static void init_pins(void) { |
| 86 | unselect_rows(); | 100 | unselect_rows(); |
| 87 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 101 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
| 88 | setPinInputHigh(col_pins[x]); | 102 | setPinInputHigh_atomic(col_pins[x]); |
| 89 | } | 103 | } |
| 90 | } | 104 | } |
| 91 | 105 | ||
| @@ -120,22 +134,23 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row) | |||
| 120 | # elif (DIODE_DIRECTION == ROW2COL) | 134 | # elif (DIODE_DIRECTION == ROW2COL) |
| 121 | 135 | ||
| 122 | static void select_col(uint8_t col) { | 136 | static void select_col(uint8_t col) { |
| 123 | setPinOutput(col_pins[col]); | 137 | setPinOutput_writeLow(col_pins[col]); |
| 124 | writePinLow(col_pins[col]); | ||
| 125 | } | 138 | } |
| 126 | 139 | ||
| 127 | static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); } | 140 | static void unselect_col(uint8_t col) { |
| 141 | setPinInputHigh_atomic(col_pins[col]); | ||
| 142 | } | ||
| 128 | 143 | ||
| 129 | static void unselect_cols(void) { | 144 | static void unselect_cols(void) { |
| 130 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { | 145 | for (uint8_t x = 0; x < MATRIX_COLS; x++) { |
| 131 | setPinInputHigh(col_pins[x]); | 146 | setPinInputHigh_atomic(col_pins[x]); |
| 132 | } | 147 | } |
| 133 | } | 148 | } |
| 134 | 149 | ||
| 135 | static void init_pins(void) { | 150 | static void init_pins(void) { |
| 136 | unselect_cols(); | 151 | unselect_cols(); |
| 137 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { | 152 | for (uint8_t x = 0; x < MATRIX_ROWS; x++) { |
| 138 | setPinInputHigh(row_pins[x]); | 153 | setPinInputHigh_atomic(row_pins[x]); |
| 139 | } | 154 | } |
| 140 | } | 155 | } |
| 141 | 156 | ||
