diff options
| author | Joel Challis <git@zvecr.com> | 2024-03-14 10:45:03 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-14 21:45:03 +1100 |
| commit | 4bbfecae90e994b4a7d9bf5db06a995fb05d6ab2 (patch) | |
| tree | 51d3ca05791953a67c972841a6605e8cca19c481 /quantum | |
| parent | 6720e9c58c3a239ff0de4be1ff2ad075a0b2c248 (diff) | |
Infer eeconfig identifiers (#22135)
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/eeconfig.c | 6 | ||||
| -rw-r--r-- | quantum/eeconfig.h | 64 |
2 files changed, 45 insertions, 25 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index 2d2180b4b4..40690d6a97 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c | |||
| @@ -19,6 +19,8 @@ void via_eeprom_set_valid(bool valid); | |||
| 19 | void eeconfig_init_via(void); | 19 | void eeconfig_init_via(void); |
| 20 | #endif | 20 | #endif |
| 21 | 21 | ||
| 22 | _Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); | ||
| 23 | |||
| 22 | /** \brief eeconfig enable | 24 | /** \brief eeconfig enable |
| 23 | * | 25 | * |
| 24 | * FIXME: needs doc | 26 | * FIXME: needs doc |
| @@ -57,11 +59,9 @@ void eeconfig_init_quantum(void) { | |||
| 57 | eeprom_update_byte(EECONFIG_AUDIO, 0); | 59 | eeprom_update_byte(EECONFIG_AUDIO, 0); |
| 58 | eeprom_update_dword(EECONFIG_RGBLIGHT, 0); | 60 | eeprom_update_dword(EECONFIG_RGBLIGHT, 0); |
| 59 | eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0); | 61 | eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0); |
| 60 | eeprom_update_byte(EECONFIG_UNUSED, 0); | ||
| 61 | eeprom_update_byte(EECONFIG_UNICODEMODE, 0); | 62 | eeprom_update_byte(EECONFIG_UNICODEMODE, 0); |
| 62 | eeprom_update_byte(EECONFIG_STENOMODE, 0); | 63 | eeprom_update_byte(EECONFIG_STENOMODE, 0); |
| 63 | uint64_t dummy = 0; | 64 | eeprom_write_qword(EECONFIG_RGB_MATRIX, 0); |
| 64 | eeprom_update_block(&dummy, EECONFIG_RGB_MATRIX, sizeof(uint64_t)); | ||
| 65 | eeprom_update_dword(EECONFIG_HAPTIC, 0); | 65 | eeprom_update_dword(EECONFIG_HAPTIC, 0); |
| 66 | #if defined(HAPTIC_ENABLE) | 66 | #if defined(HAPTIC_ENABLE) |
| 67 | haptic_reset(); | 67 | haptic_reset(); |
diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index d7cce166bd..fa0dd799d1 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h | |||
| @@ -19,37 +19,57 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | 19 | ||
| 20 | #include <stdint.h> | 20 | #include <stdint.h> |
| 21 | #include <stdbool.h> | 21 | #include <stdbool.h> |
| 22 | #include <stddef.h> // offsetof | ||
| 22 | #include "eeprom.h" | 23 | #include "eeprom.h" |
| 24 | #include "util.h" | ||
| 23 | 25 | ||
| 24 | #ifndef EECONFIG_MAGIC_NUMBER | 26 | #ifndef EECONFIG_MAGIC_NUMBER |
| 25 | # define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE6 // When changing, decrement this value to avoid future re-init issues | 27 | # define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE5 // When changing, decrement this value to avoid future re-init issues |
| 26 | #endif | 28 | #endif |
| 27 | #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF | 29 | #define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF |
| 28 | 30 | ||
| 31 | // Dummy struct only used to calculate offsets | ||
| 32 | typedef struct PACKED { | ||
| 33 | uint16_t magic; | ||
| 34 | uint8_t debug; | ||
| 35 | uint8_t default_layer; | ||
| 36 | uint16_t keymap; | ||
| 37 | uint8_t backlight; | ||
| 38 | uint8_t audio; | ||
| 39 | uint32_t rgblight; | ||
| 40 | uint8_t unicode; | ||
| 41 | uint8_t steno; | ||
| 42 | uint8_t handedness; | ||
| 43 | uint32_t keyboard; | ||
| 44 | uint32_t user; | ||
| 45 | union { // Mutually exclusive | ||
| 46 | uint32_t led_matrix; | ||
| 47 | uint64_t rgb_matrix; | ||
| 48 | }; | ||
| 49 | uint32_t haptic; | ||
| 50 | uint8_t rgblight_ext; | ||
| 51 | } eeprom_core_t; | ||
| 52 | |||
| 29 | /* EEPROM parameter address */ | 53 | /* EEPROM parameter address */ |
| 30 | #define EECONFIG_MAGIC (uint16_t *)0 | 54 | #define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic)) |
| 31 | #define EECONFIG_DEBUG (uint8_t *)2 | 55 | #define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug)) |
| 32 | #define EECONFIG_DEFAULT_LAYER (uint8_t *)3 | 56 | #define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer)) |
| 33 | #define EECONFIG_KEYMAP (uint16_t *)4 | 57 | #define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap)) |
| 34 | #define EECONFIG_BACKLIGHT (uint8_t *)6 | 58 | #define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight)) |
| 35 | #define EECONFIG_AUDIO (uint8_t *)7 | 59 | #define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio)) |
| 36 | #define EECONFIG_RGBLIGHT (uint32_t *)8 | 60 | #define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight)) |
| 37 | #define EECONFIG_UNICODEMODE (uint8_t *)12 | 61 | #define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode)) |
| 38 | #define EECONFIG_STENOMODE (uint8_t *)13 | 62 | #define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno)) |
| 39 | // EEHANDS for two handed boards | 63 | #define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness)) |
| 40 | #define EECONFIG_HANDEDNESS (uint8_t *)14 | 64 | #define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard)) |
| 41 | #define EECONFIG_KEYBOARD (uint32_t *)15 | 65 | #define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user)) |
| 42 | #define EECONFIG_USER (uint32_t *)19 | 66 | #define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix)) |
| 43 | #define EECONFIG_UNUSED (uint8_t *)23 | 67 | #define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix)) |
| 44 | // Mutually exclusive | 68 | #define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic)) |
| 45 | #define EECONFIG_LED_MATRIX (uint32_t *)24 | 69 | #define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext)) |
| 46 | #define EECONFIG_RGB_MATRIX (uint64_t *)24 | ||
| 47 | |||
| 48 | #define EECONFIG_HAPTIC (uint32_t *)32 | ||
| 49 | #define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)36 | ||
| 50 | 70 | ||
| 51 | // Size of EEPROM being used for core data storage | 71 | // Size of EEPROM being used for core data storage |
| 52 | #define EECONFIG_BASE_SIZE 37 | 72 | #define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) |
| 53 | 73 | ||
| 54 | // Size of EEPROM dedicated to keyboard- and user-specific data | 74 | // Size of EEPROM dedicated to keyboard- and user-specific data |
| 55 | #ifndef EECONFIG_KB_DATA_SIZE | 75 | #ifndef EECONFIG_KB_DATA_SIZE |
