Skip to content

Commit ed10e78

Browse files
zvecrptrxyz
authored andcommitted
Further tidy up of STM32 eeprom emulation (qmk#14591)
1 parent 2aedf53 commit ed10e78

File tree

3 files changed

+10
-38
lines changed

3 files changed

+10
-38
lines changed

common_features.mk

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -153,51 +153,18 @@ else
153153
ifeq ($(PLATFORM),AVR)
154154
# Automatically provided by avr-libc, nothing required
155155
else ifeq ($(PLATFORM),CHIBIOS)
156-
ifeq ($(MCU_SERIES), STM32F3xx)
156+
ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),)
157157
OPT_DEFS += -DEEPROM_DRIVER
158158
COMMON_VPATH += $(DRIVER_PATH)/eeprom
159159
SRC += eeprom_driver.c
160160
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
161161
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
162-
OPT_DEFS += -DEEPROM_EMU_STM32F303xC
163-
else ifeq ($(MCU_SERIES), STM32F1xx)
164-
OPT_DEFS += -DEEPROM_DRIVER
165-
COMMON_VPATH += $(DRIVER_PATH)/eeprom
166-
SRC += eeprom_driver.c
167-
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
168-
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
169-
OPT_DEFS += -DEEPROM_EMU_STM32F103xB
170-
else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F072xB)
171-
OPT_DEFS += -DEEPROM_DRIVER
172-
COMMON_VPATH += $(DRIVER_PATH)/eeprom
173-
SRC += eeprom_driver.c
174-
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
175-
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
176-
OPT_DEFS += -DEEPROM_EMU_STM32F072xB
177-
else ifneq ($(filter $(MCU_SERIES)_$(MCU_LDSCRIPT),STM32F4xx_STM32F401xC STM32F4xx_STM32F401xE STM32F4xx_STM32F411xE STM32F4xx_STM32F405xG),)
178-
OPT_DEFS += -DEEPROM_DRIVER
179-
COMMON_VPATH += $(DRIVER_PATH)/eeprom
180-
SRC += eeprom_driver.c
181-
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
182-
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
183-
OPT_DEFS += -DEEPROM_EMU_STM32F401xC
184-
else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F042x6)
185-
# Stack sizes: Since this chip has limited RAM capacity, the stack area needs to be reduced.
186-
# This ensures that the EEPROM page buffer fits into RAM
187-
USE_PROCESS_STACKSIZE = 0x600
188-
USE_EXCEPTIONS_STACKSIZE = 0x300
189-
190-
OPT_DEFS += -DEEPROM_DRIVER
191-
COMMON_VPATH += $(DRIVER_PATH)/eeprom
192-
SRC += eeprom_driver.c
193-
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
194-
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
195-
OPT_DEFS += -DEEPROM_EMU_STM32F042x6
196162
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
197163
OPT_DEFS += -DEEPROM_DRIVER
198164
COMMON_VPATH += $(DRIVER_PATH)/eeprom
199165
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom
200-
SRC += eeprom_driver.c eeprom_stm32_L0_L1.c
166+
SRC += eeprom_driver.c
167+
SRC += eeprom_stm32_L0_L1.c
201168
else
202169
# This will effectively work the same as "transient" if not supported by the chip
203170
SRC += $(PLATFORM_COMMON_DIR)/eeprom_teensy.c

quantum/mcu_selection.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ ifneq ($(findstring STM32F042, $(MCU)),)
138138

139139
# UF2 settings
140140
UF2_FAMILY ?= STM32F0
141+
142+
# Stack sizes: Since this chip has limited RAM capacity, the stack area needs to be reduced.
143+
# This ensures that the EEPROM page buffer fits into RAM
144+
USE_PROCESS_STACKSIZE = 0x600
145+
USE_EXCEPTIONS_STACKSIZE = 0x300
141146
endif
142147

143148
ifneq ($(findstring STM32F072, $(MCU)),)

tmk_core/common/chibios/flash_stm32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
#include <hal.h>
2020
#include "flash_stm32.h"
2121

22-
#if defined(EEPROM_EMU_STM32F103xB)
22+
#if defined(STM32F1XX)
2323
# define FLASH_SR_WRPERR FLASH_SR_WRPRTERR
2424
#endif
2525

26-
#if defined(EEPROM_EMU_STM32F401xC)
26+
#if defined(STM32F4XX)
2727
# define FLASH_SR_PGERR (FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR)
2828

2929
# define FLASH_KEY1 0x45670123U

0 commit comments

Comments
 (0)