summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/eeconfig.c42
-rw-r--r--quantum/eeconfig.h4
2 files changed, 38 insertions, 8 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index 3b4d690e42..21bcce2654 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -71,15 +71,11 @@ void eeconfig_init_quantum(void) {
#endif
#if (EECONFIG_KB_DATA_SIZE) > 0
- eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION));
- uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0};
- eeprom_update_block(EECONFIG_KB_DATABLOCK, dummy_kb, (EECONFIG_KB_DATA_SIZE));
+ eeconfig_init_kb_datablock();
#endif
#if (EECONFIG_USER_DATA_SIZE) > 0
- eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION));
- uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0};
- eeprom_update_block(EECONFIG_USER_DATABLOCK, dummy_user, (EECONFIG_USER_DATA_SIZE));
+ eeconfig_init_user_datablock();
#endif
#if defined(VIA_ENABLE)
@@ -273,12 +269,19 @@ void eeconfig_update_handedness(bool val) {
}
#if (EECONFIG_KB_DATA_SIZE) > 0
+/** \brief eeconfig assert keyboard data block version
+ *
+ * FIXME: needs doc
+ */
+bool eeconfig_is_kb_datablock_valid(void) {
+ return eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION);
+}
/** \brief eeconfig read keyboard data block
*
* FIXME: needs doc
*/
void eeconfig_read_kb_datablock(void *data) {
- if (eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION)) {
+ if (eeconfig_is_kb_datablock_valid()) {
eeprom_read_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE));
} else {
memset(data, 0, (EECONFIG_KB_DATA_SIZE));
@@ -292,15 +295,30 @@ void eeconfig_update_kb_datablock(const void *data) {
eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION));
eeprom_update_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE));
}
+/** \brief eeconfig init keyboard data block
+ *
+ * FIXME: needs doc
+ */
+__attribute__((weak)) void eeconfig_init_kb_datablock(void) {
+ uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0};
+ eeconfig_update_kb_datablock(dummy_kb);
+}
#endif // (EECONFIG_KB_DATA_SIZE) > 0
#if (EECONFIG_USER_DATA_SIZE) > 0
+/** \brief eeconfig assert user data block version
+ *
+ * FIXME: needs doc
+ */
+bool eeconfig_is_user_datablock_valid(void) {
+ return eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION);
+}
/** \brief eeconfig read user data block
*
* FIXME: needs doc
*/
void eeconfig_read_user_datablock(void *data) {
- if (eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION)) {
+ if (eeconfig_is_user_datablock_valid()) {
eeprom_read_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE));
} else {
memset(data, 0, (EECONFIG_USER_DATA_SIZE));
@@ -314,4 +332,12 @@ void eeconfig_update_user_datablock(const void *data) {
eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION));
eeprom_update_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE));
}
+/** \brief eeconfig init user data block
+ *
+ * FIXME: needs doc
+ */
+__attribute__((weak)) void eeconfig_init_user_datablock(void) {
+ uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0};
+ eeconfig_update_user_datablock(dummy_user);
+}
#endif // (EECONFIG_USER_DATA_SIZE) > 0
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h
index 9fc563d09c..ee8e9add8b 100644
--- a/quantum/eeconfig.h
+++ b/quantum/eeconfig.h
@@ -134,13 +134,17 @@ bool eeconfig_read_handedness(void);
void eeconfig_update_handedness(bool val);
#if (EECONFIG_KB_DATA_SIZE) > 0
+bool eeconfig_is_kb_datablock_valid(void);
void eeconfig_read_kb_datablock(void *data);
void eeconfig_update_kb_datablock(const void *data);
+void eeconfig_init_kb_datablock(void);
#endif // (EECONFIG_KB_DATA_SIZE) > 0
#if (EECONFIG_USER_DATA_SIZE) > 0
+bool eeconfig_is_user_datablock_valid(void);
void eeconfig_read_user_datablock(void *data);
void eeconfig_update_user_datablock(const void *data);
+void eeconfig_init_user_datablock(void);
#endif // (EECONFIG_USER_DATA_SIZE) > 0
// Any "checked" debounce variant used requires implementation of: