]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix debug parameter setting in eeconfig
authortmk <nobody@nowhere>
Mon, 11 Mar 2013 06:10:56 +0000 (15:10 +0900)
committertmk <nobody@nowhere>
Mon, 11 Mar 2013 06:10:56 +0000 (15:10 +0900)
common/bootmagic.c
common/bootmagic.h
common/eeconfig.c
common/eeconfig.h
common/keyboard.c

index 46fbc180a468a372b1b11614cb90240a094aca12..388099e2e63acf4d7c84d065514a5d0371134dfe 100644 (file)
 
 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();
     }
index d32a5bef88b5221b9f3d93a2f2d6cbb49d312c5d..5791b221f41c265213240e17a207134bbe5b9537 100644 (file)
@@ -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 */
index f536dc06c922dda1df337439c02f9553f8c37561..cea3810ee30046eae643bbe234bbe45a5905751d 100644 (file)
@@ -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); }
index 2786995a29e391dab5acb56fdad6bb78cca07b46..3e195478b5a232818b6be8b3339fb95cdaea883c 100644 (file)
@@ -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);
 
index 0a0bacd4330dea81d623fed8ceab53906ebcb955..1acb79861da04bb76d70702f0f8fbdc672115c81 100644 (file)
@@ -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();
     }