Skip to content
Permalink
Browse files

add eeconfig functions

  • Loading branch information
dodosuke committed Nov 16, 2019
1 parent ca88531 commit b415b17329e9bad5ac0644645b2720f05ae9a2da
Showing with 59 additions and 5 deletions.
  1. +47 −1 tmk_core/common/eeconfig.c
  2. +12 −4 tmk_core/common/eeconfig.h
@@ -3,6 +3,22 @@
#include "eeprom.h"
#include "eeconfig.h"


/** \brief eeconfig enable
*
* FIXME: needs doc
*/
__attribute__((weak)) void eeconfig_init_user(void) {
// Reset user EEPROM value to blank, rather than to a set value
eeconfig_update_user(0);
}

__attribute__((weak)) void eeconfig_init_kb(void) {
// Reset Keyboard EEPROM value to blank, rather than to a set value
eeconfig_update_kb(0);
eeconfig_init_user();
}

/** \brief eeconfig initialization
*
* FIXME: needs doc
@@ -26,6 +42,7 @@ void eeconfig_init(void)
#ifdef STENO_ENABLE
eeprom_update_byte(EECONFIG_STENOMODE, 0);
#endif
eeconfig_init_kb();
}

/** \brief eeconfig enable
@@ -43,7 +60,7 @@ void eeconfig_enable(void)
*/
void eeconfig_disable(void)
{
eeprom_update_word(EECONFIG_MAGIC, 0xFFFF);
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER_OFF);
}

/** \brief eeconfig is enabled
@@ -55,6 +72,12 @@ bool eeconfig_is_enabled(void)
return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
}

/** \brief eeconfig is disabled
*
* FIXME: needs doc
*/
bool eeconfig_is_disabled(void) { return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF); }

/** \brief eeconfig read debug
*
* FIXME: needs doc
@@ -113,3 +136,26 @@ uint8_t eeconfig_read_audio(void) { return eeprom_read_byte(EECONFIG_AUDIO)
*/
void eeconfig_update_audio(uint8_t val) { eeprom_update_byte(EECONFIG_AUDIO, val); }
#endif

/** \brief eeconfig read kb
*
* FIXME: needs doc
*/
uint32_t eeconfig_read_kb(void) { return eeprom_read_dword(EECONFIG_KEYBOARD); }
/** \brief eeconfig update kb
*
* FIXME: needs doc
*/
void eeconfig_update_kb(uint32_t val) { eeprom_update_dword(EECONFIG_KEYBOARD, val); }

/** \brief eeconfig read user
*
* FIXME: needs doc
*/
uint32_t eeconfig_read_user(void) { return eeprom_read_dword(EECONFIG_USER); }
/** \brief eeconfig update user
*
* FIXME: needs doc
*/
void eeconfig_update_user(uint32_t val) { eeprom_update_dword(EECONFIG_USER, val); }

@@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <stdbool.h>


#define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEED
#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF

/* eeprom parameteter address */
#define EECONFIG_MAGIC (uint16_t *)0
@@ -36,8 +36,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_UNICODEMODE (uint8_t *)12
#define EECONFIG_STENOMODE (uint8_t *)13
// EEHANDS for two handed boards
#define EECONFIG_HANDEDNESS (uint8_t *)14

#define EECONFIG_HANDEDNESS (uint8_t *)14
#define EECONFIG_KEYBOARD (uint32_t *)15
#define EECONFIG_USER (uint32_t *)19

/* debug bit */
#define EECONFIG_DEBUG_ENABLE (1<<0)
@@ -55,10 +56,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_KEYMAP_SWAP_BACKSLASH_BACKSPACE (1<<6)
#define EECONFIG_KEYMAP_NKRO (1<<7)


bool eeconfig_is_enabled(void);
bool eeconfig_is_disabled(void);

void eeconfig_init(void);
void eeconfig_init_kb(void);
void eeconfig_init_user(void);

void eeconfig_enable(void);

@@ -83,4 +86,9 @@ uint8_t eeconfig_read_audio(void);
void eeconfig_update_audio(uint8_t val);
#endif

uint32_t eeconfig_read_kb(void);
void eeconfig_update_kb(uint32_t val);
uint32_t eeconfig_read_user(void);
void eeconfig_update_user(uint32_t val);

#endif

0 comments on commit b415b17

Please sign in to comment.
You can’t perform that action at this time.