1
0

Support for odd-byte keymap

This commit is contained in:
Kai Ryu 2014-04-10 15:55:11 +09:00
parent 6aeb9cac41
commit 237bd9e5fe
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) {
uint16_t checksum_in_eeprom = eeprom_read_word(EECONFIG_KEYMAP_CHECKSUM);
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
for (uint16_t i = 0; i < KEYMAP_WORD_SIZE; i++) {
checksum += eeprom_read_word(EECONFIG_KEYMAP_FN_ACTIONS + i);
for (uint16_t i = 0; i < KEYMAP_SIZE; 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
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_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1)
#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_WORD_SIZE ((KEYMAP_SIZE + 1) / 2)