From 359b68d35f0763ab0cafa2fb800e0a3497291f95 Mon Sep 17 00:00:00 2001 From: tmk Date: Thu, 7 Mar 2013 03:30:08 +0900 Subject: Add eeconfig.c - eeprom stored paramerters --- common/keyboard.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'common/keyboard.c') 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 PS2_MOUSE_ENABLE - ps2_mouse_init(); +#ifdef IS_BOOTMAGIC_EEPROM_CLEAR + if (IS_BOOTMAGIC_EEPROM_CLEAR()) eeconfig_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(); + } + } /* -- cgit v1.2.3 From 4d64fd8faa8b1a0ceb9019446ba6915aaf1812ea Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 9 Mar 2013 11:22:27 +0900 Subject: Add bootmagic.c and fix bootloader_jump --- common/keyboard.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'common/keyboard.c') diff --git a/common/keyboard.c b/common/keyboard.c index 2206f16759..0a0bacd433 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -28,7 +28,7 @@ along with this program. If not, see . #include "command.h" #include "util.h" #include "sendchar.h" -#include "bootloader.h" +#include "bootmagic.h" #ifdef MOUSEKEY_ENABLE #include "mousekey.h" #endif @@ -64,27 +64,7 @@ void keyboard_init(void) ps2_mouse_init(); #endif - /* matrix scan for boot magic keys */ -#ifdef DEBOUNCE - uint8_t scan = DEBOUNCE * 2; - while (scan--) { matrix_scan(); _delay_ms(1); } -#else - matrix_scan(); -#endif - - /* boot magic keys */ -#ifdef IS_BOOTMAGIC_BOOTLOADER - /* kick up bootloader */ - if (IS_BOOTMAGIC_BOOTLOADER()) bootloader_jump(); -#endif -#ifdef IS_BOOTMAGIC_DEBUG - 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 + bootmagic(); if (eeconfig_initialized()) { uint8_t config; @@ -96,7 +76,6 @@ void keyboard_init(void) } else { eeconfig_init(); } - } /* -- cgit v1.2.3 From d055e0633e36e97802d60554f6002e47021ba5fd Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 11 Mar 2013 15:10:56 +0900 Subject: Fix debug parameter setting in eeconfig --- common/keyboard.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'common/keyboard.c') 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(); } -- cgit v1.2.3 From ef8439bddb2d7fe5fd95faf2b6bebd8235acf160 Mon Sep 17 00:00:00 2001 From: tmk Date: Mon, 11 Mar 2013 15:28:14 +0900 Subject: Add build option BOOTMAGIC_ENABLE --- common/keyboard.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'common/keyboard.c') diff --git a/common/keyboard.c b/common/keyboard.c index 1acb79861d..401fdb4e17 100644 --- a/common/keyboard.c +++ b/common/keyboard.c @@ -29,10 +29,8 @@ along with this program. If not, see . #include "util.h" #include "sendchar.h" #include "bootmagic.h" -#ifdef MOUSEKEY_ENABLE -#include "mousekey.h" -#endif #include "eeconfig.h" +#include "mousekey.h" #ifdef MATRIX_HAS_GHOST @@ -64,6 +62,7 @@ void keyboard_init(void) ps2_mouse_init(); #endif +#ifdef BOOTMAGIC_ENABLE bootmagic(); if (eeconfig_is_enabled()) { @@ -77,6 +76,7 @@ void keyboard_init(void) } else { eeconfig_init(); } +#endif } /* -- cgit v1.2.3