summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorOlivier <olivier@gid0.org>2016-04-17 19:54:06 +0200
committerOlivier <olivier@gid0.org>2016-04-17 19:54:06 +0200
commitb03a9f7252781b7fee75a684ba77650dc195dca5 (patch)
tree43d6a80f4f4cf47c5f571397a0a17ec6e7ef0083 /tmk_core
parent0715cf46ac369921fd39b1b62d8a95fc89d48244 (diff)
parenta67d425f4d5278595e7ab785a0f246b83fb1a09f (diff)
Merge https://github.com/jackhumbert/qmk_firmware
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common.mk30
-rw-r--r--tmk_core/common/action_code.h2
-rw-r--r--tmk_core/common/action_layer.c8
-rw-r--r--tmk_core/common/action_layer.h1
-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.c3
-rw-r--r--tmk_core/common/keymap.h3
-rw-r--r--tmk_core/common/magic.c36
-rw-r--r--tmk_core/common/magic.h6
-rw-r--r--tmk_core/protocol/lufa.mk4
12 files changed, 90 insertions, 25 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 89c366f554..9cb2eb8ecd 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -17,66 +17,70 @@ SRC += $(COMMON_DIR)/host.c \
# Option modules
-ifdef BOOTMAGIC_ENABLE
+ifeq ($(strip $(BOOTMAGIC_ENABLE)), yes)
SRC += $(COMMON_DIR)/bootmagic.c
SRC += $(COMMON_DIR)/avr/eeconfig.c
OPT_DEFS += -DBOOTMAGIC_ENABLE
+else
+ SRC += $(COMMON_DIR)/magic.c
+ SRC += $(COMMON_DIR)/avr/eeconfig.c
endif
-ifdef MOUSEKEY_ENABLE
+ifeq ($(strip $(MOUSEKEY_ENABLE)), yes)
SRC += $(COMMON_DIR)/mousekey.c
OPT_DEFS += -DMOUSEKEY_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
endif
-ifdef EXTRAKEY_ENABLE
+ifeq ($(strip $(EXTRAKEY_ENABLE)), yes)
OPT_DEFS += -DEXTRAKEY_ENABLE
endif
-ifdef CONSOLE_ENABLE
+ifeq ($(strip $(CONSOLE_ENABLE)), yes)
OPT_DEFS += -DCONSOLE_ENABLE
else
OPT_DEFS += -DNO_PRINT
OPT_DEFS += -DNO_DEBUG
endif
-ifdef COMMAND_ENABLE
+ifeq ($(strip $(COMMAND_ENABLE)), yes)
SRC += $(COMMON_DIR)/command.c
OPT_DEFS += -DCOMMAND_ENABLE
endif
-ifdef NKRO_ENABLE
+ifeq ($(strip $(NKRO_ENABLE)), yes)
OPT_DEFS += -DNKRO_ENABLE
endif
-ifdef MIDI_ENABLE
+ifeq ($(strip $(MIDI_ENABLE)), yes)
OPT_DEFS += -DMIDI_ENABLE
endif
-ifdef AUDIO_ENABLE
+ifeq ($(strip $(AUDIO_ENABLE)), yes)
OPT_DEFS += -DAUDIO_ENABLE
endif
-ifdef USB_6KRO_ENABLE
+ifeq ($(strip $(USB_6KRO_ENABLE)), yes)
OPT_DEFS += -DUSB_6KRO_ENABLE
endif
-ifdef SLEEP_LED_ENABLE
+ifeq ($(strip $(SLEEP_LED_ENABLE)), yes)
SRC += $(COMMON_DIR)/sleep_led.c
OPT_DEFS += -DSLEEP_LED_ENABLE
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
endif
-ifdef BACKLIGHT_ENABLE
+ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
SRC += $(COMMON_DIR)/backlight.c
+ SRC += $(COMMON_DIR)/avr/eeconfig.c
OPT_DEFS += -DBACKLIGHT_ENABLE
endif
-ifdef BLUETOOTH_ENABLE
+ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
OPT_DEFS += -DBLUETOOTH_ENABLE
endif
-ifdef KEYMAP_SECTION_ENABLE
+ifeq ($(strip $(KEYMAP_SECTION_ENABLE)), yes)
OPT_DEFS += -DKEYMAP_SECTION_ENABLE
ifeq ($(strip $(MCU)),atmega32u2)
diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h
index 4fe9c1d581..2b0b0b077e 100644
--- a/tmk_core/common/action_code.h
+++ b/tmk_core/common/action_code.h
@@ -301,7 +301,7 @@ enum backlight_opt {
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
-#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level)
+#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | (level))
/* Command */
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
/* Function */
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index fc721a7323..e817c0d515 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -111,7 +111,7 @@ void layer_debug(void)
#endif
#if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
-uint8_t source_layers_cache[MAX_LAYER_BITS][(MATRIX_ROWS * MATRIX_COLS + 7) / 8] = {0};
+uint8_t source_layers_cache[(MATRIX_ROWS * MATRIX_COLS + 7) / 8][MAX_LAYER_BITS] = {0};
void update_source_layers_cache(keypos_t key, uint8_t layer)
{
@@ -120,9 +120,9 @@ void update_source_layers_cache(keypos_t key, uint8_t layer)
const uint8_t storage_bit = key_number % 8;
for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
- source_layers_cache[bit_number][storage_row] ^=
+ source_layers_cache[storage_row][bit_number] ^=
(-((layer & (1U << bit_number)) != 0)
- ^ source_layers_cache[bit_number][storage_row])
+ ^ source_layers_cache[storage_row][bit_number])
& (1U << storage_bit);
}
}
@@ -136,7 +136,7 @@ uint8_t read_source_layers_cache(keypos_t key)
for (uint8_t bit_number = 0; bit_number < MAX_LAYER_BITS; bit_number++) {
layer |=
- ((source_layers_cache[bit_number][storage_row]
+ ((source_layers_cache[storage_row][bit_number]
& (1U << storage_bit)) != 0)
<< bit_number;
}
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index 3a4b1e3349..025cf5420f 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -68,6 +68,7 @@ void layer_xor(uint32_t state);
#define layer_and(state)
#define layer_xor(state)
#define layer_debug()
+
#endif
/* pressed actions cache */
diff --git a/tmk_core/common/avr/eeconfig.c b/tmk_core/common/avr/eeconfig.c
index 5bd47dc6ad..25bb9e849c 100644
--- a/tmk_core/common/avr/eeconfig.c
+++ b/tmk_core/common/avr/eeconfig.c
@@ -13,6 +13,9 @@ void eeconfig_init(void)
#ifdef BACKLIGHT_ENABLE
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
#endif
+#ifdef AUDIO_ENABLE
+ eeprom_write_byte(EECONFIG_AUDIO, 0xFF); // On by default
+#endif
}
void eeconfig_enable(void)
@@ -43,3 +46,8 @@ void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); }
#endif
+
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
+void eeconfig_write_audio(uint8_t val) { eeprom_write_byte(EECONFIG_AUDIO, val); }
+#endif \ No newline at end of file
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 3cd1a174f6..ddefca1347 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/>.
#define EECONFIG_KEYMAP (uint8_t *)4
#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
#define EECONFIG_BACKLIGHT (uint8_t *)6
+#define EECONFIG_AUDIO (uint8_t *)7
/* debug bit */
@@ -72,4 +73,9 @@ uint8_t eeconfig_read_backlight(void);
void eeconfig_write_backlight(uint8_t val);
#endif
+#ifdef AUDIO_ENABLE
+uint8_t eeconfig_read_audio(void);
+void eeconfig_write_audio(uint8_t val);
+#endif
+
#endif
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 302b3ec87c..1d99818481 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/>.
#include "command.h"
#include "util.h"
#include "sendchar.h"
-#include "bootmagic.h"
+#ifdef BOOTMAGIC_ENABLE
+ #include "bootmagic.h"
+#else
+ #include "magic.h"
+#endif
#include "eeconfig.h"
#include "backlight.h"
#ifdef MOUSEKEY_ENABLE
@@ -86,6 +90,8 @@ void keyboard_init(void)
#ifdef BOOTMAGIC_ENABLE
bootmagic();
+#else
+ magic();
#endif
#ifdef BACKLIGHT_ENABLE
diff --git a/tmk_core/common/keymap.c b/tmk_core/common/keymap.c
index 11f4aa8aaa..8955fc710d 100644
--- a/tmk_core/common/keymap.c
+++ b/tmk_core/common/keymap.c
@@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_macro.h"
#include "wait.h"
#include "debug.h"
-
+#include "bootloader.h"
static action_t keycode_to_action(uint8_t keycode);
@@ -143,6 +143,7 @@ static action_t keycode_to_action(uint8_t keycode)
action.code = ACTION_TRANSPARENT;
break;
case KC_BOOTLOADER:
+ action.code = ACTION_NO;
clear_keyboard();
wait_ms(50);
bootloader_jump(); // not return
diff --git a/tmk_core/common/keymap.h b/tmk_core/common/keymap.h
index e1a6f992e6..abc9bdb32d 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/>.
#include <stdbool.h>
#include "action.h"
-
-#ifdef BOOTMAGIC_ENABLE
/* NOTE: Not portable. Bit field order depends on implementation */
typedef union {
uint8_t raw;
@@ -39,7 +37,6 @@ typedef union {
};
} keymap_config_t;
keymap_config_t keymap_config;
-#endif
/* translates key to keycode */
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c
new file mode 100644
index 0000000000..f21d1346c7
--- /dev/null
+++ b/tmk_core/common/magic.c
@@ -0,0 +1,36 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include <util/delay.h>
+#include "matrix.h"
+#include "bootloader.h"
+#include "debug.h"
+#include "keymap.h"
+#include "host.h"
+#include "action_layer.h"
+#include "eeconfig.h"
+#include "magic.h"
+
+keymap_config_t keymap_config;
+
+void magic(void)
+{
+ /* check signature */
+ if (!eeconfig_is_enabled()) {
+ eeconfig_init();
+ }
+
+ /* debug enable */
+ debug_config.raw = eeconfig_read_debug();
+
+ /* keymap config */
+ keymap_config.raw = eeconfig_read_keymap();
+
+#ifdef NKRO_ENABLE
+ keyboard_nkro = keymap_config.nkro;
+#endif
+
+ uint8_t default_layer = 0;
+ default_layer = eeconfig_read_default_layer();
+ default_layer_set((uint32_t)default_layer);
+
+} \ 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 0000000000..3fa2d8b81c
--- /dev/null
+++ b/tmk_core/common/magic.h
@@ -0,0 +1,6 @@
+#ifndef MAGIC_H
+#define MAGIC_H
+
+void magic(void);
+
+#endif
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk
index 4905760bb4..9ac6298f11 100644
--- a/tmk_core/protocol/lufa.mk
+++ b/tmk_core/protocol/lufa.mk
@@ -17,7 +17,7 @@ LUFA_SRC = $(LUFA_DIR)/lufa.c \
$(LUFA_DIR)/descriptor.c \
$(LUFA_SRC_USB)
-ifdef MIDI_ENABLE
+ifeq ($(strip $(MIDI_ENABLE)), yes)
LUFA_SRC += $(LUFA_DIR)/midi/midi.c \
$(LUFA_DIR)/midi/midi_device.c \
$(LUFA_DIR)/midi/bytequeue/bytequeue.c \
@@ -25,7 +25,7 @@ ifdef MIDI_ENABLE
$(LUFA_SRC_USBCLASS)
endif
-ifdef BLUETOOTH_ENABLE
+ifeq ($(strip $(BLUETOOTH_ENABLE)), yes)
LUFA_SRC += $(LUFA_DIR)/bluetooth.c \
$(TMK_DIR)/protocol/serial_uart.c
endif