aboutsummaryrefslogtreecommitdiff
path: root/quantum/eeconfig.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2021-08-20 21:02:53 -0700
committerGitHub <noreply@github.com>2021-08-20 21:02:53 -0700
commita80d7891472335ec297082daecc6fbf90042c38c (patch)
tree04d34e9dd3658bf471ca9b11db3fa1095b4aa2c0 /quantum/eeconfig.c
parentafd3bcbf45a9b7de097d7666ced2c674192949e5 (diff)
downloadqmk_firmware-a80d7891472335ec297082daecc6fbf90042c38c.tar.gz
qmk_firmware-a80d7891472335ec297082daecc6fbf90042c38c.zip
Fix issues with VIA EEPROM init and bring in line with eeconfig functionality (#13243)
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'quantum/eeconfig.c')
-rw-r--r--quantum/eeconfig.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index ffa56ab56..92f0ac443 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -17,6 +17,12 @@
17# include "haptic.h" 17# include "haptic.h"
18#endif 18#endif
19 19
20#if defined(VIA_ENABLE)
21bool via_eeprom_is_valid(void);
22void via_eeprom_set_valid(bool valid);
23void eeconfig_init_via(void);
24#endif
25
20/** \brief eeconfig enable 26/** \brief eeconfig enable
21 * 27 *
22 * FIXME: needs doc 28 * FIXME: needs doc
@@ -77,6 +83,13 @@ void eeconfig_init_quantum(void) {
77 // when a haptic-enabled firmware is loaded onto the keyboard. 83 // when a haptic-enabled firmware is loaded onto the keyboard.
78 eeprom_update_dword(EECONFIG_HAPTIC, 0); 84 eeprom_update_dword(EECONFIG_HAPTIC, 0);
79#endif 85#endif
86#if defined(VIA_ENABLE)
87 // Invalidate VIA eeprom config, and then reset.
88 // Just in case if power is lost mid init, this makes sure that it pets
89 // properly re-initialized.
90 via_eeprom_set_valid(false);
91 eeconfig_init_via();
92#endif
80 93
81 eeconfig_init_kb(); 94 eeconfig_init_kb();
82} 95}
@@ -111,13 +124,29 @@ void eeconfig_disable(void) {
111 * 124 *
112 * FIXME: needs doc 125 * FIXME: needs doc
113 */ 126 */
114bool eeconfig_is_enabled(void) { return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); } 127bool eeconfig_is_enabled(void) {
128 bool is_eeprom_enabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
129#ifdef VIA_ENABLE
130 if (is_eeprom_enabled) {
131 is_eeprom_enabled = via_eeprom_is_valid();
132 }
133#endif
134 return is_eeprom_enabled;
135}
115 136
116/** \brief eeconfig is disabled 137/** \brief eeconfig is disabled
117 * 138 *
118 * FIXME: needs doc 139 * FIXME: needs doc
119 */ 140 */
120bool eeconfig_is_disabled(void) { return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF); } 141bool eeconfig_is_disabled(void) {
142 bool is_eeprom_disabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF);
143#ifdef VIA_ENABLE
144 if (!is_eeprom_disabled) {
145 is_eeprom_disabled = !via_eeprom_is_valid();
146 }
147#endif
148 return is_eeprom_disabled;
149}
121 150
122/** \brief eeconfig read debug 151/** \brief eeconfig read debug
123 * 152 *