start planning eeprom stuff
This commit is contained in:
parent
bd0a888133
commit
4e7ee5b0d5
2 changed files with 99 additions and 5 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
void eeconfig_init(void)
|
||||
{
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_word(EEPROM_SIGNATURE_ADDR, EEPROM_SIGNATURE);
|
||||
eeprom_update_byte(EECONFIG_DEBUG, 0);
|
||||
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
eeprom_update_byte(EECONFIG_KEYMAP, 0);
|
||||
|
@ -24,19 +24,59 @@ void eeconfig_init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
uint8_t eeprom_feature_location(eeprom_feature_t feature) {
|
||||
uint8_t location = EEPROM_HEADER_SIZE;
|
||||
if (feature == eeprom_debug)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_debug));
|
||||
if (feature == eeprom_default_layer)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_default_layer));
|
||||
if (feature == eeprom_keymap)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_keymap));
|
||||
if (feature == eeprom_mousekey_accel)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_mousekey_accel));
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
if (feature == eeprom_backlight)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_backlight));
|
||||
#endif
|
||||
#ifdef AUDIO_ENABLE
|
||||
if (feature == eeprom_audio)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_audio));
|
||||
#endif
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
if (feature == eeprom_rgblight)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_rgblight));
|
||||
#endif
|
||||
if (feature == eeprom_unicodemode)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_unicodemode));
|
||||
#ifdef STENO_ENABLE
|
||||
if (feature == eeprom_stenomode)
|
||||
return location;
|
||||
location += sizeof(typeof(eeprom_stenomode));
|
||||
#endif
|
||||
return location;
|
||||
}
|
||||
|
||||
void eeconfig_enable(void)
|
||||
{
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_word(EEPROM_SIGNATURE_ADDR, EEPROM_SIGNATURE);
|
||||
}
|
||||
|
||||
void eeconfig_disable(void)
|
||||
{
|
||||
eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
|
||||
eeprom_update_word(EEPROM_SIGNATURE_ADDR, 0xFFFF);
|
||||
}
|
||||
|
||||
bool eeconfig_is_enabled(void)
|
||||
{
|
||||
return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
|
||||
return (eeprom_read_word(EEPROM_SIGNATURE_ADDR) == EEPROM_SIGNATURE);
|
||||
}
|
||||
|
||||
uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
|
||||
|
|
|
@ -21,8 +21,62 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define EEPROM_CONFIG_VERSION 1
|
||||
#define EEPROM_HEADER_SIZE 4
|
||||
|
||||
#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED
|
||||
#define EEPROM_SIGNATURE (0xFEED - EEPROM_CONFIG_VERSION)
|
||||
#define EEPROM_SIGNATURE_ADDR (uint16_t *)0
|
||||
|
||||
#define EEPROM_ENABLED_FEATURES eeprom_enabled_features
|
||||
#define EEPROM_ENABLED_FEATURES_ADDR (uint16_t *)2
|
||||
|
||||
enum eeprom_optional_features {
|
||||
eeprom_backlight_option,
|
||||
eeprom_audio_option,
|
||||
eeprom_rgblight_option,
|
||||
eeprom_stenomode_option,
|
||||
eeprom_free_range_option
|
||||
};
|
||||
|
||||
static const uint16_t eeprom_enabled_features =
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
(1 << eeprom_backlight_option) |
|
||||
#endif
|
||||
#ifdef AUDIO_ENABLE
|
||||
(1 << eeprom_audio_option) |
|
||||
#endif
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
(1 << eeprom_rgblight_option) |
|
||||
#endif
|
||||
#ifdef STENO_ENABLE
|
||||
(1 << eeprom_stenomode_option) |
|
||||
#endif
|
||||
0;
|
||||
|
||||
typedef enum eeprom_features {
|
||||
eeprom_debug,
|
||||
eeprom_default_layer,
|
||||
eeprom_keymap,
|
||||
eeprom_mousekey_accel,
|
||||
eeprom_backlight,
|
||||
eeprom_audio,
|
||||
eeprom_rgblight,
|
||||
eeprom_unicodemode,
|
||||
eeprom_stenomode,
|
||||
eeprom_free_range
|
||||
} eeprom_feature_t;
|
||||
|
||||
typedef uint8_t eeprom_debug_t;
|
||||
typedef uint8_t eeprom_default_layer_t;
|
||||
typedef uint8_t eeprom_keymap_t;
|
||||
typedef uint8_t eeprom_mousekey_accel_t;
|
||||
typedef uint8_t eeprom_backlight_t;
|
||||
typedef uint8_t eeprom_audio_t;
|
||||
typedef uint32_t eeprom_rgblight_t;
|
||||
typedef uint8_t eeprom_unicodemode_t;
|
||||
typedef uint8_t eeprom_stenomode_t;
|
||||
|
||||
#define typeof(n) n ## _t
|
||||
|
||||
/* eeprom parameteter address */
|
||||
#define EECONFIG_MAGIC (uint16_t *)0
|
||||
|
|
Loading…
Reference in a new issue