summaryrefslogtreecommitdiff
path: root/quantum/via.c
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-08-29 08:20:25 +1000
committerNick Brassel <nick@tzarc.org>2021-08-29 08:20:25 +1000
commitf061ca497464fe85284906fb163a33eaee7a91ef (patch)
tree33ef1bfb529aed382e8526c607c4e18717f92571 /quantum/via.c
parentff65185dec6f97be1eb49f17cea526a0d0bbf3d6 (diff)
parent4bad375d7c09d949a9dcdd4feba147c9c7a67ec6 (diff)
downloadqmk_firmware-f061ca497464fe85284906fb163a33eaee7a91ef.tar.gz
qmk_firmware-f061ca497464fe85284906fb163a33eaee7a91ef.zip
Breaking changes develop merge to master, 2021Q3 edition. (#14196)
Diffstat (limited to 'quantum/via.c')
-rw-r--r--quantum/via.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/quantum/via.c b/quantum/via.c
index c89b663b9b..1b2dbcf08d 100644
--- a/quantum/via.c
+++ b/quantum/via.c
@@ -83,16 +83,6 @@ void via_eeprom_set_valid(bool valid) {
eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2, valid ? magic2 : 0xFF);
}
-// Flag QMK and VIA/keyboard level EEPROM as invalid.
-// Used in bootmagic_lite() and VIA command handler.
-// Keyboard level code should not need to call this.
-void via_eeprom_reset(void) {
- // Set the VIA specific EEPROM state as invalid.
- via_eeprom_set_valid(false);
- // Set the TMK/QMK EEPROM state as invalid.
- eeconfig_disable();
-}
-
// Override this at the keyboard code level to check
// VIA's EEPROM valid state and reset to defaults as needed.
// Used by keyboards that store their own state in EEPROM,
@@ -109,19 +99,24 @@ void via_init(void) {
// If the EEPROM has the magic, the data is good.
// OK to load from EEPROM.
- if (via_eeprom_is_valid()) {
- } else {
- // This resets the layout options
- via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
- // This resets the keymaps in EEPROM to what is in flash.
- dynamic_keymap_reset();
- // This resets the macros in EEPROM to nothing.
- dynamic_keymap_macro_reset();
- // Save the magic number last, in case saving was interrupted
- via_eeprom_set_valid(true);
+ if (!via_eeprom_is_valid()) {
+ eeconfig_init_via();
}
}
+void eeconfig_init_via(void) {
+ // set the magic number to false, in case this gets interrupted
+ via_eeprom_set_valid(false);
+ // This resets the layout options
+ via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
+ // This resets the keymaps in EEPROM to what is in flash.
+ dynamic_keymap_reset();
+ // This resets the macros in EEPROM to nothing.
+ dynamic_keymap_macro_reset();
+ // Save the magic number last, in case saving was interrupted
+ via_eeprom_set_valid(true);
+}
+
// This is generalized so the layout options EEPROM usage can be
// variable, between 1 and 4 bytes.
uint32_t via_get_layout_options(void) {
@@ -329,6 +324,13 @@ void raw_hid_receive(uint8_t *data, uint8_t length) {
#endif
break;
}
+#ifdef VIA_EEPROM_ALLOW_RESET
+ case id_eeprom_reset: {
+ via_eeprom_set_valid(false);
+ eeconfig_init_via();
+ break;
+ }
+#endif
case id_dynamic_keymap_macro_get_count: {
command_data[0] = dynamic_keymap_macro_get_count();
break;