forked from forks/qmk_firmware
Update functions used to write to EEPROM
This commit is contained in:
parent
9828aba2a1
commit
620ac4b260
|
@ -233,7 +233,7 @@ void update_quad_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3, uint8_t l
|
|||
|
||||
void persistant_default_layer_set(uint16_t default_layer)
|
||||
{
|
||||
eeconfig_write_default_layer(default_layer);
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ static void store_link(uint8_t *eeaddr)
|
|||
xprintf("%s(%d)\r\n", s, strlen(s));
|
||||
if (strlen(s) == 12) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
eeprom_write_byte(eeaddr+i, *(s+i));
|
||||
eeprom_update_byte(eeaddr+i, *(s+i));
|
||||
dprintf("%c ", *(s+i));
|
||||
}
|
||||
dprint("\r\n");
|
||||
|
|
|
@ -211,7 +211,7 @@ float goodbye[][2] = SONG(GOODBYE_SOUND);
|
|||
|
||||
|
||||
void persistant_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_write_default_layer(default_layer);
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|||
}
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
keymap_config.nkro = 1;
|
||||
eeconfig_write_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
|
|
|
@ -200,7 +200,7 @@ float goodbye[][2] = SONG(GOODBYE_SOUND);
|
|||
#endif
|
||||
|
||||
void persistant_default_layer_set(uint16_t default_layer) {
|
||||
eeconfig_write_default_layer(default_layer);
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set(default_layer);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,17 +85,17 @@ uint16_t envelope_index = 0;
|
|||
|
||||
void audio_toggle(void) {
|
||||
audio_config.enable ^= 1;
|
||||
eeconfig_write_audio(audio_config.raw);
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void audio_on(void) {
|
||||
audio_config.enable = 1;
|
||||
eeconfig_write_audio(audio_config.raw);
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
void audio_off(void) {
|
||||
audio_config.enable = 0;
|
||||
eeconfig_write_audio(audio_config.raw);
|
||||
eeconfig_update_audio(audio_config.raw);
|
||||
}
|
||||
|
||||
#ifdef VIBRATO_ENABLE
|
||||
|
|
|
@ -245,7 +245,7 @@ static action_t keycode_to_action(uint16_t keycode)
|
|||
keymap_config.swap_lalt_lgui = 0;
|
||||
keymap_config.swap_ralt_rgui = 0;
|
||||
}
|
||||
eeconfig_write_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
break;
|
||||
case 0x5100 ... 0x5FFF: ;
|
||||
// Layer movement shortcuts
|
||||
|
|
|
@ -107,17 +107,17 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1) {
|
|||
uint32_t eeconfig_read_rgblight(void) {
|
||||
return eeprom_read_dword(EECONFIG_RGBLIGHT);
|
||||
}
|
||||
void eeconfig_write_rgblight(uint32_t val) {
|
||||
eeprom_write_dword(EECONFIG_RGBLIGHT, val);
|
||||
void eeconfig_update_rgblight(uint32_t val) {
|
||||
eeprom_update_dword(EECONFIG_RGBLIGHT, val);
|
||||
}
|
||||
void eeconfig_write_rgblight_default(void) {
|
||||
dprintf("eeconfig_write_rgblight_default\n");
|
||||
void eeconfig_update_rgblight_default(void) {
|
||||
dprintf("eeconfig_update_rgblight_default\n");
|
||||
rgblight_config.enable = 1;
|
||||
rgblight_config.mode = 1;
|
||||
rgblight_config.hue = 200;
|
||||
rgblight_config.sat = 204;
|
||||
rgblight_config.val = 204;
|
||||
eeconfig_write_rgblight(rgblight_config.raw);
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
}
|
||||
void eeconfig_debug_rgblight(void) {
|
||||
dprintf("rgblight_config eprom\n");
|
||||
|
@ -136,12 +136,12 @@ void rgblight_init(void) {
|
|||
if (!eeconfig_is_enabled()) {
|
||||
dprintf("rgblight_init eeconfig is not enabled.\n");
|
||||
eeconfig_init();
|
||||
eeconfig_write_rgblight_default();
|
||||
eeconfig_update_rgblight_default();
|
||||
}
|
||||
rgblight_config.raw = eeconfig_read_rgblight();
|
||||
if (!rgblight_config.mode) {
|
||||
dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
|
||||
eeconfig_write_rgblight_default();
|
||||
eeconfig_update_rgblight_default();
|
||||
rgblight_config.raw = eeconfig_read_rgblight();
|
||||
}
|
||||
eeconfig_debug_rgblight(); // display current eeprom values
|
||||
|
@ -189,7 +189,7 @@ void rgblight_mode(uint8_t mode) {
|
|||
} else {
|
||||
rgblight_config.mode = mode;
|
||||
}
|
||||
eeconfig_write_rgblight(rgblight_config.raw);
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
dprintf("rgblight mode: %u\n", rgblight_config.mode);
|
||||
if (rgblight_config.mode == 1) {
|
||||
rgblight_timer_disable();
|
||||
|
@ -206,7 +206,7 @@ void rgblight_mode(uint8_t mode) {
|
|||
|
||||
void rgblight_toggle(void) {
|
||||
rgblight_config.enable ^= 1;
|
||||
eeconfig_write_rgblight(rgblight_config.raw);
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
dprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
|
||||
if (rgblight_config.enable) {
|
||||
rgblight_mode(rgblight_config.mode);
|
||||
|
@ -299,7 +299,7 @@ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val){
|
|||
rgblight_config.hue = hue;
|
||||
rgblight_config.sat = sat;
|
||||
rgblight_config.val = val;
|
||||
eeconfig_write_rgblight(rgblight_config.raw);
|
||||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,8 +66,8 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
|
|||
|
||||
#define EECONFIG_RGBLIGHT (uint8_t *)7
|
||||
uint32_t eeconfig_read_rgblight(void);
|
||||
void eeconfig_write_rgblight(uint32_t val);
|
||||
void eeconfig_write_rgblight_default(void);
|
||||
void eeconfig_update_rgblight(uint32_t val);
|
||||
void eeconfig_update_rgblight_default(void);
|
||||
void eeconfig_debug_rgblight(void);
|
||||
|
||||
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1);
|
||||
|
|
|
@ -5,27 +5,27 @@
|
|||
|
||||
void eeconfig_init(void)
|
||||
{
|
||||
eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_write_byte(EECONFIG_DEBUG, 0);
|
||||
eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
eeprom_write_byte(EECONFIG_KEYMAP, 0);
|
||||
eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_byte(EECONFIG_DEBUG, 0);
|
||||
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, 0);
|
||||
eeprom_update_byte(EECONFIG_KEYMAP, 0);
|
||||
eeprom_update_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
|
||||
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
|
||||
#endif
|
||||
#ifdef AUDIO_ENABLE
|
||||
eeprom_write_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
eeprom_update_byte(EECONFIG_AUDIO, 0xFF); // On by default
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeconfig_enable(void)
|
||||
{
|
||||
eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
|
||||
}
|
||||
|
||||
void eeconfig_disable(void)
|
||||
{
|
||||
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
|
||||
eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
|
||||
}
|
||||
|
||||
bool eeconfig_is_enabled(void)
|
||||
|
@ -34,20 +34,20 @@ bool eeconfig_is_enabled(void)
|
|||
}
|
||||
|
||||
uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
|
||||
void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); }
|
||||
void eeconfig_update_debug(uint8_t val) { eeprom_update_byte(EECONFIG_DEBUG, val); }
|
||||
|
||||
uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
|
||||
void eeconfig_write_default_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); }
|
||||
void eeconfig_update_default_layer(uint8_t val) { eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); }
|
||||
|
||||
uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); }
|
||||
void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); }
|
||||
void eeconfig_update_keymap(uint8_t val) { eeprom_update_byte(EECONFIG_KEYMAP, val); }
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); }
|
||||
void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); }
|
||||
void eeconfig_update_backlight(uint8_t val) { eeprom_update_byte(EECONFIG_BACKLIGHT, val); }
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO); }
|
||||
void eeconfig_write_audio(uint8_t val) { eeprom_write_byte(EECONFIG_AUDIO, val); }
|
||||
void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); }
|
||||
#endif
|
|
@ -37,7 +37,7 @@ void backlight_increase(void)
|
|||
{
|
||||
backlight_config.level++;
|
||||
backlight_config.enable = 1;
|
||||
eeconfig_write_backlight(backlight_config.raw);
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
}
|
||||
dprintf("backlight increase: %u\n", backlight_config.level);
|
||||
backlight_set(backlight_config.level);
|
||||
|
@ -49,7 +49,7 @@ void backlight_decrease(void)
|
|||
{
|
||||
backlight_config.level--;
|
||||
backlight_config.enable = !!backlight_config.level;
|
||||
eeconfig_write_backlight(backlight_config.raw);
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
}
|
||||
dprintf("backlight decrease: %u\n", backlight_config.level);
|
||||
backlight_set(backlight_config.level);
|
||||
|
@ -58,7 +58,7 @@ void backlight_decrease(void)
|
|||
void backlight_toggle(void)
|
||||
{
|
||||
backlight_config.enable ^= 1;
|
||||
eeconfig_write_backlight(backlight_config.raw);
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
dprintf("backlight toggle: %u\n", backlight_config.enable);
|
||||
backlight_set(backlight_config.enable ? backlight_config.level : 0);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ void backlight_step(void)
|
|||
backlight_config.level = 0;
|
||||
}
|
||||
backlight_config.enable = !!backlight_config.level;
|
||||
eeconfig_write_backlight(backlight_config.raw);
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
dprintf("backlight step: %u\n", backlight_config.level);
|
||||
backlight_set(backlight_config.level);
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ void backlight_level(uint8_t level)
|
|||
{
|
||||
backlight_config.level ^= level;
|
||||
backlight_config.enable = !!backlight_config.level;
|
||||
eeconfig_write_backlight(backlight_config.raw);
|
||||
eeconfig_update_backlight(backlight_config.raw);
|
||||
backlight_set(backlight_config.level);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ void bootmagic(void)
|
|||
debug_config.enable = !debug_config.enable;
|
||||
}
|
||||
}
|
||||
eeconfig_write_debug(debug_config.raw);
|
||||
eeconfig_update_debug(debug_config.raw);
|
||||
|
||||
/* keymap config */
|
||||
keymap_config.raw = eeconfig_read_keymap();
|
||||
|
@ -80,7 +80,7 @@ void bootmagic(void)
|
|||
if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) {
|
||||
keymap_config.nkro = !keymap_config.nkro;
|
||||
}
|
||||
eeconfig_write_keymap(keymap_config.raw);
|
||||
eeconfig_update_keymap(keymap_config.raw);
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
keyboard_nkro = keymap_config.nkro;
|
||||
|
@ -97,7 +97,7 @@ void bootmagic(void)
|
|||
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); }
|
||||
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); }
|
||||
if (default_layer) {
|
||||
eeconfig_write_default_layer(default_layer);
|
||||
eeconfig_update_default_layer(default_layer);
|
||||
default_layer_set((uint32_t)default_layer);
|
||||
} else {
|
||||
default_layer = eeconfig_read_default_layer();
|
||||
|
|
|
@ -60,22 +60,22 @@ void eeconfig_enable(void);
|
|||
void eeconfig_disable(void);
|
||||
|
||||
uint8_t eeconfig_read_debug(void);
|
||||
void eeconfig_write_debug(uint8_t val);
|
||||
void eeconfig_update_debug(uint8_t val);
|
||||
|
||||
uint8_t eeconfig_read_default_layer(void);
|
||||
void eeconfig_write_default_layer(uint8_t val);
|
||||
void eeconfig_update_default_layer(uint8_t val);
|
||||
|
||||
uint8_t eeconfig_read_keymap(void);
|
||||
void eeconfig_write_keymap(uint8_t val);
|
||||
void eeconfig_update_keymap(uint8_t val);
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
uint8_t eeconfig_read_backlight(void);
|
||||
void eeconfig_write_backlight(uint8_t val);
|
||||
void eeconfig_update_backlight(uint8_t val);
|
||||
#endif
|
||||
|
||||
#ifdef AUDIO_ENABLE
|
||||
uint8_t eeconfig_read_audio(void);
|
||||
void eeconfig_write_audio(uint8_t val);
|
||||
void eeconfig_update_audio(uint8_t val);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -327,7 +327,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
|||
else
|
||||
{
|
||||
/* Write the next EEPROM byte from the endpoint */
|
||||
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||
eeprom_update_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||
|
||||
/* Increment the address counter after use */
|
||||
CurrAddress += 2;
|
||||
|
@ -581,7 +581,7 @@ static void CDC_Task(void)
|
|||
else if (Command == AVR109_COMMAND_WriteEEPROM)
|
||||
{
|
||||
/* Read the byte from the endpoint and write it to the EEPROM */
|
||||
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||
eeprom_update_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||
|
||||
/* Increment the address after use */
|
||||
CurrAddress += 2;
|
||||
|
|
|
@ -370,7 +370,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
}
|
||||
|
||||
/* Read the byte from the USB interface and write to to the EEPROM */
|
||||
eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_8());
|
||||
eeprom_update_byte((uint8_t*)StartAddr, Endpoint_Read_8());
|
||||
|
||||
/* Adjust counters */
|
||||
StartAddr++;
|
||||
|
|
Loading…
Reference in a new issue