summaryrefslogtreecommitdiff
path: root/ports/stm32/flash.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2018-03-17 10:42:50 +1100
committerDamien George <damien.p.george@gmail.com>2018-03-17 10:42:50 +1100
commite37b8ba5a55c99dbd1e69eb1c99651307b22fd3e (patch)
tree41800ba58b24830bd8033274dadd7b189e4a621d /ports/stm32/flash.c
parent5edce4539b239eab9b045bb2fde18456f6fdbfe4 (diff)
stm32: Use STM32xx macros instead of MCU_SERIES_xx to select MCU type.
The CMSIS files for the STM32 range provide macros to distinguish between the different MCU series: STM32F4, STM32F7, STM32H7, STM32L4, etc. Prefer to use these instead of custom ones.
Diffstat (limited to 'ports/stm32/flash.c')
-rw-r--r--ports/stm32/flash.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/ports/stm32/flash.c b/ports/stm32/flash.c
index 4042785fa..214d10fdb 100644
--- a/ports/stm32/flash.c
+++ b/ports/stm32/flash.c
@@ -34,7 +34,7 @@ typedef struct {
uint32_t sector_count;
} flash_layout_t;
-#if defined(MCU_SERIES_F4)
+#if defined(STM32F4)
static const flash_layout_t flash_layout[] = {
{ 0x08000000, 0x04000, 4 },
@@ -50,7 +50,7 @@ static const flash_layout_t flash_layout[] = {
#endif
};
-#elif defined(MCU_SERIES_F7)
+#elif defined(STM32F7)
// FLASH_FLAG_PGSERR (Programming Sequence Error) was renamed to
// FLASH_FLAG_ERSERR (Erasing Sequence Error) in STM32F7
@@ -62,7 +62,7 @@ static const flash_layout_t flash_layout[] = {
{ 0x08040000, 0x40000, 3 },
};
-#elif defined(MCU_SERIES_L4)
+#elif defined(STM32L4)
static const flash_layout_t flash_layout[] = {
{ (uint32_t)FLASH_BASE, (uint32_t)FLASH_PAGE_SIZE, 512 },
@@ -78,7 +78,7 @@ static const flash_layout_t flash_layout[] = {
#error Unsupported processor
#endif
-#if defined(MCU_SERIES_L4) || defined(STM32H7)
+#if defined(STM32L4) || defined(STM32H7)
// get the bank of a given flash address
static uint32_t get_bank(uint32_t addr) {
@@ -103,7 +103,7 @@ static uint32_t get_bank(uint32_t addr) {
}
}
-#if defined(MCU_SERIES_L4)
+#if defined(STM32L4)
// get the page of a given flash address
static uint32_t get_page(uint32_t addr) {
if (addr < (FLASH_BASE + FLASH_BANK_SIZE)) {
@@ -153,7 +153,7 @@ void flash_erase(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32)
FLASH_EraseInitTypeDef EraseInitStruct;
- #if defined(MCU_SERIES_L4)
+ #if defined(STM32L4)
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
// erase the sector(s)
@@ -220,7 +220,7 @@ void flash_erase_it(uint32_t flash_dest, const uint32_t *src, uint32_t num_word3
*/
void flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32) {
- #if defined(MCU_SERIES_L4)
+ #if defined(STM32L4)
// program the flash uint64 by uint64
for (int i = 0; i < num_word32 / 2; i++) {