From 5bad37cb564fa2ce210c9dbeac99e046304a9614 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 14 Jan 2022 23:28:29 -0800 Subject: [Bug] Remove config.h include in dynamic_keymap.c (#15886) --- quantum/dynamic_keymap.c | 1 - 1 file changed, 1 deletion(-) (limited to 'quantum/dynamic_keymap.c') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index f5525576d8..19a6bea59a 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -14,7 +14,6 @@ * along with this program. If not, see . */ -#include "config.h" #include "keymap.h" // to get keymaps[][][] #include "eeprom.h" #include "progmem.h" // to read default from flash -- cgit v1.2.3 From e22efc037a7e4da17f1051d5053768e40683da68 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 2 Feb 2022 15:04:37 +1100 Subject: 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. --- quantum/dynamic_keymap.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'quantum/dynamic_keymap.c') 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 -- cgit v1.2.3 From 63646e8906e062d1c1de3925cba70c4e3426a855 Mon Sep 17 00:00:00 2001 From: QMK Bot Date: Sat, 12 Feb 2022 10:29:31 -0800 Subject: Format code according to conventions (#16322) --- quantum/dynamic_keymap.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'quantum/dynamic_keymap.c') diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 8f1f39bc0f..f070375ff3 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -14,12 +14,12 @@ * along with this program. If not, see . */ -#include "keymap.h" // to get keymaps[][][] +#include "keymap.h" // to get keymaps[][][] #include "eeprom.h" -#include "progmem.h" // to read default from flash -#include "quantum.h" // for send_string() +#include "progmem.h" // to read default from flash +#include "quantum.h" // for send_string() #include "dynamic_keymap.h" -#include "via.h" // for default VIA_EEPROM_ADDR_END +#include "via.h" // for default VIA_EEPROM_ADDR_END #ifndef DYNAMIC_KEYMAP_LAYER_COUNT # define DYNAMIC_KEYMAP_LAYER_COUNT 4 @@ -79,7 +79,9 @@ # define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) #endif -uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; } +uint8_t dynamic_keymap_get_layer_count(void) { + return DYNAMIC_KEYMAP_LAYER_COUNT; +} void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { // TODO: optimize this with some left shifts @@ -151,9 +153,13 @@ uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key) { } } -uint8_t dynamic_keymap_macro_get_count(void) { return DYNAMIC_KEYMAP_MACRO_COUNT; } +uint8_t dynamic_keymap_macro_get_count(void) { + return DYNAMIC_KEYMAP_MACRO_COUNT; +} -uint16_t dynamic_keymap_macro_get_buffer_size(void) { return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; } +uint16_t dynamic_keymap_macro_get_buffer_size(void) { + return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; +} void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); -- cgit v1.2.3