diff options
author | Nick Brassel <[email protected]> | 2025-03-21 23:38:34 +1100 |
---|---|---|
committer | GitHub <[email protected]> | 2025-03-21 23:38:34 +1100 |
commit | 2b00b846dce1d1267dfdb2a3c2972a367cc0dd44 (patch) | |
tree | 6d801a8d83c58ee646b789bfa9ab912857ee7d8c /quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h | |
parent | c9d62ddc78e879053241202b288d0129073b07dc (diff) | |
download | qmk_firmware-2b00b846dce1d1267dfdb2a3c2972a367cc0dd44.tar.gz qmk_firmware-2b00b846dce1d1267dfdb2a3c2972a367cc0dd44.zip |
Non-volatile memory data repository pattern (#24356)
* First batch of eeconfig conversions.
* Offset and length for datablocks.
* `via`, `dynamic_keymap`.
* Fix filename.
* Commentary.
* wilba leds
* satisfaction75
* satisfaction75
* more keyboard whack-a-mole
* satisfaction75
* omnikeyish
* more whack-a-mole
* `generic_features.mk` to automatically pick up nvm repositories
* thievery
* deferred variable resolve
* whitespace
* convert api to structs/unions
* convert api to structs/unions
* convert api to structs/unions
* fixups
* code-side docs
* code size fix
* rollback
* nvm_xxxxx_erase
* Updated location of eeconfig magic numbers so non-EEPROM nvm drivers can use them too.
* Fixup build.
* Fixup compilation error with encoders.
* Build fixes.
* Add `via_ci` keymap to onekey to exercise VIA bindings (and thus dynamic keymap et.al.), fixup compilation errors based on preprocessor+sizeof.
* Build failure rectification.
Diffstat (limited to 'quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h')
-rw-r--r-- | quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h new file mode 100644 index 0000000000..6efbf9480b --- /dev/null +++ b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h @@ -0,0 +1,59 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include <stdint.h> +#include <stddef.h> // offsetof +#include "eeconfig.h" +#include "util.h" + +// Dummy struct only used to calculate offsets +typedef struct PACKED { + uint16_t magic; + uint8_t debug; + uint8_t default_layer; + uint16_t keymap; + uint8_t backlight; + uint8_t audio; + uint32_t rgblight; + uint8_t unicode; + uint8_t steno; + uint8_t handedness; + uint32_t keyboard; + uint32_t user; + union { // Mutually exclusive + uint32_t led_matrix; + uint64_t rgb_matrix; + }; + uint32_t haptic; + uint8_t rgblight_ext; +} eeprom_core_t; + +/* EEPROM parameter address */ +#define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic)) +#define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug)) +#define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer)) +#define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap)) +#define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight)) +#define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio)) +#define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight)) +#define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode)) +#define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno)) +#define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness)) +#define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard)) +#define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user)) +#define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix)) +#define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix)) +#define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic)) +#define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext)) + +// Size of EEPROM being used for core data storage +#define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) + +#define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE)) +#define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE))) + +// Size of EEPROM being used, other code can refer to this for available EEPROM +#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)) + +_Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); |