diff --git a/common.mk b/common.mk
index 5fb76e739b..a99e335ee1 100644
--- a/common.mk
+++ b/common.mk
@@ -10,6 +10,7 @@ SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/print.c \
$(COMMON_DIR)/debug.c \
$(COMMON_DIR)/bootloader.c \
+ $(COMMON_DIR)/eeconfig.c \
$(COMMON_DIR)/util.c
diff --git a/common/command.c b/common/command.c
index 202d531fd8..40932e0501 100644
--- a/common/command.c
+++ b/common/command.c
@@ -27,6 +27,7 @@ along with this program. If not, see .
#include "keyboard.h"
#include "bootloader.h"
#include "layer_switch.h"
+#include "eeconfig.h"
#include "command.h"
#ifdef MOUSEKEY_ENABLE
@@ -108,6 +109,7 @@ static void command_common_help(void)
print("v: print device version & info\n");
print("t: print timer count\n");
print("s: print status\n");
+ print("e: print eeprom config\n");
#ifdef NKRO_ENABLE
print("n: toggle NKRO\n");
#endif
@@ -121,10 +123,30 @@ static void command_common_help(void)
print("Paus: jump to bootloader\n");
}
+static void print_eeprom_config(void)
+{
+ uint8_t eebyte;
+
+ print("magic: "); print_hex16(eeprom_read_word((uint16_t)0)); print("\n");
+
+ eebyte = eeconfig_read_debug();
+ print("debug: "); print_hex8(eebyte); print("\n");
+
+ eebyte = eeconfig_read_defalt_layer();
+ print("defalt_layer: "); print_hex8(eebyte); print("\n");
+
+ eebyte = eeconfig_read_modifier();
+ print("modifiers: "); print_hex8(eebyte); print("\n");
+}
+
static bool command_common(uint8_t code)
{
static host_driver_t *host_driver = 0;
switch (code) {
+ case KC_E:
+ print("eeprom config\n");
+ print_eeprom_config();
+ break;
case KC_CAPSLOCK:
if (host_get_driver()) {
host_driver = host_get_driver();
diff --git a/common/eeconfig.c b/common/eeconfig.c
new file mode 100644
index 0000000000..a5834aa2c7
--- /dev/null
+++ b/common/eeconfig.c
@@ -0,0 +1,29 @@
+#include
+#include
+#include
+#include "eeconfig.h"
+
+
+void eeconfig_init(void)
+{
+ eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
+ eeprom_write_byte(EECONFIG_DEBUG, 0);
+ eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0);
+ eeprom_write_byte(EECONFIG_MODIFIER, 0);
+ eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
+}
+
+bool eeconfig_initialized(void)
+{
+ return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
+}
+
+uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
+void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); }
+
+uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
+void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); }
+
+uint8_t eeconfig_read_modifier(void) { return eeprom_read_byte(EECONFIG_MODIFIER); }
+void eeconfig_write_modifier(uint8_t val) { eeprom_write_byte(EECONFIG_MODIFIER, val); }
+
diff --git a/common/eeconfig.h b/common/eeconfig.h
new file mode 100644
index 0000000000..088171f575
--- /dev/null
+++ b/common/eeconfig.h
@@ -0,0 +1,59 @@
+/*
+Copyright 2013 Jun Wako
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*/
+
+#ifndef EECONFIG_H
+#define EECONFIG_H
+
+#include
+
+#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED
+
+/* eeprom parameteter address */
+#define EECONFIG_MAGIC (uint16_t *)0
+#define EECONFIG_DEBUG (uint8_t *)2
+#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
+#define EECONFIG_MODIFIER (uint8_t *)4
+#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
+
+
+/* config bit */
+#define EECONFIG_DEBUG_ENABLE (1<<0)
+#define EECONFIG_DEBUG_MATRIX (1<<1)
+#define EECONFIG_DEBUG_KEYBOARD (1<<2)
+#define EECONFIG_DEBUG_MOUSE (1<<3)
+
+#define EECONFIG_MODIFIER_CONTROL_CAPSLOCK (1<<0)
+#define EECONFIG_MODIFIER_ALT_GUI (1<<1)
+#define EECONFIG_MODIFIER_ESC_GRAVE (1<<2)
+#define EECONFIG_MODIFIER_BACKSPACE_BACKSLASH (1<<3)
+#define EECONFIG_MODIFIER_NO_GUI (1<<4)
+
+
+bool eeconfig_initialized(void);
+
+void eeconfig_init(void);
+
+uint8_t eeconfig_read_debug(void);
+void eeconfig_write_debug(uint8_t val);
+
+uint8_t eeconfig_read_defalt_layer(void);
+void eeconfig_write_defalt_layer(uint8_t val);
+
+uint8_t eeconfig_read_modifier(void);
+void eeconfig_write_modifier(uint8_t val);
+
+#endif
diff --git a/common/keyboard.c b/common/keyboard.c
index 91f321d9ca..2206f16759 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -32,6 +32,7 @@ along with this program. If not, see .
#ifdef MOUSEKEY_ENABLE
#include "mousekey.h"
#endif
+#include "eeconfig.h"
#ifdef MATRIX_HAS_GHOST
@@ -59,6 +60,9 @@ void keyboard_init(void)
timer_init();
matrix_init();
+#ifdef PS2_MOUSE_ENABLE
+ ps2_mouse_init();
+#endif
/* matrix scan for boot magic keys */
#ifdef DEBOUNCE
@@ -74,12 +78,25 @@ void keyboard_init(void)
if (IS_BOOTMAGIC_BOOTLOADER()) bootloader_jump();
#endif
#ifdef IS_BOOTMAGIC_DEBUG
- if (IS_BOOTMAGIC_DEBUG()) debug_enable = true;
+ if (IS_BOOTMAGIC_DEBUG()) {
+ eeconfig_write_debug(eeconfig_read_debug() ^ EECONFIG_DEBUG_ENABLE);
+ }
+#endif
+#ifdef IS_BOOTMAGIC_EEPROM_CLEAR
+ if (IS_BOOTMAGIC_EEPROM_CLEAR()) eeconfig_init();
#endif
-#ifdef PS2_MOUSE_ENABLE
- ps2_mouse_init();
-#endif
+ if (eeconfig_initialized()) {
+ uint8_t config;
+ 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);
+ } else {
+ eeconfig_init();
+ }
+
}
/*
diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h
index ef0c9a1735..3a7a3f97fb 100644
--- a/keyboard/gh60/config.h
+++ b/keyboard/gh60/config.h
@@ -56,10 +56,13 @@ along with this program. If not, see .
/* key position on matrix(ROW:COL) */
#define KEY_FN 0x4A
#define KEY_D 0x23
+#define KEY_ESC 0x00
#define KEY_IS_ON(key) matrix_is_on((key)>>4, (key)&0xF)
/* kick up bootloader */
#define IS_BOOTMAGIC_BOOTLOADER() KEY_IS_ON(KEY_FN)
/* debug on */
#define IS_BOOTMAGIC_DEBUG() KEY_IS_ON(KEY_D)
+/* eeprom clear */
+#define IS_BOOTMAGIC_EEPROM_CLEAR() KEY_IS_ON(KEY_ESC)
#endif