From f7620ae1482110d0401a16ad49e909c585d755ad Mon Sep 17 00:00:00 2001 From: molnarkares Date: Sat, 2 Nov 2013 11:05:50 +0100 Subject: [PATCH] * unnecessary PG bit clearing removed from flash word and half-word programming to improve speed * missing PG bit set is inserted at word programming --- lib/stm32/f1/flash.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/stm32/f1/flash.c b/lib/stm32/f1/flash.c index aec98ae7..95f0664a 100644 --- a/lib/stm32/f1/flash.c +++ b/lib/stm32/f1/flash.c @@ -127,14 +127,14 @@ void flash_program_word(uint32_t address, uint32_t data) /* Wait for the write to complete. */ flash_wait_for_last_operation(); + /* Enable writes to flash. */ + FLASH_CR |= FLASH_CR_PG; + /* Program the second half of the word. */ MMIO16(address + 2) = data >> 16; /* Wait for the write to complete. */ flash_wait_for_last_operation(); - - /* Disable writes to flash. */ - FLASH_CR &= ~FLASH_CR_PG; } void flash_program_half_word(uint32_t address, uint16_t data) @@ -146,8 +146,6 @@ void flash_program_half_word(uint32_t address, uint16_t data) MMIO16(address) = data; flash_wait_for_last_operation(); - - FLASH_CR &= ~FLASH_CR_PG; /* Disable the PG bit. */ } void flash_erase_page(uint32_t page_address)