diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/keyboard.c | 11 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.h | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 8c7bdc8b5..b35620e7f 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -97,21 +97,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 97 | #endif | 97 | #endif |
| 98 | 98 | ||
| 99 | // Only enable this if console is enabled to print to | 99 | // Only enable this if console is enabled to print to |
| 100 | #if defined(DEBUG_MATRIX_SCAN_RATE) && defined(CONSOLE_ENABLE) | 100 | #if defined(DEBUG_MATRIX_SCAN_RATE) |
| 101 | static uint32_t matrix_timer = 0; | 101 | static uint32_t matrix_timer = 0; |
| 102 | static uint32_t matrix_scan_count = 0; | 102 | static uint32_t matrix_scan_count = 0; |
| 103 | static uint32_t last_matrix_scan_count = 0; | ||
| 103 | 104 | ||
| 104 | void matrix_scan_perf_task(void) { | 105 | void matrix_scan_perf_task(void) { |
| 105 | matrix_scan_count++; | 106 | matrix_scan_count++; |
| 106 | 107 | ||
| 107 | uint32_t timer_now = timer_read32(); | 108 | uint32_t timer_now = timer_read32(); |
| 108 | if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { | 109 | if (TIMER_DIFF_32(timer_now, matrix_timer) > 1000) { |
| 110 | # if defined(CONSOLE_ENABLE) | ||
| 109 | dprintf("matrix scan frequency: %d\n", matrix_scan_count); | 111 | dprintf("matrix scan frequency: %d\n", matrix_scan_count); |
| 110 | 112 | # endif | |
| 113 | last_matrix_scan_count = matrix_scan_count; | ||
| 111 | matrix_timer = timer_now; | 114 | matrix_timer = timer_now; |
| 112 | matrix_scan_count = 0; | 115 | matrix_scan_count = 0; |
| 113 | } | 116 | } |
| 114 | } | 117 | } |
| 118 | |||
| 119 | uint32_t get_matrix_scan_rate(void) { | ||
| 120 | return last_matrix_scan_count; | ||
| 121 | } | ||
| 115 | #else | 122 | #else |
| 116 | # define matrix_scan_perf_task() | 123 | # define matrix_scan_perf_task() |
| 117 | #endif | 124 | #endif |
diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index d04e685cd..70e8f7e2c 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h | |||
| @@ -73,6 +73,8 @@ void keyboard_post_init_user(void); | |||
| 73 | void housekeeping_task_kb(void); | 73 | void housekeeping_task_kb(void); |
| 74 | void housekeeping_task_user(void); | 74 | void housekeeping_task_user(void); |
| 75 | 75 | ||
| 76 | uint32_t get_matrix_scan_rate(void); | ||
| 77 | |||
| 76 | #ifdef __cplusplus | 78 | #ifdef __cplusplus |
| 77 | } | 79 | } |
| 78 | #endif | 80 | #endif |
