瀏覽代碼

Fix debug parameter setting in eeconfig

tags/v1.9
tmk 11 年之前
父節點
當前提交
d055e0633e
共有 5 個文件被更改,包括 31 次插入12 次删除
  1. 2
    2
      common/bootmagic.c
  2. 2
    2
      common/bootmagic.h
  3. 12
    2
      common/eeconfig.c
  4. 9
    1
      common/eeconfig.h
  5. 6
    5
      common/keyboard.c

+ 2
- 2
common/bootmagic.c 查看文件



void bootmagic(void) void bootmagic(void)
{ {
if (!BOOTMAGIC_IS_ENABLED()) { return; }

/* do scans in case of bounce */ /* do scans in case of bounce */
uint8_t scan = 100; uint8_t scan = 100;
while (scan--) { matrix_scan(); _delay_ms(1); } while (scan--) { matrix_scan(); _delay_ms(1); }


if (!BOOTMAGIC_IS_ENABLE()) { return; }

if (bootmagic_scan_keycode(BOOTMAGIC_BOOTLOADER_KEY)) { if (bootmagic_scan_keycode(BOOTMAGIC_BOOTLOADER_KEY)) {
bootloader_jump(); bootloader_jump();
} }

+ 2
- 2
common/bootmagic.h 查看文件

#define BOOTMAGIC_H #define BOOTMAGIC_H




#ifndef BOOTMAGIC_IS_ENABLE
#define BOOTMAGIC_IS_ENABLE() true
#ifndef BOOTMAGIC_IS_ENABLED
#define BOOTMAGIC_IS_ENABLED() true
#endif #endif


/* kick up bootloader */ /* kick up bootloader */

+ 12
- 2
common/eeconfig.c 查看文件

eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
} }


bool eeconfig_initialized(void)
void eeconfig_enable(void)
{ {
return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
}

void eeconfig_disable(void)
{
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
}

bool eeconfig_is_enabled(void)
{
return EECONFIG_IS_ENABLED() && (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
} }


uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }

+ 9
- 1
common/eeconfig.h 查看文件



#include <stdint.h> #include <stdint.h>


#ifndef EECONFIG_IS_ENABLED
#define EECONFIG_IS_ENABLED() true
#endif

#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED #define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED


/* eeprom parameteter address */ /* eeprom parameteter address */
}; };
} keyconf; } keyconf;


bool eeconfig_initialized(void);
bool eeconfig_is_enabled(void);


void eeconfig_init(void); void eeconfig_init(void);


void eeconfig_enable(void);

void eeconfig_disable(void);

uint8_t eeconfig_read_debug(void); uint8_t eeconfig_read_debug(void);
void eeconfig_write_debug(uint8_t val); void eeconfig_write_debug(uint8_t val);



+ 6
- 5
common/keyboard.c 查看文件



bootmagic(); bootmagic();


if (eeconfig_initialized()) {
if (eeconfig_is_enabled()) {
uint8_t config; uint8_t config;
config = eeconfig_read_debug(); config = eeconfig_read_debug();
debug_enable = (config & EECONFIG_DEBUG_ENABLE);
debug_matrix = (config & EECONFIG_DEBUG_MATRIX);
debug_keyboard = (config & EECONFIG_DEBUG_KEYBOARD);
debug_mouse = (config & EECONFIG_DEBUG_MOUSE);
// ignored if debug is enabled by program before.
if (!debug_enable) debug_enable = (config & EECONFIG_DEBUG_ENABLE);
if (!debug_matrix) debug_matrix = (config & EECONFIG_DEBUG_MATRIX);
if (!debug_keyboard) debug_keyboard = (config & EECONFIG_DEBUG_KEYBOARD);
if (!debug_mouse) debug_mouse = (config & EECONFIG_DEBUG_MOUSE);
} else { } else {
eeconfig_init(); eeconfig_init();
} }

Loading…
取消
儲存