Migrate STM32_EEPROM_ENABLE to use EEPROM_DRIVER (#14433)
parent
b63453a75b
commit
fa141a5a8f
|
@ -157,20 +157,26 @@ else
|
|||
# Automatically provided by avr-libc, nothing required
|
||||
else ifeq ($(PLATFORM),CHIBIOS)
|
||||
ifeq ($(MCU_SERIES), STM32F3xx)
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
OPT_DEFS += -DEEPROM_EMU_STM32F303xC
|
||||
OPT_DEFS += -DSTM32_EEPROM_ENABLE
|
||||
else ifeq ($(MCU_SERIES), STM32F1xx)
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
OPT_DEFS += -DEEPROM_EMU_STM32F103xB
|
||||
OPT_DEFS += -DSTM32_EEPROM_ENABLE
|
||||
else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F072xB)
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
OPT_DEFS += -DEEPROM_EMU_STM32F072xB
|
||||
OPT_DEFS += -DSTM32_EEPROM_ENABLE
|
||||
else ifeq ($(MCU_SERIES)_$(MCU_LDSCRIPT), STM32F0xx_STM32F042x6)
|
||||
|
||||
# Stack sizes: Since this chip has limited RAM capacity, the stack area needs to be reduced.
|
||||
|
@ -178,10 +184,12 @@ else
|
|||
USE_PROCESS_STACKSIZE = 0x600
|
||||
USE_EXCEPTIONS_STACKSIZE = 0x300
|
||||
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
SRC += eeprom_driver.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/eeprom_stm32.c
|
||||
SRC += $(PLATFORM_COMMON_DIR)/flash_stm32.c
|
||||
OPT_DEFS += -DEEPROM_EMU_STM32F042x6
|
||||
OPT_DEFS += -DSTM32_EEPROM_ENABLE
|
||||
else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),)
|
||||
OPT_DEFS += -DEEPROM_DRIVER
|
||||
COMMON_VPATH += $(DRIVER_PATH)/eeprom
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
#ifdef EEPROM_ENABLE
|
||||
# include "eeprom.h"
|
||||
#endif
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
# include <hal.h>
|
||||
# include "eeprom_stm32.h"
|
||||
#endif
|
||||
#include "wait.h"
|
||||
#include "progmem.h"
|
||||
#include "timer.h"
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
#include "eeconfig.h"
|
||||
#include "action_layer.h"
|
||||
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
# include <hal.h>
|
||||
# include "eeprom_stm32.h"
|
||||
#endif
|
||||
|
||||
#if defined(EEPROM_DRIVER)
|
||||
# include "eeprom_driver.h"
|
||||
#endif
|
||||
|
@ -43,9 +38,6 @@ __attribute__((weak)) void eeconfig_init_kb(void) {
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_init_quantum(void) {
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
EEPROM_Erase();
|
||||
#endif
|
||||
#if defined(EEPROM_DRIVER)
|
||||
eeprom_driver_erase();
|
||||
#endif
|
||||
|
@ -111,9 +103,6 @@ void eeconfig_enable(void) { eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_N
|
|||
* FIXME: needs doc
|
||||
*/
|
||||
void eeconfig_disable(void) {
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
EEPROM_Erase();
|
||||
#endif
|
||||
#if defined(EEPROM_DRIVER)
|
||||
eeprom_driver_erase();
|
||||
#endif
|
||||
|
|
|
@ -97,9 +97,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifdef DIP_SWITCH_ENABLE
|
||||
# include "dip_switch.h"
|
||||
#endif
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
# include "eeprom_stm32.h"
|
||||
#endif
|
||||
#ifdef EEPROM_DRIVER
|
||||
# include "eeprom_driver.h"
|
||||
#endif
|
||||
|
@ -246,9 +243,6 @@ void keyboard_setup(void) {
|
|||
disable_jtag();
|
||||
#endif
|
||||
print_set_sendchar(sendchar);
|
||||
#ifdef STM32_EEPROM_ENABLE
|
||||
EEPROM_Init();
|
||||
#endif
|
||||
#ifdef EEPROM_DRIVER
|
||||
eeprom_driver_init();
|
||||
#endif
|
||||
|
|
|
@ -620,48 +620,11 @@ uint16_t EEPROM_ReadDataWord(uint16_t Address) {
|
|||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* Wrap library in AVR style functions.
|
||||
* Bind to eeprom_driver.c
|
||||
*******************************************************************************/
|
||||
uint8_t eeprom_read_byte(const uint8_t *Address) { return EEPROM_ReadDataByte((const uintptr_t)Address); }
|
||||
void eeprom_driver_init(void) { EEPROM_Init(); }
|
||||
|
||||
void eeprom_write_byte(uint8_t *Address, uint8_t Value) { EEPROM_WriteDataByte((uintptr_t)Address, Value); }
|
||||
|
||||
void eeprom_update_byte(uint8_t *Address, uint8_t Value) { EEPROM_WriteDataByte((uintptr_t)Address, Value); }
|
||||
|
||||
uint16_t eeprom_read_word(const uint16_t *Address) { return EEPROM_ReadDataWord((const uintptr_t)Address); }
|
||||
|
||||
void eeprom_write_word(uint16_t *Address, uint16_t Value) { EEPROM_WriteDataWord((uintptr_t)Address, Value); }
|
||||
|
||||
void eeprom_update_word(uint16_t *Address, uint16_t Value) { EEPROM_WriteDataWord((uintptr_t)Address, Value); }
|
||||
|
||||
uint32_t eeprom_read_dword(const uint32_t *Address) {
|
||||
const uint16_t p = (const uintptr_t)Address;
|
||||
/* Check word alignment */
|
||||
if (p % 2) {
|
||||
/* Not aligned */
|
||||
return (uint32_t)EEPROM_ReadDataByte(p) | (uint32_t)(EEPROM_ReadDataWord(p + 1) << 8) | (uint32_t)(EEPROM_ReadDataByte(p + 3) << 24);
|
||||
} else {
|
||||
/* Aligned */
|
||||
return EEPROM_ReadDataWord(p) | (EEPROM_ReadDataWord(p + 2) << 16);
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_dword(uint32_t *Address, uint32_t Value) {
|
||||
uint16_t p = (const uintptr_t)Address;
|
||||
/* Check word alignment */
|
||||
if (p % 2) {
|
||||
/* Not aligned */
|
||||
EEPROM_WriteDataByte(p, (uint8_t)Value);
|
||||
EEPROM_WriteDataWord(p + 1, (uint16_t)(Value >> 8));
|
||||
EEPROM_WriteDataByte(p + 3, (uint8_t)(Value >> 24));
|
||||
} else {
|
||||
/* Aligned */
|
||||
EEPROM_WriteDataWord(p, (uint16_t)Value);
|
||||
EEPROM_WriteDataWord(p + 2, (uint16_t)(Value >> 16));
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_update_dword(uint32_t *Address, uint32_t Value) { eeprom_write_dword(Address, Value); }
|
||||
void eeprom_driver_erase(void) { EEPROM_Erase(); }
|
||||
|
||||
void eeprom_read_block(void *buf, const void *addr, size_t len) {
|
||||
const uint8_t *src = (const uint8_t *)addr;
|
||||
|
@ -670,14 +633,14 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
|
|||
/* Check word alignment */
|
||||
if (len && (uintptr_t)src % 2) {
|
||||
/* Read the unaligned first byte */
|
||||
*dest++ = eeprom_read_byte(src++);
|
||||
*dest++ = EEPROM_ReadDataByte((const uintptr_t)src++);
|
||||
--len;
|
||||
}
|
||||
|
||||
uint16_t value;
|
||||
bool aligned = ((uintptr_t)dest % 2 == 0);
|
||||
while (len > 1) {
|
||||
value = eeprom_read_word((uint16_t *)src);
|
||||
value = EEPROM_ReadDataWord((const uintptr_t)((uint16_t *)src));
|
||||
if (aligned) {
|
||||
*(uint16_t *)dest = value;
|
||||
dest += 2;
|
||||
|
@ -689,7 +652,7 @@ void eeprom_read_block(void *buf, const void *addr, size_t len) {
|
|||
len -= 2;
|
||||
}
|
||||
if (len) {
|
||||
*dest = eeprom_read_byte(src);
|
||||
*dest = EEPROM_ReadDataByte((const uintptr_t)src);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,7 +663,7 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
|
|||
/* Check word alignment */
|
||||
if (len && (uintptr_t)dest % 2) {
|
||||
/* Write the unaligned first byte */
|
||||
eeprom_write_byte(dest++, *src++);
|
||||
EEPROM_WriteDataByte((uintptr_t)dest++, *src++);
|
||||
--len;
|
||||
}
|
||||
|
||||
|
@ -712,15 +675,13 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) {
|
|||
} else {
|
||||
value = *(uint8_t *)src | (*(uint8_t *)(src + 1) << 8);
|
||||
}
|
||||
eeprom_write_word((uint16_t *)dest, value);
|
||||
EEPROM_WriteDataWord((uintptr_t)((uint16_t *)dest), value);
|
||||
dest += 2;
|
||||
src += 2;
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
if (len) {
|
||||
eeprom_write_byte(dest, *src);
|
||||
EEPROM_WriteDataByte((uintptr_t)dest, *src);
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_update_block(const void *buf, void *addr, size_t len) { eeprom_write_block(buf, addr, len); }
|
||||
|
|
|
@ -16,6 +16,7 @@ eeprom_stm32_tiny_INC := $(eeprom_stm32_INC)
|
|||
eeprom_stm32_large_INC := $(eeprom_stm32_INC)
|
||||
|
||||
eeprom_stm32_SRC := \
|
||||
$(TOP_DIR)/drivers/eeprom/eeprom_driver.c \
|
||||
$(TMK_PATH)/common/test/eeprom_stm32_tests.cpp \
|
||||
$(TMK_PATH)/common/test/flash_stm32_mock.c \
|
||||
$(TMK_PATH)/common/chibios/eeprom_stm32.c
|
||||
|
|
Loading…
Reference in New Issue