From 4ad30d56b4b37e9c39d6623c61ea656c67441623 Mon Sep 17 00:00:00 2001 From: Fergus Noble Date: Fri, 10 May 2013 13:30:32 -0700 Subject: [PATCH] Add higher level flash_program function for f2/f4 to write a buffer into flash. --- include/libopencm3/stm32/common/flash_common_f24.h | 1 + lib/stm32/common/flash_common_f24.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/libopencm3/stm32/common/flash_common_f24.h b/include/libopencm3/stm32/common/flash_common_f24.h index 2a762a30..e977333a 100644 --- a/include/libopencm3/stm32/common/flash_common_f24.h +++ b/include/libopencm3/stm32/common/flash_common_f24.h @@ -143,6 +143,7 @@ void flash_program_double_word(u32 address, u64 data); void flash_program_word(u32 address, u32 data); void flash_program_half_word(u32 address, u16 data); void flash_program_byte(u32 address, u8 data); +void flash_program(u32 address, u8* data, u32 len); void flash_wait_for_last_operation(void); void flash_program_option_bytes(u32 data); diff --git a/lib/stm32/common/flash_common_f24.c b/lib/stm32/common/flash_common_f24.c index 6abff49d..17cc561d 100644 --- a/lib/stm32/common/flash_common_f24.c +++ b/lib/stm32/common/flash_common_f24.c @@ -218,6 +218,15 @@ void flash_program_byte(u32 address, u8 data) FLASH_CR &= ~FLASH_CR_PG; /* Disable the PG bit. */ } +void flash_program(u32 address, u8* data, u32 len) +{ + /* TODO: Use dword and word size program operations where possible for turbo + * speed. */ + u32 i; + for (i=0; i