Added debug counter of matrix scan frequency

This commit is contained in:
Oleg Kostyuk 2013-09-08 18:25:40 +03:00
parent e6ad104bd8
commit 6b7921f91b
2 changed files with 27 additions and 0 deletions

View file

@ -71,5 +71,6 @@ Project located at <https://github.com/benblazak/ergodox-firmware>
//#define NO_ACTION_ONESHOT
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
//#define DEBUG_MATRIX_FREQ
#endif

View file

@ -29,6 +29,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "matrix.h"
#include "ergodox.h"
#include "i2cmaster.h"
#ifdef DEBUG_MATRIX_FREQ
#include "timer.h"
#endif
#ifndef DEBOUNCE
# define DEBOUNCE 5
@ -44,6 +47,10 @@ static void init_cols(void);
static void unselect_rows(uint8_t mcp23018_status);
static void select_row(uint8_t mcp23018_status, uint8_t row);
#ifdef DEBUG_MATRIX_FREQ
uint32_t matrix_timer;
uint32_t matrix_scan_count;
#endif
inline
uint8_t matrix_rows(void)
@ -71,10 +78,29 @@ void matrix_init(void)
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
#ifdef DEBUG_MATRIX_FREQ
matrix_timer = timer_read32();
matrix_scan_count = 0;
#endif
}
uint8_t matrix_scan(void)
{
#ifdef DEBUG_MATRIX_FREQ
matrix_scan_count++;
uint32_t timer_now = timer_read32();
if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) {
print("matrix scan frequency: ");
pdec(matrix_scan_count);
print("\n");
matrix_timer = timer_now;
matrix_scan_count = 0;
}
#endif
#ifdef KEYMAP_CUB
uint8_t layer = biton32(layer_state);