From 09d924931086c13f2e24e2b51f69c8aed513a4fe Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 22 Nov 2013 10:58:02 +0900 Subject: [PATCH] Fix some debug codes --- common/keymap_ex.c | 6 ++++++ common/keymap_ex.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/common/keymap_ex.c b/common/keymap_ex.c index cb67e8f4..3d55c08c 100644 --- a/common/keymap_ex.c +++ b/common/keymap_ex.c @@ -32,6 +32,12 @@ void keymap_init(void) { bool check_keymap_in_eeprom(void) { uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum); uint16_t checksum = EECONFIG_MAGIC_NUMBER; + for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) { + checksum ^= eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i)); + } +#ifdef DEBUG + eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum); +#endif return (checksum_in_eeprom == checksum); } diff --git a/common/keymap_ex.h b/common/keymap_ex.h index be229b10..435547a0 100644 --- a/common/keymap_ex.h +++ b/common/keymap_ex.h @@ -33,11 +33,13 @@ typedef struct { uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; } keymap_ex_t; +#define EECONFIG_KEYMAP_DEBUG (EECONFIG_KEYMAP_EX - sizeof(uint16_t)) #define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX) #define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t)) #define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT) #define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS) +#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT) #define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index) #define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col))