]> git.donarmstrong.com Git - qmk_firmware.git/blob - common/eeconfig.c
Use dprint and dprintf for debug
[qmk_firmware.git] / common / eeconfig.c
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 }
14
15 void eeconfig_enable(void)
16 {
17     eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
18 }
19
20 void eeconfig_disable(void)
21 {
22     eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
23 }
24
25 bool eeconfig_is_enabled(void)
26 {
27     return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
28 }
29
30 uint8_t eeconfig_read_debug(void)      { return eeprom_read_byte(EECONFIG_DEBUG); }
31 void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); }
32
33 uint8_t eeconfig_read_defalt_layer(void)      { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
34 void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); }
35
36 uint8_t eeconfig_read_keymap(void)      { return eeprom_read_byte(EECONFIG_KEYMAP); }
37 void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); }