diff options
Diffstat (limited to 'tmk_core/common/bootmagic_lite.c')
-rw-r--r-- | tmk_core/common/bootmagic_lite.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tmk_core/common/bootmagic_lite.c b/tmk_core/common/bootmagic_lite.c new file mode 100644 index 000000000..53bd7b1c7 --- /dev/null +++ b/tmk_core/common/bootmagic_lite.c | |||
@@ -0,0 +1,51 @@ | |||
1 | #include "quantum.h" | ||
2 | |||
3 | bool is_keyboard_left(void); | ||
4 | |||
5 | /** \brief Reset eeprom | ||
6 | * | ||
7 | * ...just incase someone wants to only change the eeprom behaviour | ||
8 | */ | ||
9 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | ||
10 | #if defined(VIA_ENABLE) | ||
11 | via_eeprom_reset(); | ||
12 | #else | ||
13 | eeconfig_disable(); | ||
14 | #endif | ||
15 | } | ||
16 | |||
17 | /** \brief The lite version of TMK's bootmagic based on Wilba. | ||
18 | * | ||
19 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
20 | */ | ||
21 | __attribute__((weak)) void bootmagic_lite(void) { | ||
22 | // We need multiple scans because debouncing can't be turned off. | ||
23 | matrix_scan(); | ||
24 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
25 | wait_ms(DEBOUNCE * 2); | ||
26 | #else | ||
27 | wait_ms(30); | ||
28 | #endif | ||
29 | matrix_scan(); | ||
30 | |||
31 | // If the configured key (commonly Esc) is held down on power up, | ||
32 | // reset the EEPROM valid state and jump to bootloader. | ||
33 | // This isn't very generalized, but we need something that doesn't | ||
34 | // rely on user's keymaps in firmware or EEPROM. | ||
35 | uint8_t row = BOOTMAGIC_LITE_ROW; | ||
36 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | ||
37 | |||
38 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | ||
39 | if (!is_keyboard_left()) { | ||
40 | row = BOOTMAGIC_LITE_ROW_RIGHT; | ||
41 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | ||
42 | } | ||
43 | #endif | ||
44 | |||
45 | if (matrix_get_row(row) & (1 << col)) { | ||
46 | bootmagic_lite_reset_eeprom(); | ||
47 | |||
48 | // Jump to bootloader. | ||
49 | bootloader_jump(); | ||
50 | } | ||
51 | } \ No newline at end of file | ||