1
0

Support for odd-byte keymap

This commit is contained in:
Kai Ryu 2014-04-10 15:55:11 +09:00
parent 55f603394d
commit d8b992585e
2 changed files with 5 additions and 3 deletions

View File

@ -36,8 +36,10 @@ void keymap_in_eeprom_disable(void) {
bool check_keymap_in_eeprom(void) { bool check_keymap_in_eeprom(void) {
uint16_t checksum_in_eeprom = eeprom_read_word(EECONFIG_KEYMAP_CHECKSUM); uint16_t checksum_in_eeprom = eeprom_read_word(EECONFIG_KEYMAP_CHECKSUM);
uint16_t checksum = EECONFIG_MAGIC_NUMBER; uint16_t checksum = EECONFIG_MAGIC_NUMBER;
for (uint16_t i = 0; i < KEYMAP_WORD_SIZE; i++) { for (uint16_t i = 0; i < KEYMAP_SIZE; i++) {
checksum += eeprom_read_word(EECONFIG_KEYMAP_FN_ACTIONS + i); uint8_t byte = eeprom_read_byte((uint8_t *)EECONFIG_KEYMAP_FN_ACTIONS + i);
uint16_t word = (i & 1) ? byte << 8 : byte;
checksum += word;
} }
#ifdef DEBUG #ifdef DEBUG
eeprom_write_word(EECONFIG_KEYMAP_DEBUG, checksum); eeprom_write_word(EECONFIG_KEYMAP_DEBUG, checksum);

View File

@ -41,7 +41,7 @@ typedef struct {
#define EECONFIG_KEYMAP_CHECKSUM (uint16_t *)(EECONFIG_KEYMAP_IN_EEPROM) #define EECONFIG_KEYMAP_CHECKSUM (uint16_t *)(EECONFIG_KEYMAP_IN_EEPROM)
#define EECONFIG_KEYMAP_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1) #define EECONFIG_KEYMAP_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1)
#define EECONFIG_KEYMAP_KEYMAPS (uint8_t *)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTIONS_COUNT) #define EECONFIG_KEYMAP_KEYMAPS (uint8_t *)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTIONS_COUNT)
#define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_KEYMAPS + KEYS_COUNT) #define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM - 1)
#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT) #define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT)
#define KEYMAP_WORD_SIZE ((KEYMAP_SIZE + 1) / 2) #define KEYMAP_WORD_SIZE ((KEYMAP_SIZE + 1) / 2)