mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-28 14:10:13 +00:00
Extend eeconfig kb/user datablock API (#19094)
This commit is contained in:
parent
81a6407dca
commit
57ac917b43
@ -71,15 +71,11 @@ void eeconfig_init_quantum(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (EECONFIG_KB_DATA_SIZE) > 0
|
#if (EECONFIG_KB_DATA_SIZE) > 0
|
||||||
eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION));
|
eeconfig_init_kb_datablock();
|
||||||
uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0};
|
|
||||||
eeprom_update_block(EECONFIG_KB_DATABLOCK, dummy_kb, (EECONFIG_KB_DATA_SIZE));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (EECONFIG_USER_DATA_SIZE) > 0
|
#if (EECONFIG_USER_DATA_SIZE) > 0
|
||||||
eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION));
|
eeconfig_init_user_datablock();
|
||||||
uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0};
|
|
||||||
eeprom_update_block(EECONFIG_USER_DATABLOCK, dummy_user, (EECONFIG_USER_DATA_SIZE));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VIA_ENABLE)
|
#if defined(VIA_ENABLE)
|
||||||
@ -273,12 +269,19 @@ void eeconfig_update_handedness(bool val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if (EECONFIG_KB_DATA_SIZE) > 0
|
#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
|
/** \brief eeconfig read keyboard data block
|
||||||
*
|
*
|
||||||
* FIXME: needs doc
|
* FIXME: needs doc
|
||||||
*/
|
*/
|
||||||
void eeconfig_read_kb_datablock(void *data) {
|
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));
|
eeprom_read_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE));
|
||||||
} else {
|
} else {
|
||||||
memset(data, 0, (EECONFIG_KB_DATA_SIZE));
|
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_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION));
|
||||||
eeprom_update_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE));
|
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
|
#endif // (EECONFIG_KB_DATA_SIZE) > 0
|
||||||
|
|
||||||
#if (EECONFIG_USER_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
|
/** \brief eeconfig read user data block
|
||||||
*
|
*
|
||||||
* FIXME: needs doc
|
* FIXME: needs doc
|
||||||
*/
|
*/
|
||||||
void eeconfig_read_user_datablock(void *data) {
|
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));
|
eeprom_read_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE));
|
||||||
} else {
|
} else {
|
||||||
memset(data, 0, (EECONFIG_USER_DATA_SIZE));
|
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_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION));
|
||||||
eeprom_update_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE));
|
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
|
#endif // (EECONFIG_USER_DATA_SIZE) > 0
|
||||||
|
@ -134,13 +134,17 @@ bool eeconfig_read_handedness(void);
|
|||||||
void eeconfig_update_handedness(bool val);
|
void eeconfig_update_handedness(bool val);
|
||||||
|
|
||||||
#if (EECONFIG_KB_DATA_SIZE) > 0
|
#if (EECONFIG_KB_DATA_SIZE) > 0
|
||||||
|
bool eeconfig_is_kb_datablock_valid(void);
|
||||||
void eeconfig_read_kb_datablock(void *data);
|
void eeconfig_read_kb_datablock(void *data);
|
||||||
void eeconfig_update_kb_datablock(const void *data);
|
void eeconfig_update_kb_datablock(const void *data);
|
||||||
|
void eeconfig_init_kb_datablock(void);
|
||||||
#endif // (EECONFIG_KB_DATA_SIZE) > 0
|
#endif // (EECONFIG_KB_DATA_SIZE) > 0
|
||||||
|
|
||||||
#if (EECONFIG_USER_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_read_user_datablock(void *data);
|
||||||
void eeconfig_update_user_datablock(const void *data);
|
void eeconfig_update_user_datablock(const void *data);
|
||||||
|
void eeconfig_init_user_datablock(void);
|
||||||
#endif // (EECONFIG_USER_DATA_SIZE) > 0
|
#endif // (EECONFIG_USER_DATA_SIZE) > 0
|
||||||
|
|
||||||
// Any "checked" debounce variant used requires implementation of:
|
// Any "checked" debounce variant used requires implementation of:
|
||||||
|
Loading…
Reference in New Issue
Block a user