diff options
| -rw-r--r-- | keyboards/ergodone/matrix.c | 35 | ||||
| -rw-r--r-- | keyboards/ergodox_ez/matrix.c | 37 | ||||
| -rw-r--r-- | keyboards/ergodox_stm32/matrix.c | 7 | ||||
| -rw-r--r-- | keyboards/ergotaco/matrix.c | 31 | ||||
| -rw-r--r-- | keyboards/georgi/matrix.c | 32 | ||||
| -rw-r--r-- | keyboards/gergo/matrix.c | 33 | ||||
| -rw-r--r-- | keyboards/handwired/dactyl/matrix.c | 24 | ||||
| -rw-r--r-- | keyboards/handwired/frenchdev/matrix.c | 35 | ||||
| -rw-r--r-- | keyboards/handwired/xealous/matrix.c | 12 | ||||
| -rw-r--r-- | keyboards/handwired/xealous/matrix_scanrate.c | 39 | ||||
| -rw-r--r-- | keyboards/handwired/xealous/matrix_scanrate.h | 4 | ||||
| -rw-r--r-- | keyboards/handwired/xealous/rules.mk | 2 | ||||
| -rw-r--r-- | keyboards/hotdox/matrix.c | 34 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 24 |
14 files changed, 25 insertions, 324 deletions
diff --git a/keyboards/ergodone/matrix.c b/keyboards/ergodone/matrix.c index 4a8230aa8..456f73c95 100644 --- a/keyboards/ergodone/matrix.c +++ b/keyboards/ergodone/matrix.c | |||
| @@ -9,9 +9,6 @@ | |||
| 9 | #include "matrix.h" | 9 | #include "matrix.h" |
| 10 | #include "ergodone.h" | 10 | #include "ergodone.h" |
| 11 | #include "expander.h" | 11 | #include "expander.h" |
| 12 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 13 | #include "timer.h" | ||
| 14 | #endif | ||
| 15 | 12 | ||
| 16 | /* | 13 | /* |
| 17 | * This constant define not debouncing time in msecs, but amount of matrix | 14 | * This constant define not debouncing time in msecs, but amount of matrix |
| @@ -41,12 +38,6 @@ static void init_cols(void); | |||
| 41 | static void unselect_rows(void); | 38 | static void unselect_rows(void); |
| 42 | static void select_row(uint8_t row); | 39 | static void select_row(uint8_t row); |
| 43 | 40 | ||
| 44 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 45 | uint32_t matrix_timer; | ||
| 46 | uint32_t matrix_scan_count; | ||
| 47 | #endif | ||
| 48 | |||
| 49 | |||
| 50 | __attribute__ ((weak)) | 41 | __attribute__ ((weak)) |
| 51 | void matrix_init_user(void) {} | 42 | void matrix_init_user(void) {} |
| 52 | 43 | ||
| @@ -88,13 +79,7 @@ void matrix_init(void) | |||
| 88 | } | 79 | } |
| 89 | } | 80 | } |
| 90 | 81 | ||
| 91 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 92 | matrix_timer = timer_read32(); | ||
| 93 | matrix_scan_count = 0; | ||
| 94 | #endif | ||
| 95 | |||
| 96 | matrix_init_quantum(); | 82 | matrix_init_quantum(); |
| 97 | |||
| 98 | } | 83 | } |
| 99 | 84 | ||
| 100 | void matrix_power_up(void) { | 85 | void matrix_power_up(void) { |
| @@ -105,11 +90,6 @@ void matrix_power_up(void) { | |||
| 105 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 90 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 106 | matrix[i] = 0; | 91 | matrix[i] = 0; |
| 107 | } | 92 | } |
| 108 | |||
| 109 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 110 | matrix_timer = timer_read32(); | ||
| 111 | matrix_scan_count = 0; | ||
| 112 | #endif | ||
| 113 | } | 93 | } |
| 114 | 94 | ||
| 115 | // Returns a matrix_row_t whose bits are set if the corresponding key should be | 95 | // Returns a matrix_row_t whose bits are set if the corresponding key should be |
| @@ -140,21 +120,6 @@ uint8_t matrix_scan(void) | |||
| 140 | { | 120 | { |
| 141 | expander_scan(); | 121 | expander_scan(); |
| 142 | 122 | ||
| 143 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 144 | matrix_scan_count++; | ||
| 145 | |||
| 146 | uint32_t timer_now = timer_read32(); | ||
| 147 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 148 | print("matrix scan frequency: "); | ||
| 149 | pdec(matrix_scan_count); | ||
| 150 | print("\n"); | ||
| 151 | matrix_print(); | ||
| 152 | |||
| 153 | matrix_timer = timer_now; | ||
| 154 | matrix_scan_count = 0; | ||
| 155 | } | ||
| 156 | #endif | ||
| 157 | |||
| 158 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 123 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
| 159 | select_row(i); | 124 | select_row(i); |
| 160 | wait_us(30); // without this wait read unstable value. | 125 | wait_us(30); // without this wait read unstable value. |
diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c index 3c9a2f43a..4f11a0ad5 100644 --- a/keyboards/ergodox_ez/matrix.c +++ b/keyboards/ergodox_ez/matrix.c | |||
| @@ -32,15 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 32 | #include "debounce.h" | 32 | #include "debounce.h" |
| 33 | #include QMK_KEYBOARD_H | 33 | #include QMK_KEYBOARD_H |
| 34 | 34 | ||
| 35 | // Only enable this if console is enabled to print to | ||
| 36 | #if defined(DEBUG_MATRIX_SCAN_RATE) && !defined(CONSOLE_ENABLE) | ||
| 37 | # undef DEBUG_MATRIX_SCAN_RATE | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 41 | # include "timer.h" | ||
| 42 | #endif | ||
| 43 | |||
| 44 | /* | 35 | /* |
| 45 | * This constant define not debouncing time in msecs, assuming eager_pr. | 36 | * This constant define not debouncing time in msecs, assuming eager_pr. |
| 46 | * | 37 | * |
| @@ -65,11 +56,6 @@ static void select_row(uint8_t row); | |||
| 65 | static uint8_t mcp23018_reset_loop; | 56 | static uint8_t mcp23018_reset_loop; |
| 66 | // static uint16_t mcp23018_reset_loop; | 57 | // static uint16_t mcp23018_reset_loop; |
| 67 | 58 | ||
| 68 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 69 | uint32_t matrix_timer; | ||
| 70 | uint32_t matrix_scan_count; | ||
| 71 | #endif | ||
| 72 | |||
| 73 | __attribute__((weak)) void matrix_init_user(void) {} | 59 | __attribute__((weak)) void matrix_init_user(void) {} |
| 74 | 60 | ||
| 75 | __attribute__((weak)) void matrix_scan_user(void) {} | 61 | __attribute__((weak)) void matrix_scan_user(void) {} |
| @@ -96,10 +82,6 @@ void matrix_init(void) { | |||
| 96 | raw_matrix[i] = 0; | 82 | raw_matrix[i] = 0; |
| 97 | } | 83 | } |
| 98 | 84 | ||
| 99 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 100 | matrix_timer = timer_read32(); | ||
| 101 | matrix_scan_count = 0; | ||
| 102 | #endif | ||
| 103 | debounce_init(MATRIX_ROWS); | 85 | debounce_init(MATRIX_ROWS); |
| 104 | matrix_init_quantum(); | 86 | matrix_init_quantum(); |
| 105 | } | 87 | } |
| @@ -114,11 +96,6 @@ void matrix_power_up(void) { | |||
| 114 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 96 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
| 115 | matrix[i] = 0; | 97 | matrix[i] = 0; |
| 116 | } | 98 | } |
| 117 | |||
| 118 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 119 | matrix_timer = timer_read32(); | ||
| 120 | matrix_scan_count = 0; | ||
| 121 | #endif | ||
| 122 | } | 99 | } |
| 123 | 100 | ||
| 124 | // Reads and stores a row, returning | 101 | // Reads and stores a row, returning |
| @@ -149,20 +126,6 @@ uint8_t matrix_scan(void) { | |||
| 149 | } | 126 | } |
| 150 | } | 127 | } |
| 151 | 128 | ||
| 152 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 153 | matrix_scan_count++; | ||
| 154 | |||
| 155 | uint32_t timer_now = timer_read32(); | ||
| 156 | if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { | ||
| 157 | print("matrix scan frequency: "); | ||
| 158 | pdec(matrix_scan_count); | ||
| 159 | print("\n"); | ||
| 160 | |||
| 161 | matrix_timer = timer_now; | ||
| 162 | matrix_scan_count = 0; | ||
| 163 | } | ||
| 164 | #endif | ||
| 165 | |||
| 166 | #ifdef LEFT_LEDS | 129 | #ifdef LEFT_LEDS |
| 167 | mcp23018_status = ergodox_left_leds_update(); | 130 | mcp23018_status = ergodox_left_leds_update(); |
| 168 | #endif // LEFT_LEDS | 131 | #endif // LEFT_LEDS |
diff --git a/keyboards/ergodox_stm32/matrix.c b/keyboards/ergodox_stm32/matrix.c index 5a280ee17..383bf9790 100644 --- a/keyboards/ergodox_stm32/matrix.c +++ b/keyboards/ergodox_stm32/matrix.c | |||
| @@ -13,13 +13,6 @@ | |||
| 13 | #define DEBOUNCE 10 | 13 | #define DEBOUNCE 10 |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | //#define DEBUG_MATRIX_SCAN_RATE | ||
| 17 | |||
| 18 | //#ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 19 | //uint32_t matrix_timer; | ||
| 20 | //uint32_t matrix_scan_count; | ||
| 21 | //#endif | ||
| 22 | |||
| 23 | static uint8_t mcp23017_reset_loop = 0; | 16 | static uint8_t mcp23017_reset_loop = 0; |
| 24 | 17 | ||
| 25 | volatile matrix_row_t matrix[MATRIX_ROWS]; | 18 | volatile matrix_row_t matrix[MATRIX_ROWS]; |
diff --git a/keyboards/ergotaco/matrix.c b/keyboards/ergotaco/matrix.c index f7ceb194a..e28f754e6 100644 --- a/keyboards/ergotaco/matrix.c +++ b/keyboards/ergotaco/matrix.c | |||
| @@ -26,9 +26,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 26 | #include "debug.h" | 26 | #include "debug.h" |
| 27 | #include "util.h" | 27 | #include "util.h" |
| 28 | #include QMK_KEYBOARD_H | 28 | #include QMK_KEYBOARD_H |
| 29 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 30 | #include "timer.h" | ||
| 31 | #endif | ||
| 32 | 29 | ||
| 33 | #ifndef DEBOUNCE | 30 | #ifndef DEBOUNCE |
| 34 | # define DEBOUNCE 5 | 31 | # define DEBOUNCE 5 |
| @@ -70,12 +67,6 @@ static void select_row(uint8_t row); | |||
| 70 | static uint8_t mcp23018_reset_loop; | 67 | static uint8_t mcp23018_reset_loop; |
| 71 | // static uint16_t mcp23018_reset_loop; | 68 | // static uint16_t mcp23018_reset_loop; |
| 72 | 69 | ||
| 73 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 74 | uint32_t matrix_timer; | ||
| 75 | uint32_t matrix_scan_count; | ||
| 76 | #endif | ||
| 77 | |||
| 78 | |||
| 79 | __attribute__ ((weak)) | 70 | __attribute__ ((weak)) |
| 80 | void matrix_init_user(void) {} | 71 | void matrix_init_user(void) {} |
| 81 | 72 | ||
| @@ -121,10 +112,6 @@ void matrix_init(void) | |||
| 121 | } | 112 | } |
| 122 | } | 113 | } |
| 123 | 114 | ||
| 124 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 125 | matrix_timer = timer_read32(); | ||
| 126 | matrix_scan_count = 0; | ||
| 127 | #endif | ||
| 128 | matrix_init_quantum(); | 115 | matrix_init_quantum(); |
| 129 | } | 116 | } |
| 130 | 117 | ||
| @@ -138,12 +125,6 @@ void matrix_power_up(void) { | |||
| 138 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 125 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 139 | matrix[i] = 0; | 126 | matrix[i] = 0; |
| 140 | } | 127 | } |
| 141 | |||
| 142 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 143 | matrix_timer = timer_read32(); | ||
| 144 | matrix_scan_count = 0; | ||
| 145 | #endif | ||
| 146 | |||
| 147 | } | 128 | } |
| 148 | 129 | ||
| 149 | // Returns a matrix_row_t whose bits are set if the corresponding key should be | 130 | // Returns a matrix_row_t whose bits are set if the corresponding key should be |
| @@ -192,18 +173,6 @@ uint8_t matrix_scan(void) | |||
| 192 | } | 173 | } |
| 193 | } | 174 | } |
| 194 | 175 | ||
| 195 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 196 | matrix_scan_count++; | ||
| 197 | uint32_t timer_now = timer_read32(); | ||
| 198 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 199 | print("matrix scan frequency: "); | ||
| 200 | pdec(matrix_scan_count); | ||
| 201 | print("\n"); | ||
| 202 | |||
| 203 | matrix_timer = timer_now; | ||
| 204 | matrix_scan_count = 0; | ||
| 205 | } | ||
| 206 | #endif | ||
| 207 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { | 176 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { |
| 208 | select_row(i); | 177 | select_row(i); |
| 209 | // and select on left hand | 178 | // and select on left hand |
diff --git a/keyboards/georgi/matrix.c b/keyboards/georgi/matrix.c index 58f0776c4..f0b69c841 100644 --- a/keyboards/georgi/matrix.c +++ b/keyboards/georgi/matrix.c | |||
| @@ -27,10 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "util.h" | 27 | #include "util.h" |
| 28 | #include "keymap_steno.h" | 28 | #include "keymap_steno.h" |
| 29 | #include QMK_KEYBOARD_H | 29 | #include QMK_KEYBOARD_H |
| 30 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 31 | #include "timer.h" | ||
| 32 | #endif | ||
| 33 | |||
| 34 | 30 | ||
| 35 | #ifndef DEBOUNCE | 31 | #ifndef DEBOUNCE |
| 36 | # define DEBOUNCE 5 | 32 | # define DEBOUNCE 5 |
| @@ -92,12 +88,6 @@ static void select_row(uint8_t row); | |||
| 92 | static uint8_t mcp23018_reset_loop; | 88 | static uint8_t mcp23018_reset_loop; |
| 93 | // static uint16_t mcp23018_reset_loop; | 89 | // static uint16_t mcp23018_reset_loop; |
| 94 | 90 | ||
| 95 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 96 | uint32_t matrix_timer; | ||
| 97 | uint32_t matrix_scan_count; | ||
| 98 | #endif | ||
| 99 | |||
| 100 | |||
| 101 | __attribute__ ((weak)) | 91 | __attribute__ ((weak)) |
| 102 | void matrix_init_user(void) {} | 92 | void matrix_init_user(void) {} |
| 103 | 93 | ||
| @@ -143,10 +133,6 @@ void matrix_init(void) | |||
| 143 | } | 133 | } |
| 144 | } | 134 | } |
| 145 | 135 | ||
| 146 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 147 | matrix_timer = timer_read32(); | ||
| 148 | matrix_scan_count = 0; | ||
| 149 | #endif | ||
| 150 | matrix_init_quantum(); | 136 | matrix_init_quantum(); |
| 151 | } | 137 | } |
| 152 | 138 | ||
| @@ -160,12 +146,6 @@ void matrix_power_up(void) { | |||
| 160 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 146 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 161 | matrix[i] = 0; | 147 | matrix[i] = 0; |
| 162 | } | 148 | } |
| 163 | |||
| 164 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 165 | matrix_timer = timer_read32(); | ||
| 166 | matrix_scan_count = 0; | ||
| 167 | #endif | ||
| 168 | |||
| 169 | } | 149 | } |
| 170 | 150 | ||
| 171 | // Returns a matrix_row_t whose bits are set if the corresponding key should be | 151 | // Returns a matrix_row_t whose bits are set if the corresponding key should be |
| @@ -214,18 +194,6 @@ uint8_t matrix_scan(void) | |||
| 214 | } | 194 | } |
| 215 | } | 195 | } |
| 216 | 196 | ||
| 217 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 218 | matrix_scan_count++; | ||
| 219 | uint32_t timer_now = timer_read32(); | ||
| 220 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 221 | print("matrix scan frequency: "); | ||
| 222 | pdec(matrix_scan_count); | ||
| 223 | print("\n"); | ||
| 224 | |||
| 225 | matrix_timer = timer_now; | ||
| 226 | matrix_scan_count = 0; | ||
| 227 | } | ||
| 228 | #endif | ||
| 229 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { | 197 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { |
| 230 | select_row(i); | 198 | select_row(i); |
| 231 | // and select on left hand | 199 | // and select on left hand |
diff --git a/keyboards/gergo/matrix.c b/keyboards/gergo/matrix.c index 9ef1f6b5c..f659ed52c 100644 --- a/keyboards/gergo/matrix.c +++ b/keyboards/gergo/matrix.c | |||
| @@ -27,9 +27,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "util.h" | 27 | #include "util.h" |
| 28 | #include "debounce.h" | 28 | #include "debounce.h" |
| 29 | #include QMK_KEYBOARD_H | 29 | #include QMK_KEYBOARD_H |
| 30 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 31 | # include "timer.h" | ||
| 32 | #endif | ||
| 33 | 30 | ||
| 34 | #ifdef BALLER | 31 | #ifdef BALLER |
| 35 | #include <avr/interrupt.h> | 32 | #include <avr/interrupt.h> |
| @@ -124,12 +121,6 @@ static void enableInterrupts(void); | |||
| 124 | static uint8_t mcp23018_reset_loop; | 121 | static uint8_t mcp23018_reset_loop; |
| 125 | // static uint16_t mcp23018_reset_loop; | 122 | // static uint16_t mcp23018_reset_loop; |
| 126 | 123 | ||
| 127 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 128 | uint32_t matrix_timer; | ||
| 129 | uint32_t matrix_scan_count; | ||
| 130 | #endif | ||
| 131 | |||
| 132 | |||
| 133 | __attribute__ ((weak)) void matrix_init_user(void) {} | 124 | __attribute__ ((weak)) void matrix_init_user(void) {} |
| 134 | 125 | ||
| 135 | __attribute__ ((weak)) void matrix_scan_user(void) {} | 126 | __attribute__ ((weak)) void matrix_scan_user(void) {} |
| @@ -161,10 +152,6 @@ void matrix_init(void) { | |||
| 161 | raw_matrix[i] = 0; | 152 | raw_matrix[i] = 0; |
| 162 | } | 153 | } |
| 163 | 154 | ||
| 164 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 165 | matrix_timer = timer_read32(); | ||
| 166 | matrix_scan_count = 0; | ||
| 167 | #endif | ||
| 168 | debounce_init(MATRIX_ROWS); | 155 | debounce_init(MATRIX_ROWS); |
| 169 | matrix_init_quantum(); | 156 | matrix_init_quantum(); |
| 170 | } | 157 | } |
| @@ -179,12 +166,6 @@ void matrix_power_up(void) { | |||
| 179 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 166 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 180 | matrix[i] = 0; | 167 | matrix[i] = 0; |
| 181 | } | 168 | } |
| 182 | |||
| 183 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 184 | matrix_timer = timer_read32(); | ||
| 185 | matrix_scan_count = 0; | ||
| 186 | #endif | ||
| 187 | |||
| 188 | } | 169 | } |
| 189 | 170 | ||
| 190 | // Reads and stores a row, returning | 171 | // Reads and stores a row, returning |
| @@ -261,20 +242,6 @@ uint8_t matrix_scan(void) { | |||
| 261 | } | 242 | } |
| 262 | } | 243 | } |
| 263 | 244 | ||
| 264 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 265 | matrix_scan_count++; | ||
| 266 | |||
| 267 | uint32_t timer_now = timer_read32(); | ||
| 268 | if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { | ||
| 269 | print("matrix scan frequency: "); | ||
| 270 | pdec(matrix_scan_count); | ||
| 271 | print("\n"); | ||
| 272 | |||
| 273 | matrix_timer = timer_now; | ||
| 274 | matrix_scan_count = 0; | ||
| 275 | } | ||
| 276 | #endif | ||
| 277 | |||
| 278 | bool changed = false; | 245 | bool changed = false; |
| 279 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { | 246 | for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { |
| 280 | // select rows from left and right hands | 247 | // select rows from left and right hands |
diff --git a/keyboards/handwired/dactyl/matrix.c b/keyboards/handwired/dactyl/matrix.c index 28cf37522..faa5c19cf 100644 --- a/keyboards/handwired/dactyl/matrix.c +++ b/keyboards/handwired/dactyl/matrix.c | |||
| @@ -76,11 +76,6 @@ uint8_t expander_status; | |||
| 76 | uint8_t expander_input_pin_mask; | 76 | uint8_t expander_input_pin_mask; |
| 77 | bool i2c_initialized = false; | 77 | bool i2c_initialized = false; |
| 78 | 78 | ||
| 79 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 80 | uint32_t matrix_timer; | ||
| 81 | uint32_t matrix_scan_count; | ||
| 82 | #endif | ||
| 83 | |||
| 84 | #define ROW_SHIFTER ((matrix_row_t)1) | 79 | #define ROW_SHIFTER ((matrix_row_t)1) |
| 85 | 80 | ||
| 86 | __attribute__ ((weak)) | 81 | __attribute__ ((weak)) |
| @@ -129,11 +124,6 @@ void matrix_init(void) | |||
| 129 | matrix_debouncing[i] = 0; | 124 | matrix_debouncing[i] = 0; |
| 130 | } | 125 | } |
| 131 | 126 | ||
| 132 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 133 | matrix_timer = timer_read32(); | ||
| 134 | matrix_scan_count = 0; | ||
| 135 | #endif | ||
| 136 | |||
| 137 | matrix_init_quantum(); | 127 | matrix_init_quantum(); |
| 138 | } | 128 | } |
| 139 | 129 | ||
| @@ -236,20 +226,6 @@ uint8_t matrix_scan(void) | |||
| 236 | } | 226 | } |
| 237 | } | 227 | } |
| 238 | 228 | ||
| 239 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 240 | matrix_scan_count++; | ||
| 241 | |||
| 242 | uint32_t timer_now = timer_read32(); | ||
| 243 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 244 | print("matrix scan frequency: "); | ||
| 245 | pdec(matrix_scan_count); | ||
| 246 | print("\n"); | ||
| 247 | |||
| 248 | matrix_timer = timer_now; | ||
| 249 | matrix_scan_count = 0; | ||
| 250 | } | ||
| 251 | #endif | ||
| 252 | |||
| 253 | #if (DIODE_DIRECTION == COL2ROW) | 229 | #if (DIODE_DIRECTION == COL2ROW) |
| 254 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { | 230 | for (uint8_t current_row = 0; current_row < MATRIX_ROWS; current_row++) { |
| 255 | # if (DEBOUNCE > 0) | 231 | # if (DEBOUNCE > 0) |
diff --git a/keyboards/handwired/frenchdev/matrix.c b/keyboards/handwired/frenchdev/matrix.c index 26c2b3126..c9c7e94ae 100644 --- a/keyboards/handwired/frenchdev/matrix.c +++ b/keyboards/handwired/frenchdev/matrix.c | |||
| @@ -35,9 +35,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 35 | #include "util.h" | 35 | #include "util.h" |
| 36 | #include "matrix.h" | 36 | #include "matrix.h" |
| 37 | #include "frenchdev.h" | 37 | #include "frenchdev.h" |
| 38 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 39 | #include "timer.h" | ||
| 40 | #endif | ||
| 41 | 38 | ||
| 42 | /* | 39 | /* |
| 43 | * This constant define not debouncing time in msecs, but amount of matrix | 40 | * This constant define not debouncing time in msecs, but amount of matrix |
| @@ -66,12 +63,6 @@ static void select_row(uint8_t row); | |||
| 66 | 63 | ||
| 67 | static uint8_t mcp23018_reset_loop; | 64 | static uint8_t mcp23018_reset_loop; |
| 68 | 65 | ||
| 69 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 70 | uint32_t matrix_timer; | ||
| 71 | uint32_t matrix_scan_count; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | |||
| 75 | __attribute__ ((weak)) | 66 | __attribute__ ((weak)) |
| 76 | void matrix_init_user(void) {} | 67 | void matrix_init_user(void) {} |
| 77 | 68 | ||
| @@ -120,13 +111,7 @@ void matrix_init(void) | |||
| 120 | matrix_debouncing[i] = 0; | 111 | matrix_debouncing[i] = 0; |
| 121 | } | 112 | } |
| 122 | 113 | ||
| 123 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 124 | matrix_timer = timer_read32(); | ||
| 125 | matrix_scan_count = 0; | ||
| 126 | #endif | ||
| 127 | |||
| 128 | matrix_init_quantum(); | 114 | matrix_init_quantum(); |
| 129 | |||
| 130 | } | 115 | } |
| 131 | 116 | ||
| 132 | void matrix_power_up(void) { | 117 | void matrix_power_up(void) { |
| @@ -140,12 +125,6 @@ void matrix_power_up(void) { | |||
| 140 | matrix[i] = 0; | 125 | matrix[i] = 0; |
| 141 | matrix_debouncing[i] = 0; | 126 | matrix_debouncing[i] = 0; |
| 142 | } | 127 | } |
| 143 | |||
| 144 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 145 | matrix_timer = timer_read32(); | ||
| 146 | matrix_scan_count = 0; | ||
| 147 | #endif | ||
| 148 | |||
| 149 | } | 128 | } |
| 150 | 129 | ||
| 151 | uint8_t matrix_scan(void) | 130 | uint8_t matrix_scan(void) |
| @@ -165,20 +144,6 @@ uint8_t matrix_scan(void) | |||
| 165 | } | 144 | } |
| 166 | } | 145 | } |
| 167 | 146 | ||
| 168 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 169 | matrix_scan_count++; | ||
| 170 | |||
| 171 | uint32_t timer_now = timer_read32(); | ||
| 172 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 173 | print("matrix scan frequency: "); | ||
| 174 | pdec(matrix_scan_count); | ||
| 175 | print("\n"); | ||
| 176 | |||
| 177 | matrix_timer = timer_now; | ||
| 178 | matrix_scan_count = 0; | ||
| 179 | } | ||
| 180 | #endif | ||
| 181 | |||
| 182 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 147 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
| 183 | select_row(i); | 148 | select_row(i); |
| 184 | wait_us(30); // without this wait read unstable value. | 149 | wait_us(30); // without this wait read unstable value. |
diff --git a/keyboards/handwired/xealous/matrix.c b/keyboards/handwired/xealous/matrix.c index e2d219939..6d43db4d9 100644 --- a/keyboards/handwired/xealous/matrix.c +++ b/keyboards/handwired/xealous/matrix.c | |||
| @@ -30,18 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #include "pro_micro.h" | 30 | #include "pro_micro.h" |
| 31 | #include "config.h" | 31 | #include "config.h" |
| 32 | #include "timer.h" | 32 | #include "timer.h" |
| 33 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 34 | #include "matrix_scanrate.h" | ||
| 35 | #endif | ||
| 36 | |||
| 37 | void matrix_scan_user(void) | ||
| 38 | { | ||
| 39 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 40 | matrix_check_scan_rate(); | ||
| 41 | matrix_time_between_scans(); | ||
| 42 | #endif | ||
| 43 | |||
| 44 | } | ||
| 45 | 33 | ||
| 46 | // Copy this code to split_common/matrix.c, | 34 | // Copy this code to split_common/matrix.c, |
| 47 | // and call it instead of the unoptimized col_reader. Scan-rate jumps from 1200->1920 | 35 | // and call it instead of the unoptimized col_reader. Scan-rate jumps from 1200->1920 |
diff --git a/keyboards/handwired/xealous/matrix_scanrate.c b/keyboards/handwired/xealous/matrix_scanrate.c deleted file mode 100644 index f2c7cbe6e..000000000 --- a/keyboards/handwired/xealous/matrix_scanrate.c +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #include <avr/io.h> | ||
| 4 | #include "wait.h" | ||
| 5 | #include "print.h" | ||
| 6 | #include "debug.h" | ||
| 7 | #include "util.h" | ||
| 8 | #include "matrix.h" | ||
| 9 | #include "timer.h" | ||
| 10 | |||
| 11 | #ifdef CONSOLE_ENABLE | ||
| 12 | static uint16_t matrix_scan_count = 0; | ||
| 13 | static uint32_t matrix_timer = 0; | ||
| 14 | void matrix_check_scan_rate(void) { | ||
| 15 | matrix_scan_count++; | ||
| 16 | if (matrix_scan_count > 1000) { | ||
| 17 | uint32_t timer_now = timer_read32(); | ||
| 18 | uint16_t ms_per_thousand = TIMER_DIFF_32(timer_now, matrix_timer); | ||
| 19 | uint16_t rate_per_second = 1000000UL / ms_per_thousand; | ||
| 20 | print("scan_rate: "); | ||
| 21 | pdec(rate_per_second); | ||
| 22 | print("\n"); | ||
| 23 | matrix_timer = timer_now; | ||
| 24 | matrix_scan_count = 0; | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | static uint32_t last_scan_time = 0; | ||
| 29 | void matrix_time_between_scans(void) { | ||
| 30 | if (timer_elapsed(last_scan_time) > 1) | ||
| 31 | { | ||
| 32 | print(">1ms elapsed since last scan: "); | ||
| 33 | pdec(timer_elapsed(last_scan_time)); | ||
| 34 | print("\n"); | ||
| 35 | } | ||
| 36 | last_scan_time = timer_read(); | ||
| 37 | |||
| 38 | } | ||
| 39 | #endif | ||
diff --git a/keyboards/handwired/xealous/matrix_scanrate.h b/keyboards/handwired/xealous/matrix_scanrate.h deleted file mode 100644 index 18d56cd5b..000000000 --- a/keyboards/handwired/xealous/matrix_scanrate.h +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | __attribute__((weak)) | ||
| 2 | void matrix_check_scan_rate(void) {} | ||
| 3 | __attribute__((weak)) | ||
| 4 | void matrix_time_between_scans(void) {} | ||
diff --git a/keyboards/handwired/xealous/rules.mk b/keyboards/handwired/xealous/rules.mk index ef3357982..adbbf1e10 100644 --- a/keyboards/handwired/xealous/rules.mk +++ b/keyboards/handwired/xealous/rules.mk | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | SRC += matrix_scanrate.c matrix.c | 1 | SRC += matrix.c |
| 2 | 2 | ||
| 3 | # MCU name | 3 | # MCU name |
| 4 | MCU = atmega32u4 | 4 | MCU = atmega32u4 |
diff --git a/keyboards/hotdox/matrix.c b/keyboards/hotdox/matrix.c index 11a1142d4..605be3022 100644 --- a/keyboards/hotdox/matrix.c +++ b/keyboards/hotdox/matrix.c | |||
| @@ -9,9 +9,6 @@ | |||
| 9 | #include "matrix.h" | 9 | #include "matrix.h" |
| 10 | #include "hotdox.h" | 10 | #include "hotdox.h" |
| 11 | #include "left.h" | 11 | #include "left.h" |
| 12 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 13 | #include "timer.h" | ||
| 14 | #endif | ||
| 15 | 12 | ||
| 16 | /* | 13 | /* |
| 17 | * This constant define not debouncing time in msecs, but amount of matrix | 14 | * This constant define not debouncing time in msecs, but amount of matrix |
| @@ -41,12 +38,6 @@ static void init_cols(void); | |||
| 41 | static void unselect_rows(void); | 38 | static void unselect_rows(void); |
| 42 | static void select_row(uint8_t row); | 39 | static void select_row(uint8_t row); |
| 43 | 40 | ||
| 44 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 45 | uint32_t matrix_timer; | ||
| 46 | uint32_t matrix_scan_count; | ||
| 47 | #endif | ||
| 48 | |||
| 49 | |||
| 50 | __attribute__ ((weak)) | 41 | __attribute__ ((weak)) |
| 51 | void matrix_init_user(void) {} | 42 | void matrix_init_user(void) {} |
| 52 | 43 | ||
| @@ -90,13 +81,7 @@ void matrix_init(void) | |||
| 90 | } | 81 | } |
| 91 | } | 82 | } |
| 92 | 83 | ||
| 93 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 94 | matrix_timer = timer_read32(); | ||
| 95 | matrix_scan_count = 0; | ||
| 96 | #endif | ||
| 97 | |||
| 98 | matrix_init_quantum(); | 84 | matrix_init_quantum(); |
| 99 | |||
| 100 | } | 85 | } |
| 101 | 86 | ||
| 102 | void matrix_power_up(void) { | 87 | void matrix_power_up(void) { |
| @@ -107,11 +92,6 @@ void matrix_power_up(void) { | |||
| 107 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { | 92 | for (uint8_t i=0; i < MATRIX_ROWS; i++) { |
| 108 | matrix[i] = 0; | 93 | matrix[i] = 0; |
| 109 | } | 94 | } |
| 110 | |||
| 111 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 112 | matrix_timer = timer_read32(); | ||
| 113 | matrix_scan_count = 0; | ||
| 114 | #endif | ||
| 115 | } | 95 | } |
| 116 | 96 | ||
| 117 | // Returns a matrix_row_t whose bits are set if the corresponding key should be | 97 | // Returns a matrix_row_t whose bits are set if the corresponding key should be |
| @@ -142,20 +122,6 @@ uint8_t matrix_scan(void) | |||
| 142 | { | 122 | { |
| 143 | left_scan(); | 123 | left_scan(); |
| 144 | 124 | ||
| 145 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 146 | matrix_scan_count++; | ||
| 147 | |||
| 148 | uint32_t timer_now = timer_read32(); | ||
| 149 | if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { | ||
| 150 | print("matrix scan frequency: "); | ||
| 151 | pdec(matrix_scan_count); | ||
| 152 | print("\n"); | ||
| 153 | matrix_print(); | ||
| 154 | |||
| 155 | matrix_timer = timer_now; | ||
| 156 | matrix_scan_count = 0; | ||
| 157 | } | ||
| 158 | #endif | ||
| 159 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | 125 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { |
| 160 | select_row(i); | 126 | select_row(i); |
| 161 | wait_us(30); // without this wait read unstable value. | 127 | wait_us(30); // without this wait read unstable value. |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index f4d2cd738..9806b5015 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -82,6 +82,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 82 | # include "velocikey.h" | 82 | # include "velocikey.h" |
| 83 | #endif | 83 | #endif |
| 84 | 84 | ||
| 85 | // Only enable this if console is enabled to print to | ||
| 86 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) | ||
| 87 | static uint32_t matrix_timer = 0; | ||
| 88 | static uint32_t matrix_scan_count = 0; | ||
| 89 | |||
| 90 | void matrix_scan_perf_task(void) { | ||
| 91 | matrix_scan_count++; | ||
| 92 | |||
| 93 | uint32_t timer_now = timer_read32(); | ||
| 94 | if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { | ||
| 95 | dprintf("matrix scan frequency: %d\n", matrix_scan_count); | ||
| 96 | |||
| 97 | matrix_timer = timer_now; | ||
| 98 | matrix_scan_count = 0; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | #else | ||
| 102 | # define matrix_scan_perf_task() | ||
| 103 | #endif | ||
| 104 | |||
| 85 | #ifdef MATRIX_HAS_GHOST | 105 | #ifdef MATRIX_HAS_GHOST |
| 86 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | 106 | extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; |
| 87 | static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { | 107 | static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) { |
| @@ -301,6 +321,10 @@ void keyboard_task(void) { | |||
| 301 | 321 | ||
| 302 | MATRIX_LOOP_END: | 322 | MATRIX_LOOP_END: |
| 303 | 323 | ||
| 324 | #ifdef DEBUG_MATRIX_SCAN_RATE | ||
| 325 | matrix_scan_perf_task(); | ||
| 326 | #endif | ||
| 327 | |||
| 304 | #ifdef QWIIC_ENABLE | 328 | #ifdef QWIIC_ENABLE |
| 305 | qwiic_task(); | 329 | qwiic_task(); |
| 306 | #endif | 330 | #endif |
