stm32: f4: flash: support extended sector ranges

F42xx and F43xx have extended sector ranges.

Reported-by: H2OBrain@irc
This commit is contained in:
Karl Palsson 2014-12-17 15:22:15 +00:00 committed by Karl Palsson
parent e3b8adec10
commit 8a15cec6bf
2 changed files with 6 additions and 16 deletions

View File

@ -74,18 +74,8 @@
#define FLASH_CR_MER (1 << 2) #define FLASH_CR_MER (1 << 2)
#define FLASH_CR_SER (1 << 1) #define FLASH_CR_SER (1 << 1)
#define FLASH_CR_PG (1 << 0) #define FLASH_CR_PG (1 << 0)
#define FLASH_CR_SECTOR_0 (0x00 << 3) #define FLASH_CR_SNB_SHIFT 3
#define FLASH_CR_SECTOR_1 (0x01 << 3) #define FLASH_CR_SNB_MASK 0x1f
#define FLASH_CR_SECTOR_2 (0x02 << 3)
#define FLASH_CR_SECTOR_3 (0x03 << 3)
#define FLASH_CR_SECTOR_4 (0x04 << 3)
#define FLASH_CR_SECTOR_5 (0x05 << 3)
#define FLASH_CR_SECTOR_6 (0x06 << 3)
#define FLASH_CR_SECTOR_7 (0x07 << 3)
#define FLASH_CR_SECTOR_8 (0x08 << 3)
#define FLASH_CR_SECTOR_9 (0x09 << 3)
#define FLASH_CR_SECTOR_10 (0x0a << 3)
#define FLASH_CR_SECTOR_11 (0x0b << 3)
#define FLASH_CR_PROGRAM_X8 (0x00 << 8) #define FLASH_CR_PROGRAM_X8 (0x00 << 8)
#define FLASH_CR_PROGRAM_X16 (0x01 << 8) #define FLASH_CR_PROGRAM_X16 (0x01 << 8)
#define FLASH_CR_PROGRAM_X32 (0x02 << 8) #define FLASH_CR_PROGRAM_X32 (0x02 << 8)

View File

@ -351,7 +351,7 @@ first be fully erased before attempting to program it.
See the reference manual or the FLASH programming manual for details. See the reference manual or the FLASH programming manual for details.
@param[in] uint32_t sector (0 - 11). @param[in] uint32_t sector (0 - 11 for some parts, 0-23 on others)
@param program_size: 0 (8-bit), 1 (16-bit), 2 (32-bit), 3 (64-bit) @param program_size: 0 (8-bit), 1 (16-bit), 2 (32-bit), 3 (64-bit)
*/ */
@ -360,14 +360,14 @@ void flash_erase_sector(uint8_t sector, uint32_t program_size)
flash_wait_for_last_operation(); flash_wait_for_last_operation();
flash_set_program_size(program_size); flash_set_program_size(program_size);
FLASH_CR &= ~(0xF << 3); FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT);
FLASH_CR |= (sector << 3) & 0x78; FLASH_CR |= (sector & FLASH_CR_SNB_MASK) << FLASH_CR_SNB_SHIFT;
FLASH_CR |= FLASH_CR_SER; FLASH_CR |= FLASH_CR_SER;
FLASH_CR |= FLASH_CR_STRT; FLASH_CR |= FLASH_CR_STRT;
flash_wait_for_last_operation(); flash_wait_for_last_operation();
FLASH_CR &= ~FLASH_CR_SER; FLASH_CR &= ~FLASH_CR_SER;
FLASH_CR &= ~(0xF << 3); FLASH_CR &= ~(FLASH_CR_SNB_MASK << FLASH_CR_SNB_SHIFT);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/