logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

nvm_eeprom_eeconfig_internal.h (2581B)


  1. // Copyright 2024 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <stdint.h>
  5. #include <stddef.h> // offsetof
  6. #include "compiler_support.h"
  7. #include "eeconfig.h"
  8. #include "util.h"
  9. // Dummy struct only used to calculate offsets
  10. typedef struct PACKED {
  11. uint16_t magic;
  12. uint8_t debug;
  13. uint8_t default_layer;
  14. uint16_t keymap;
  15. uint8_t backlight;
  16. uint8_t audio;
  17. uint32_t rgblight;
  18. uint8_t unicode;
  19. uint8_t steno;
  20. uint8_t handedness;
  21. uint32_t keyboard;
  22. uint32_t user;
  23. union { // Mutually exclusive
  24. uint32_t led_matrix;
  25. uint64_t rgb_matrix;
  26. };
  27. uint32_t haptic;
  28. uint8_t rgblight_ext;
  29. uint8_t connection;
  30. } eeprom_core_t;
  31. /* EEPROM parameter address */
  32. #define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic))
  33. #define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug))
  34. #define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer))
  35. #define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap))
  36. #define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight))
  37. #define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio))
  38. #define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight))
  39. #define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode))
  40. #define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno))
  41. #define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness))
  42. #define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard))
  43. #define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user))
  44. #define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix))
  45. #define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix))
  46. #define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic))
  47. #define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext))
  48. #define EECONFIG_CONNECTION (uint8_t *)(offsetof(eeprom_core_t, connection))
  49. // Size of EEPROM being used for core data storage
  50. #define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t))
  51. #define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE))
  52. #define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE)))
  53. // Size of EEPROM being used, other code can refer to this for available EEPROM
  54. #define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE))
  55. STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect");