mbed library sources. Supersedes mbed-src.
Fork of mbed-dev by
Diff: targets/TARGET_STM/TARGET_STM32F4/flash_api.c
- Revision:
- 178:79309dc6340a
- Parent:
- 175:af195413fb11
diff -r d650f5d4c87a -r 79309dc6340a targets/TARGET_STM/TARGET_STM32F4/flash_api.c --- a/targets/TARGET_STM/TARGET_STM32F4/flash_api.c Wed Nov 08 13:50:44 2017 +0000 +++ b/targets/TARGET_STM/TARGET_STM32F4/flash_api.c Thu Nov 23 11:57:25 2017 +0000 @@ -145,7 +145,6 @@ uint32_t flash_get_sector_size(const flash_t *obj, uint32_t address) { - if ((address >= (FLASH_BASE + FLASH_SIZE)) || (address < FLASH_BASE)) { return MBED_FLASH_INVALID_SIZE; } @@ -165,7 +164,7 @@ } uint32_t flash_get_size(const flash_t *obj) { - return FLASH_SIZE; + return FLASH_SIZE; } /** @@ -175,13 +174,15 @@ */ static uint32_t GetSector(uint32_t address) { - uint32_t sector = 0; + uint32_t sector = 0; uint32_t tmp = address - ADDR_FLASH_SECTOR_0; /* This function supports 1Mb and 2Mb flash sizes */ #if defined(ADDR_FLASH_SECTOR_16) if (address & 0x100000) { // handle 2nd bank + /* Sector will be at least 12 */ sector = FLASH_SECTOR_12; - tmp = address - ADDR_FLASH_SECTOR_12; + tmp -= 0x100000; + address -= 0x100000; } #endif if (address < ADDR_FLASH_SECTOR_4) { // 16k sectorsize @@ -189,14 +190,14 @@ } #if defined(ADDR_FLASH_SECTOR_5) else if (address < ADDR_FLASH_SECTOR_5) { //64k sector size - sector += FLASH_SECTOR_4; + sector += FLASH_SECTOR_4; } else { sector += 4 + (tmp >>17); } #else // In case ADDR_FLASH_SECTOR_5 is not defined, sector 4 is the last one. else { //64k sector size - sector += FLASH_SECTOR_4; + sector += FLASH_SECTOR_4; } #endif return sector; @@ -225,7 +226,7 @@ sectorsize = 64 * 1024; } else { sectorsize = 128 * 1024; - } + } return sectorsize; }