diff options
Diffstat (limited to 'tmk_core/common/avr/eeconfig.c')
-rw-r--r-- | tmk_core/common/avr/eeconfig.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tmk_core/common/avr/eeconfig.c b/tmk_core/common/avr/eeconfig.c new file mode 100644 index 000000000..5bd47dc6a --- /dev/null +++ b/tmk_core/common/avr/eeconfig.c | |||
@@ -0,0 +1,45 @@ | |||
1 | #include <stdint.h> | ||
2 | #include <stdbool.h> | ||
3 | #include <avr/eeprom.h> | ||
4 | #include "eeconfig.h" | ||
5 | |||
6 | void eeconfig_init(void) | ||
7 | { | ||
8 | eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); | ||
9 | eeprom_write_byte(EECONFIG_DEBUG, 0); | ||
10 | eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); | ||
11 | eeprom_write_byte(EECONFIG_KEYMAP, 0); | ||
12 | eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); | ||
13 | #ifdef BACKLIGHT_ENABLE | ||
14 | eeprom_write_byte(EECONFIG_BACKLIGHT, 0); | ||
15 | #endif | ||
16 | } | ||
17 | |||
18 | void eeconfig_enable(void) | ||
19 | { | ||
20 | eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); | ||
21 | } | ||
22 | |||
23 | void eeconfig_disable(void) | ||
24 | { | ||
25 | eeprom_write_word(EECONFIG_MAGIC, 0xFFFF); | ||
26 | } | ||
27 | |||
28 | bool eeconfig_is_enabled(void) | ||
29 | { | ||
30 | return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); | ||
31 | } | ||
32 | |||
33 | uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } | ||
34 | void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); } | ||
35 | |||
36 | uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } | ||
37 | void eeconfig_write_default_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } | ||
38 | |||
39 | uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); } | ||
40 | void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); } | ||
41 | |||
42 | #ifdef BACKLIGHT_ENABLE | ||
43 | uint8_t eeconfig_read_backlight(void) { return eeprom_read_byte(EECONFIG_BACKLIGHT); } | ||
44 | void eeconfig_write_backlight(uint8_t val) { eeprom_write_byte(EECONFIG_BACKLIGHT, val); } | ||
45 | #endif | ||