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
This commit is contained in:
Karl Palsson 2016-02-16 21:28:19 +00:00
parent 6853b7ac5a
commit 3777b96cd5

View File

@ -59,11 +59,9 @@
/**@{*/ /**@{*/
#include <libopencm3/stm32/desig.h>
#include <libopencm3/stm32/flash.h> #include <libopencm3/stm32/flash.h>
/* Memory Size Register */
#define MEMORY_SIZE_REG MMIO32(DESIG_FLASH_SIZE_BASE)
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/** @brief Enable the FLASH Half Cycle Mode /** @brief Enable the FLASH Half Cycle Mode
@ -99,7 +97,7 @@ It is locked by default on reset.
void flash_unlock_upper(void) void flash_unlock_upper(void)
{ {
if (MEMORY_SIZE_REG > 512) { if (DESIG_FLASH_SIZE > 512) {
/* Clear the unlock state. */ /* Clear the unlock state. */
FLASH_CR2 |= FLASH_CR_LOCK; FLASH_CR2 |= FLASH_CR_LOCK;
@ -128,7 +126,7 @@ void flash_lock_upper(void)
void flash_clear_pgerr_flag_upper(void) void flash_clear_pgerr_flag_upper(void)
{ {
if (MEMORY_SIZE_REG > 512) { if (DESIG_FLASH_SIZE > 512) {
FLASH_SR2 |= FLASH_SR_PGERR; FLASH_SR2 |= FLASH_SR_PGERR;
} }
} }
@ -140,7 +138,7 @@ void flash_clear_pgerr_flag_upper(void)
void flash_clear_eop_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; FLASH_SR2 |= FLASH_SR_EOP;
} }
} }
@ -152,7 +150,7 @@ void flash_clear_eop_flag_upper(void)
void flash_clear_wrprterr_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; FLASH_SR2 |= FLASH_SR_WRPRTERR;
} }
} }
@ -164,7 +162,7 @@ void flash_clear_wrprterr_flag_upper(void)
void flash_clear_bsy_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; FLASH_SR2 &= ~FLASH_SR_BSY;
} }
} }
@ -181,7 +179,7 @@ void flash_clear_status_flags(void)
flash_clear_eop_flag(); flash_clear_eop_flag();
flash_clear_wrprterr_flag(); flash_clear_wrprterr_flag();
flash_clear_bsy_flag(); flash_clear_bsy_flag();
if (MEMORY_SIZE_REG > 512) { if (DESIG_FLASH_SIZE > 512) {
flash_clear_pgerr_flag_upper(); flash_clear_pgerr_flag_upper();
flash_clear_eop_flag_upper(); flash_clear_eop_flag_upper();
flash_clear_wrprterr_flag_upper(); flash_clear_wrprterr_flag_upper();
@ -208,7 +206,7 @@ uint32_t flash_get_status_flags(void)
FLASH_SR_EOP | FLASH_SR_EOP |
FLASH_SR_WRPRTERR | FLASH_SR_WRPRTERR |
FLASH_SR_BSY)); FLASH_SR_BSY));
if (MEMORY_SIZE_REG > 512) { if (DESIG_FLASH_SIZE > 512) {
flags |= (FLASH_SR2 & (FLASH_SR_PGERR | flags |= (FLASH_SR2 & (FLASH_SR_PGERR |
FLASH_SR_EOP | FLASH_SR_EOP |
FLASH_SR_WRPRTERR | FLASH_SR_WRPRTERR |
@ -235,7 +233,7 @@ void flash_program_half_word(uint32_t address, uint16_t data)
{ {
flash_wait_for_last_operation(); 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; FLASH_CR2 |= FLASH_CR_PG;
} else { } else {
FLASH_CR |= FLASH_CR_PG; 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(); 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; FLASH_CR2 &= ~FLASH_CR_PG;
} else { } else {
FLASH_CR &= ~FLASH_CR_PG; FLASH_CR &= ~FLASH_CR_PG;
@ -269,7 +267,7 @@ void flash_erase_page(uint32_t page_address)
{ {
flash_wait_for_last_operation(); flash_wait_for_last_operation();
if ((MEMORY_SIZE_REG > 512) if ((DESIG_FLASH_SIZE > 512)
&& (page_address >= FLASH_BASE+0x00080000)) { && (page_address >= FLASH_BASE+0x00080000)) {
FLASH_CR2 |= FLASH_CR_PER; FLASH_CR2 |= FLASH_CR_PER;
FLASH_AR2 = page_address; FLASH_AR2 = page_address;
@ -282,7 +280,7 @@ void flash_erase_page(uint32_t page_address)
flash_wait_for_last_operation(); flash_wait_for_last_operation();
if ((MEMORY_SIZE_REG > 512) if ((DESIG_FLASH_SIZE > 512)
&& (page_address >= FLASH_BASE+0x00080000)) { && (page_address >= FLASH_BASE+0x00080000)) {
FLASH_CR2 &= ~FLASH_CR_PER; FLASH_CR2 &= ~FLASH_CR_PER;
} else { } else {