From 3777b96cd5605bf2356a5d012538edf3c6cfac1c Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Tue, 16 Feb 2016 21:28:19 +0000 Subject: [PATCH] stm32f1: remove duplicate incorrect flash size register DESIG_FLASH_SIZE is provided for all stm32 parts in desig.h, correctly defined as 16bits. Remove the incorrect duplicate definition within the f1 flash handling code. Fixes github issues #621 --- lib/stm32/f1/flash.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/stm32/f1/flash.c b/lib/stm32/f1/flash.c index 1112d50b..31df4b75 100644 --- a/lib/stm32/f1/flash.c +++ b/lib/stm32/f1/flash.c @@ -59,11 +59,9 @@ /**@{*/ +#include #include -/* Memory Size Register */ -#define MEMORY_SIZE_REG MMIO32(DESIG_FLASH_SIZE_BASE) - /*---------------------------------------------------------------------------*/ /** @brief Enable the FLASH Half Cycle Mode @@ -99,7 +97,7 @@ It is locked by default on reset. void flash_unlock_upper(void) { - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { /* Clear the unlock state. */ FLASH_CR2 |= FLASH_CR_LOCK; @@ -128,7 +126,7 @@ void flash_lock_upper(void) void flash_clear_pgerr_flag_upper(void) { - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { FLASH_SR2 |= FLASH_SR_PGERR; } } @@ -140,7 +138,7 @@ void flash_clear_pgerr_flag_upper(void) void flash_clear_eop_flag_upper(void) { - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { FLASH_SR2 |= FLASH_SR_EOP; } } @@ -152,7 +150,7 @@ void flash_clear_eop_flag_upper(void) void flash_clear_wrprterr_flag_upper(void) { - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { FLASH_SR2 |= FLASH_SR_WRPRTERR; } } @@ -164,7 +162,7 @@ void flash_clear_wrprterr_flag_upper(void) void flash_clear_bsy_flag_upper(void) { - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { FLASH_SR2 &= ~FLASH_SR_BSY; } } @@ -181,7 +179,7 @@ void flash_clear_status_flags(void) flash_clear_eop_flag(); flash_clear_wrprterr_flag(); flash_clear_bsy_flag(); - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { flash_clear_pgerr_flag_upper(); flash_clear_eop_flag_upper(); flash_clear_wrprterr_flag_upper(); @@ -208,7 +206,7 @@ uint32_t flash_get_status_flags(void) FLASH_SR_EOP | FLASH_SR_WRPRTERR | FLASH_SR_BSY)); - if (MEMORY_SIZE_REG > 512) { + if (DESIG_FLASH_SIZE > 512) { flags |= (FLASH_SR2 & (FLASH_SR_PGERR | FLASH_SR_EOP | FLASH_SR_WRPRTERR | @@ -235,7 +233,7 @@ void flash_program_half_word(uint32_t address, uint16_t data) { flash_wait_for_last_operation(); - if ((MEMORY_SIZE_REG > 512) && (address >= FLASH_BASE+0x00080000)) { + if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) { FLASH_CR2 |= FLASH_CR_PG; } else { FLASH_CR |= FLASH_CR_PG; @@ -245,7 +243,7 @@ void flash_program_half_word(uint32_t address, uint16_t data) flash_wait_for_last_operation(); - if ((MEMORY_SIZE_REG > 512) && (address >= FLASH_BASE+0x00080000)) { + if ((DESIG_FLASH_SIZE > 512) && (address >= FLASH_BASE+0x00080000)) { FLASH_CR2 &= ~FLASH_CR_PG; } else { FLASH_CR &= ~FLASH_CR_PG; @@ -269,7 +267,7 @@ void flash_erase_page(uint32_t page_address) { flash_wait_for_last_operation(); - if ((MEMORY_SIZE_REG > 512) + if ((DESIG_FLASH_SIZE > 512) && (page_address >= FLASH_BASE+0x00080000)) { FLASH_CR2 |= FLASH_CR_PER; FLASH_AR2 = page_address; @@ -282,7 +280,7 @@ void flash_erase_page(uint32_t page_address) flash_wait_for_last_operation(); - if ((MEMORY_SIZE_REG > 512) + if ((DESIG_FLASH_SIZE > 512) && (page_address >= FLASH_BASE+0x00080000)) { FLASH_CR2 &= ~FLASH_CR_PER; } else {