diff options
Diffstat (limited to 'quantum/nvm')
-rw-r--r-- | quantum/nvm/eeprom/nvm_dynamic_keymap.c | 7 | ||||
-rw-r--r-- | quantum/nvm/eeprom/nvm_eeconfig.c | 13 | ||||
-rw-r--r-- | quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h | 6 | ||||
-rw-r--r-- | quantum/nvm/nvm_eeconfig.h | 6 |
4 files changed, 28 insertions, 4 deletions
diff --git a/quantum/nvm/eeprom/nvm_dynamic_keymap.c b/quantum/nvm/eeprom/nvm_dynamic_keymap.c index 5f514acc1a..5ff49795b2 100644 --- a/quantum/nvm/eeprom/nvm_dynamic_keymap.c +++ b/quantum/nvm/eeprom/nvm_dynamic_keymap.c @@ -1,6 +1,7 @@ // Copyright 2024 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later +#include "compiler_support.h" #include "keycodes.h" #include "eeprom.h" #include "dynamic_keymap.h" @@ -25,10 +26,10 @@ # define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1) #endif -_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver"); +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver"); // Due to usage of uint16_t check for max 65535 -_Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536"); +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536"); // If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, #ifndef DYNAMIC_KEYMAP_EEPROM_ADDR @@ -56,7 +57,7 @@ _Static_assert(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_M // The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it, // or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has // more than the default. -_Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); +STATIC_ASSERT((int64_t)(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (int64_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); #ifndef TOTAL_EEPROM_BYTE_COUNT # error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps. diff --git a/quantum/nvm/eeprom/nvm_eeconfig.c b/quantum/nvm/eeprom/nvm_eeconfig.c index d6c388f3bc..d9495d2753 100644 --- a/quantum/nvm/eeprom/nvm_eeconfig.c +++ b/quantum/nvm/eeprom/nvm_eeconfig.c @@ -41,6 +41,10 @@ # include "haptic.h" #endif +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif + void nvm_eeconfig_erase(void) { #ifdef EEPROM_DRIVER eeprom_driver_format(false); @@ -196,6 +200,15 @@ void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config) { } #endif // HAPTIC_ENABLE +#ifdef CONNECTION_ENABLE +void nvm_eeconfig_read_connection(connection_config_t *config) { + config->raw = eeprom_read_byte(EECONFIG_CONNECTION); +} +void nvm_eeconfig_update_connection(const connection_config_t *config) { + eeprom_update_byte(EECONFIG_CONNECTION, config->raw); +} +#endif // CONNECTION_ENABLE + bool nvm_eeconfig_read_handedness(void) { return !!eeprom_read_byte(EECONFIG_HANDEDNESS); } diff --git a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h index 6efbf9480b..78b8190eaf 100644 --- a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h +++ b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h @@ -4,6 +4,8 @@ #include <stdint.h> #include <stddef.h> // offsetof + +#include "compiler_support.h" #include "eeconfig.h" #include "util.h" @@ -27,6 +29,7 @@ typedef struct PACKED { }; uint32_t haptic; uint8_t rgblight_ext; + uint8_t connection; } eeprom_core_t; /* EEPROM parameter address */ @@ -46,6 +49,7 @@ typedef struct PACKED { #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)) +#define EECONFIG_CONNECTION (uint8_t *)(offsetof(eeprom_core_t, connection)) // Size of EEPROM being used for core data storage #define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) @@ -56,4 +60,4 @@ typedef struct PACKED { // 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"); +STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); diff --git a/quantum/nvm/nvm_eeconfig.h b/quantum/nvm/nvm_eeconfig.h index 131f61d534..40827361ca 100644 --- a/quantum/nvm/nvm_eeconfig.h +++ b/quantum/nvm/nvm_eeconfig.h @@ -87,6 +87,12 @@ void nvm_eeconfig_read_haptic(haptic_config_t *haptic_c void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config); #endif // HAPTIC_ENABLE +#ifdef CONNECTION_ENABLE +typedef union connection_config_t connection_config_t; +void nvm_eeconfig_read_connection(connection_config_t *config); +void nvm_eeconfig_update_connection(const connection_config_t *config); +#endif // CONNECTION_ENABLE + bool nvm_eeconfig_read_handedness(void); void nvm_eeconfig_update_handedness(bool val); |