diff options
| author | tmk <hasu@tmk-kbd.com> | 2015-04-10 01:32:04 +0900 |
|---|---|---|
| committer | tmk <hasu@tmk-kbd.com> | 2015-04-10 01:32:04 +0900 |
| commit | 1a02ebcc612e9a9c0d87e02295c7258de3a70ccc (patch) | |
| tree | e517f3c70bb2d542797e57d13e9023c84af230fb /tmk_core/common/avr/eeconfig.c | |
| parent | 6746e37088ce8ba03529c1226bd216705edb2b1f (diff) | |
| parent | a074364c3731d66b56d988c8a6c960a83ea0e0a1 (diff) | |
| download | qmk_firmware-1a02ebcc612e9a9c0d87e02295c7258de3a70ccc.tar.gz qmk_firmware-1a02ebcc612e9a9c0d87e02295c7258de3a70ccc.zip | |
Merge commit 'a074364c3731d66b56d988c8a6c960a83ea0e0a1' as 'tmk_core'
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 | ||
