aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common.mk3
-rw-r--r--tmk_core/common/avr/eeconfig.c8
-rw-r--r--tmk_core/common/eeconfig.h6
-rw-r--r--tmk_core/common/keyboard.c8
-rw-r--r--tmk_core/common/keymap.h3
-rw-r--r--tmk_core/common/magic.c36
-rw-r--r--tmk_core/common/magic.h6
7 files changed, 66 insertions, 4 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index f8006c670..9cb2eb8ec 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -21,6 +21,9 @@ ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes)
21 SRC += $(COMMON_DIR)/bootmagic.c 21 SRC += $(COMMON_DIR)/bootmagic.c
22 SRC += $(COMMON_DIR)/avr/eeconfig.c 22 SRC += $(COMMON_DIR)/avr/eeconfig.c
23 OPT_DEFS += -DBOOTMAGIC_ENABLE 23 OPT_DEFS += -DBOOTMAGIC_ENABLE
24else
25 SRC += $(COMMON_DIR)/magic.c
26 SRC += $(COMMON_DIR)/avr/eeconfig.c
24endif 27endif
25 28
26ifeq ($(strip $(MOUSEKEY_ENABLE)), yes) 29ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
diff --git a/tmk_core/common/avr/eeconfig.c b/tmk_core/common/avr/eeconfig.c
index 5bd47dc6a..25bb9e849 100644
--- a/tmk_core/common/avr/eeconfig.c
+++ b/tmk_core/common/avr/eeconfig.c
@@ -13,6 +13,9 @@ void eeconfig_init(void)
13#ifdef BACKLIGHT_ENABLE 13#ifdef BACKLIGHT_ENABLE
14 eeprom_write_byte(EECONFIG_BACKLIGHT, 0); 14 eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
15#endif 15#endif
16#ifdef AUDIO_ENABLE
17 eeprom_write_byte(EECONFIG_AUDIO, 0xFF); // On by default
18#endif
16} 19}
17 20
18void eeconfig_enable(void) 21void eeconfig_enable(void)
@@ -43,3 +46,8 @@ void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val
43uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } 46uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
44void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); } 47void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); }
45#endif 48#endif
49
50#ifdef AUDIO_ENABLE
51uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
52void eeconfig_write_audio(uint8_t val) { eeprom_write_byte(EECONFIG_AUDIO, val); }
53#endif \ No newline at end of file
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 3cd1a174f..ddefca134 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
31#define EECONFIG_KEYMAP (uint8_t *)4 31#define EECONFIG_KEYMAP (uint8_t *)4
32#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 32#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
33#define EECONFIG_BACKLIGHT (uint8_t *)6 33#define EECONFIG_BACKLIGHT (uint8_t *)6
34#define EECONFIG_AUDIO (uint8_t *)7
34 35
35 36
36/* debug bit */ 37/* debug bit */
@@ -72,4 +73,9 @@ uint8_t eeconfig_read_backlight(void);
72void eeconfig_write_backlight(uint8_t val); 73void eeconfig_write_backlight(uint8_t val);
73#endif 74#endif
74 75
76#ifdef AUDIO_ENABLE
77uint8_t eeconfig_read_audio(void);
78void eeconfig_write_audio(uint8_t val);
79#endif
80
75#endif 81#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 302b3ec87..1d9981848 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -27,7 +27,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
27#include "command.h" 27#include "command.h"
28#include "util.h" 28#include "util.h"
29#include "sendchar.h" 29#include "sendchar.h"
30#include "bootmagic.h" 30#ifdef BOOTMAGIC_ENABLE
31 #include "bootmagic.h"
32#else
33 #include "magic.h"
34#endif
31#include "eeconfig.h" 35#include "eeconfig.h"
32#include "backlight.h" 36#include "backlight.h"
33#ifdef MOUSEKEY_ENABLE 37#ifdef MOUSEKEY_ENABLE
@@ -86,6 +90,8 @@ void keyboard_init(void)
86 90
87#ifdef BOOTMAGIC_ENABLE 91#ifdef BOOTMAGIC_ENABLE
88 bootmagic(); 92 bootmagic();
93#else
94 magic();
89#endif 95#endif
90 96
91#ifdef BACKLIGHT_ENABLE 97#ifdef BACKLIGHT_ENABLE
diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h
index e1a6f992e..abc9bdb32 100644
--- a/tmk_core/common/keymap.h
+++ b/tmk_core/common/keymap.h
@@ -22,8 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include <stdbool.h> 22#include <stdbool.h>
23#include "action.h" 23#include "action.h"
24 24
25
26#ifdef BOOTMAGIC_ENABLE
27/* NOTE: Not portable. Bit field order depends on implementation */ 25/* NOTE: Not portable. Bit field order depends on implementation */
28typedef union { 26typedef union {
29 uint8_t raw; 27 uint8_t raw;
@@ -39,7 +37,6 @@ typedef union {
39 }; 37 };
40} keymap_config_t; 38} keymap_config_t;
41keymap_config_t keymap_config; 39keymap_config_t keymap_config;
42#endif
43 40
44 41
45/* translates key to keycode */ 42/* translates key to keycode */
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
new file mode 100644
index 000000000..f21d1346c
--- /dev/null
+++ b/tmk_core/common/magic.c
@@ -0,0 +1,36 @@
1#include <stdint.h>
2#include <stdbool.h>
3#include <util/delay.h>
4#include "matrix.h"
5#include "bootloader.h"
6#include "debug.h"
7#include "keymap.h"
8#include "host.h"
9#include "action_layer.h"
10#include "eeconfig.h"
11#include "magic.h"
12
13keymap_config_t keymap_config;
14
15void magic(void)
16{
17 /* check signature */
18 if (!eeconfig_is_enabled()) {
19 eeconfig_init();
20 }
21
22 /* debug enable */
23 debug_config.raw = eeconfig_read_debug();
24
25 /* keymap config */
26 keymap_config.raw = eeconfig_read_keymap();
27
28#ifdef NKRO_ENABLE
29 keyboard_nkro = keymap_config.nkro;
30#endif
31
32 uint8_t default_layer = 0;
33 default_layer = eeconfig_read_default_layer();
34 default_layer_set((uint32_t)default_layer);
35
36} \ No newline at end of file
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h
new file mode 100644
index 000000000..3fa2d8b81
--- /dev/null
+++ b/tmk_core/common/magic.h
@@ -0,0 +1,6 @@
1#ifndef MAGIC_H
2#define MAGIC_H
3
4void magic(void);
5
6#endif