aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorTakeshi ISHII <2170248+mtei@users.noreply.github.com>2021-01-28 02:34:50 +0900
committerGitHub <noreply@github.com>2021-01-28 04:34:50 +1100
commitc27f16158d3f9524bb2d608ef4918783e7551637 (patch)
treeb12d6d7b6849b4954d5912b6ff9576f1c6250825 /tmk_core
parent6937f1d70e7d48980032446b137462a66c457bd8 (diff)
downloadqmk_firmware-c27f16158d3f9524bb2d608ef4918783e7551637.tar.gz
qmk_firmware-c27f16158d3f9524bb2d608ef4918783e7551637.zip
add get_matrix_scan_rate() to tmk_core/common/keyboard.c (#11489)
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/keyboard.c11
-rw-r--r--tmk_core/common/keyboard.h2
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)
101static uint32_t matrix_timer = 0; 101static uint32_t matrix_timer = 0;
102static uint32_t matrix_scan_count = 0; 102static uint32_t matrix_scan_count = 0;
103static uint32_t last_matrix_scan_count = 0;
103 104
104void matrix_scan_perf_task(void) { 105void 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
119uint32_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);
73void housekeeping_task_kb(void); 73void housekeeping_task_kb(void);
74void housekeeping_task_user(void); 74void housekeeping_task_user(void);
75 75
76uint32_t get_matrix_scan_rate(void);
77
76#ifdef __cplusplus 78#ifdef __cplusplus
77} 79}
78#endif 80#endif