diff options
author | Nick Brassel <nick@tzarc.org> | 2022-02-02 15:04:37 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-02 15:04:37 +1100 |
commit | e22efc037a7e4da17f1051d5053768e40683da68 (patch) | |
tree | d58924ef9de401b4e97ba46113ee42874a1593be /quantum | |
parent | da5cb5fd6f91c2f7aebbcebbf211252c51d9b4a5 (diff) |
Don't make EEPROM size assumptions with dynamic keymaps. (#16054)
* Don't make EEPROM size assumptions with dynamic keymaps.
* Add support for checking against emulated flash, error out if someone attempts to build a board without specifying EEPROM size.
* Reorder defines so that MCU is considered last.
* Refactor EEPROM definitions for simplicity.
* Fix max sizing of kabedon/kabedon980.
* Fix max sizing of mechlovin/olly/jf.
* Fix unit tests.
* Review comments, add messages with values during build failures.
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/dynamic_keymap.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 19a6bea59a..8f1f39bc0f 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -29,24 +29,22 @@ # define DYNAMIC_KEYMAP_MACRO_COUNT 16 #endif -// This is the default EEPROM max address to use for dynamic keymaps. -// The default is the ATmega32u4 EEPROM max address. -// Explicitly override it if the keyboard uses a microcontroller with -// more EEPROM *and* it makes sense to increase it. +#ifndef TOTAL_EEPROM_BYTE_COUNT +# error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps. +#endif + #ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR -# if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 -# elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 -# elif defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATtiny85__) -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 511 -# else -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023 -# endif +# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1) +#endif + +#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > (TOTAL_EEPROM_BYTE_COUNT - 1) +# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > " STR((TOTAL_EEPROM_BYTE_COUNT - 1)) +# error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver #endif // Due to usage of uint16_t check for max 65535 #if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > 65535 +# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > 65535" # error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536 #endif @@ -71,6 +69,7 @@ // or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has // more than the default. #if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR < 100 +# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) " < 100" # error Dynamic keymaps are configured to use more EEPROM than is available. #endif |