mirror of
https://github.com/andreili/katapult.git
synced 2025-08-23 19:34:06 +02:00
stm32: Enable support for stm32f2 - it has same flash interface as stm32f4
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d2ea272de0
commit
5cbc25d676
@ -30,7 +30,7 @@ choice
|
|||||||
bool "STM32F103"
|
bool "STM32F103"
|
||||||
select MACH_STM32F1
|
select MACH_STM32F1
|
||||||
config MACH_STM32F207
|
config MACH_STM32F207
|
||||||
bool "STM32F207" if 0
|
bool "STM32F207"
|
||||||
select MACH_STM32F2
|
select MACH_STM32F2
|
||||||
config MACH_STM32F401
|
config MACH_STM32F401
|
||||||
bool "STM32F401"
|
bool "STM32F401"
|
||||||
@ -344,9 +344,9 @@ config CANBUS_FREQUENCY
|
|||||||
choice
|
choice
|
||||||
prompt "Application start offset"
|
prompt "Application start offset"
|
||||||
config STM32_APP_START_8000
|
config STM32_APP_START_8000
|
||||||
bool "32KiB offset" if MACH_STM32F4
|
bool "32KiB offset" if MACH_STM32F2 || MACH_STM32F4
|
||||||
config STM32_APP_START_4000
|
config STM32_APP_START_4000
|
||||||
bool "16KiB offset" if MACH_STM32F4
|
bool "16KiB offset" if MACH_STM32F2 || MACH_STM32F4
|
||||||
config STM32_APP_START_2000
|
config STM32_APP_START_2000
|
||||||
bool "8KiB offset" if MACH_STM32F0 || MACH_STM32F1
|
bool "8KiB offset" if MACH_STM32F0 || MACH_STM32F1
|
||||||
config STM32_APP_START_1000
|
config STM32_APP_START_1000
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "flash.h" // flash_write_block
|
#include "flash.h" // flash_write_block
|
||||||
#include "internal.h" // FLASH
|
#include "internal.h" // FLASH
|
||||||
|
|
||||||
#if CONFIG_MACH_STM32F4
|
#if CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4
|
||||||
#define FLASH_KEY1 (0x45670123UL)
|
#define FLASH_KEY1 (0x45670123UL)
|
||||||
#define FLASH_KEY2 (0xCDEF89ABUL)
|
#define FLASH_KEY2 (0xCDEF89ABUL)
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ stm32f4_sector_index(uint32_t addr)
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
flash_get_page_size(uint32_t addr)
|
flash_get_page_size(uint32_t addr)
|
||||||
{
|
{
|
||||||
if (CONFIG_MACH_STM32F4) {
|
if (CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4) {
|
||||||
if (addr < 0x08010000)
|
if (addr < 0x08010000)
|
||||||
return 16 * 1024;
|
return 16 * 1024;
|
||||||
else if (addr < 0x08020000)
|
else if (addr < 0x08020000)
|
||||||
@ -91,7 +91,7 @@ lock_flash(void)
|
|||||||
static void
|
static void
|
||||||
erase_page(uint32_t page_address)
|
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
|
FLASH->CR = (FLASH_CR_PSIZE_1 | FLASH_CR_STRT | FLASH_CR_SER
|
||||||
| ((stm32f4_sector_index(page_address) & 0xF) << 3));
|
| ((stm32f4_sector_index(page_address) & 0xF) << 3));
|
||||||
#else
|
#else
|
||||||
@ -106,7 +106,7 @@ erase_page(uint32_t page_address)
|
|||||||
static void
|
static void
|
||||||
write_block(uint32_t block_address, uint32_t *data)
|
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;
|
uint32_t *page = (void*)block_address;
|
||||||
FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG;
|
FLASH->CR = FLASH_CR_PSIZE_1 | FLASH_CR_PG;
|
||||||
for (int i = 0; i < CONFIG_BLOCK_SIZE / 4; i++) {
|
for (int i = 0; i < CONFIG_BLOCK_SIZE / 4; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user