From cef14009d932303dd93ec320b26de05e381319e9 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 26 Jun 2019 08:46:08 +0200 Subject: [PATCH 1/2] cpu/stm32l1: use flash size define to get the number of pages --- cpu/stm32l1/include/cpu_conf.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cpu/stm32l1/include/cpu_conf.h b/cpu/stm32l1/include/cpu_conf.h index d9940a3ff5..222e6e44c3 100644 --- a/cpu/stm32l1/include/cpu_conf.h +++ b/cpu/stm32l1/include/cpu_conf.h @@ -76,18 +76,9 @@ extern "C" { * @name Flash page configuration * @{ */ -#if defined(CPU_MODEL_STM32L152RE) || defined(CPU_MODEL_STM32L151RC) || defined(CPU_MODEL_STM32L151CB) #define FLASHPAGE_SIZE (256U) -#if defined(CPU_MODEL_STM32L152RE) -#define FLASHPAGE_NUMOF (2048U) /* 512KB */ -#endif -#if defined(CPU_MODEL_STM32L151RC) -#define FLASHPAGE_NUMOF (1024U) /* 256KB */ -#endif -#if defined(CPU_MODEL_STM32L151CB) -#define FLASHPAGE_NUMOF (512U) /* 128KB */ -#endif -#endif +#define FLASHPAGE_NUMOF (STM32_FLASHSIZE / FLASHPAGE_SIZE) + /* The minimum block size which can be written is 4B. However, the erase * block is always FLASHPAGE_SIZE. */ From ee5181dd509e81e94ff5e2013504e573499185d1 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 26 Jun 2019 08:46:19 +0200 Subject: [PATCH 2/2] cpu/stm32l4: use flash size define to get the number of pages --- cpu/stm32l4/include/cpu_conf.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cpu/stm32l4/include/cpu_conf.h b/cpu/stm32l4/include/cpu_conf.h index 14e846cf90..1cfc99e9b0 100644 --- a/cpu/stm32l4/include/cpu_conf.h +++ b/cpu/stm32l4/include/cpu_conf.h @@ -64,13 +64,8 @@ extern "C" { */ #define FLASHPAGE_SIZE (2048U) -#if defined(CPU_MODEL_STM32L432KC) || defined(CPU_MODEL_STM32L433RC) -#define FLASHPAGE_NUMOF (128U) -#elif defined(CPU_MODEL_STM32L452RE) -#define FLASHPAGE_NUMOF (256U) -#else -#define FLASHPAGE_NUMOF (512U) -#endif +#define FLASHPAGE_NUMOF (STM32_FLASHSIZE / FLASHPAGE_SIZE) + /* The minimum block size which can be written is 8B. However, the erase * block is always FLASHPAGE_SIZE. */