eeconfig.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. Copyright 2013 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef EECONFIG_H
  15. #define EECONFIG_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #define EEPROM_CONFIG_VERSION 1
  19. #define EEPROM_HEADER_SIZE 4
  20. #define EEPROM_SIGNATURE (0xFEED - EEPROM_CONFIG_VERSION)
  21. #define EEPROM_SIGNATURE_ADDR (uint16_t *)0
  22. #define EEPROM_ENABLED_FEATURES eeprom_enabled_features
  23. #define EEPROM_ENABLED_FEATURES_ADDR (uint16_t *)2
  24. enum eeprom_optional_features {
  25. eeprom_backlight_option,
  26. eeprom_audio_option,
  27. eeprom_rgblight_option,
  28. eeprom_stenomode_option,
  29. eeprom_free_range_option
  30. };
  31. static const uint16_t eeprom_enabled_features =
  32. #ifdef BACKLIGHT_ENABLE
  33. (1 << eeprom_backlight_option) |
  34. #endif
  35. #ifdef AUDIO_ENABLE
  36. (1 << eeprom_audio_option) |
  37. #endif
  38. #ifdef RGBLIGHT_ENABLE
  39. (1 << eeprom_rgblight_option) |
  40. #endif
  41. #ifdef STENO_ENABLE
  42. (1 << eeprom_stenomode_option) |
  43. #endif
  44. 0;
  45. typedef enum eeprom_features {
  46. eeprom_debug,
  47. eeprom_default_layer,
  48. eeprom_keymap,
  49. eeprom_mousekey_accel,
  50. eeprom_backlight,
  51. eeprom_audio,
  52. eeprom_rgblight,
  53. eeprom_unicodemode,
  54. eeprom_stenomode,
  55. eeprom_free_range
  56. } eeprom_feature_t;
  57. typedef uint8_t eeprom_debug_t;
  58. typedef uint8_t eeprom_default_layer_t;
  59. typedef uint8_t eeprom_keymap_t;
  60. typedef uint8_t eeprom_mousekey_accel_t;
  61. typedef uint8_t eeprom_backlight_t;
  62. typedef uint8_t eeprom_audio_t;
  63. typedef uint32_t eeprom_rgblight_t;
  64. typedef uint8_t eeprom_unicodemode_t;
  65. typedef uint8_t eeprom_stenomode_t;
  66. #define typeof(n) n ## _t
  67. /* eeprom parameteter address */
  68. #define EECONFIG_MAGIC (uint16_t *)0
  69. #define EECONFIG_DEBUG (uint8_t *)2
  70. #define EECONFIG_DEFAULT_LAYER (uint8_t *)3
  71. #define EECONFIG_KEYMAP (uint8_t *)4
  72. #define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
  73. #define EECONFIG_BACKLIGHT (uint8_t *)6
  74. #define EECONFIG_AUDIO (uint8_t *)7
  75. #define EECONFIG_RGBLIGHT (uint32_t *)8
  76. #define EECONFIG_UNICODEMODE (uint8_t *)12
  77. #define EECONFIG_STENOMODE (uint8_t *)13
  78. /* debug bit */
  79. #define EECONFIG_DEBUG_ENABLE (1<<0)
  80. #define EECONFIG_DEBUG_MATRIX (1<<1)
  81. #define EECONFIG_DEBUG_KEYBOARD (1<<2)
  82. #define EECONFIG_DEBUG_MOUSE (1<<3)
  83. /* keyconf bit */
  84. #define EECONFIG_KEYMAP_SWAP_CONTROL_CAPSLOCK (1<<0)
  85. #define EECONFIG_KEYMAP_CAPSLOCK_TO_CONTROL (1<<1)
  86. #define EECONFIG_KEYMAP_SWAP_LALT_LGUI (1<<2)
  87. #define EECONFIG_KEYMAP_SWAP_RALT_RGUI (1<<3)
  88. #define EECONFIG_KEYMAP_NO_GUI (1<<4)
  89. #define EECONFIG_KEYMAP_SWAP_GRAVE_ESC (1<<5)
  90. #define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1<<6)
  91. #define EECONFIG_KEYMAP_NKRO (1<<7)
  92. bool eeconfig_is_enabled(void);
  93. void eeconfig_init(void);
  94. void eeconfig_enable(void);
  95. void eeconfig_disable(void);
  96. uint8_t eeconfig_read_debug(void);
  97. void eeconfig_update_debug(uint8_t val);
  98. uint8_t eeconfig_read_default_layer(void);
  99. void eeconfig_update_default_layer(uint8_t val);
  100. uint8_t eeconfig_read_keymap(void);
  101. void eeconfig_update_keymap(uint8_t val);
  102. #ifdef BACKLIGHT_ENABLE
  103. uint8_t eeconfig_read_backlight(void);
  104. void eeconfig_update_backlight(uint8_t val);
  105. #endif
  106. #ifdef AUDIO_ENABLE
  107. uint8_t eeconfig_read_audio(void);
  108. void eeconfig_update_audio(uint8_t val);
  109. #endif
  110. #endif