summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-03-11 15:10:56 +0900
committertmk <nobody@nowhere>2013-03-11 15:10:56 +0900
commitd055e0633e36e97802d60554f6002e47021ba5fd (patch)
treed129174dd33232723fbd60795ccb5132701ad51f /common
parent1d5bbb55f28eb2e9eff0543753b8cb85f3b94282 (diff)
Fix debug parameter setting in eeconfig
Diffstat (limited to 'common')
-rw-r--r--common/bootmagic.c4
-rw-r--r--common/bootmagic.h4
-rw-r--r--common/eeconfig.c14
-rw-r--r--common/eeconfig.h10
-rw-r--r--common/keyboard.c11
5 files changed, 31 insertions, 12 deletions
diff --git a/common/bootmagic.c b/common/bootmagic.c
index 46fbc180a4..388099e2e6 100644
--- a/common/bootmagic.c
+++ b/common/bootmagic.c
@@ -10,12 +10,12 @@
void bootmagic(void)
{
+ if (!BOOTMAGIC_IS_ENABLED()) { return; }
+
/* do scans in case of bounce */
uint8_t scan = 100;
while (scan--) { matrix_scan(); _delay_ms(1); }
- if (!BOOTMAGIC_IS_ENABLE()) { return; }
-
if (bootmagic_scan_keycode(BOOTMAGIC_BOOTLOADER_KEY)) {
bootloader_jump();
}
diff --git a/common/bootmagic.h b/common/bootmagic.h
index d32a5bef88..5791b221f4 100644
--- a/common/bootmagic.h
+++ b/common/bootmagic.h
@@ -2,8 +2,8 @@
#define BOOTMAGIC_H
-#ifndef BOOTMAGIC_IS_ENABLE
-#define BOOTMAGIC_IS_ENABLE() true
+#ifndef BOOTMAGIC_IS_ENABLED
+#define BOOTMAGIC_IS_ENABLED() true
#endif
/* kick up bootloader */
diff --git a/common/eeconfig.c b/common/eeconfig.c
index f536dc06c9..cea3810ee3 100644
--- a/common/eeconfig.c
+++ b/common/eeconfig.c
@@ -13,9 +13,19 @@ void eeconfig_init(void)
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); }
diff --git a/common/eeconfig.h b/common/eeconfig.h
index 2786995a29..3e195478b5 100644
--- a/common/eeconfig.h
+++ b/common/eeconfig.h
@@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
+#ifndef EECONFIG_IS_ENABLED
+#define EECONFIG_IS_ENABLED() true
+#endif
+
#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED
/* eeprom parameteter address */
@@ -61,10 +65,14 @@ typedef union {
};
} keyconf;
-bool eeconfig_initialized(void);
+bool eeconfig_is_enabled(void);
void eeconfig_init(void);
+void eeconfig_enable(void);
+
+void eeconfig_disable(void);
+
uint8_t eeconfig_read_debug(void);
void eeconfig_write_debug(uint8_t val);
diff --git a/common/keyboard.c b/common/keyboard.c
index 0a0bacd433..1acb79861d 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -66,13 +66,14 @@ void keyboard_init(void)
bootmagic();
- if (eeconfig_initialized()) {
+ if (eeconfig_is_enabled()) {
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);
+ // 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 {
eeconfig_init();
}