From 5cbc25d676ca3bcca6f8b5add74a74e9d6db8628 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 16 May 2022 21:16:22 -0400 Subject: [PATCH] stm32: Enable support for stm32f2 - it has same flash interface as stm32f4 Signed-off-by: Kevin O'Connor --- src/stm32/Kconfig | 6 +++--- src/stm32/flash.c | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/stm32/Kconfig b/src/stm32/Kconfig index b7fea6a..b3ab7cf 100644 --- a/src/stm32/Kconfig +++ b/src/stm32/Kconfig @@ -30,7 +30,7 @@ choice bool "STM32F103" select MACH_STM32F1 config MACH_STM32F207 - bool "STM32F207" if 0 + bool "STM32F207" select MACH_STM32F2 config MACH_STM32F401 bool "STM32F401" @@ -344,9 +344,9 @@ config CANBUS_FREQUENCY choice prompt "Application start offset" config STM32_APP_START_8000 - bool "32KiB offset" if MACH_STM32F4 + bool "32KiB offset" if MACH_STM32F2 || MACH_STM32F4 config STM32_APP_START_4000 - bool "16KiB offset" if MACH_STM32F4 + bool "16KiB offset" if MACH_STM32F2 || MACH_STM32F4 config STM32_APP_START_2000 bool "8KiB offset" if MACH_STM32F0 || MACH_STM32F1 config STM32_APP_START_1000 diff --git a/src/stm32/flash.c b/src/stm32/flash.c index 7c574f6..2b77c4c 100644 --- a/src/stm32/flash.c +++ b/src/stm32/flash.c @@ -10,7 +10,7 @@ #include "flash.h" // flash_write_block #include "internal.h" // FLASH -#if CONFIG_MACH_STM32F4 +#if CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4 #define FLASH_KEY1 (0x45670123UL) #define FLASH_KEY2 (0xCDEF89ABUL) @@ -31,7 +31,7 @@ stm32f4_sector_index(uint32_t addr) static uint32_t flash_get_page_size(uint32_t addr) { - if (CONFIG_MACH_STM32F4) { + if (CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4) { if (addr < 0x08010000) return 16 * 1024; else if (addr < 0x08020000) @@ -91,7 +91,7 @@ lock_flash(void) static void erase_page(uint32_t page_address) { -#if CONFIG_MACH_STM32F4 +#if CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4 FLASH->CR = (FLASH_CR_PSIZE_1 | FLASH_CR_STRT | FLASH_CR_SER | ((stm32f4_sector_index(page_address) & 0xF) << 3)); #else @@ -106,7 +106,7 @@ erase_page(uint32_t page_address) static void write_block(uint32_t block_address, uint32_t *data) { -#if CONFIG_MACH_STM32F4 +#if CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4 uint32_t *page = (void*)block_address; FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG; for (int i = 0; i < CONFIG_BLOCK_SIZE / 4; i++) {