Skip to content

Commit dad8282

Browse files
author
fpr
committed
Factorized code to make reading easier
Signed-off-by: fpr <[email protected]>
1 parent 0366e8a commit dad8282

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

Diff for: cores/arduino/stm32/stm32_eeprom.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,13 @@
6969
* @{
7070
*/
7171
// We use the last page of the flash to store data (to prevent code overwritten).
72-
#ifdef STM32F0xx
73-
#define FLASH_BASE_ADDRESS ((uint32_t)(FLASH_BANK1_END + 1) - FLASH_PAGE_SIZE)
74-
#elif defined (STM32F1xx)
72+
#if defined (STM32F0xx) || defined (STM32F1xx)
7573
#ifdef FLASH_BANK2_END
7674
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_BANK2_END + 1) - FLASH_PAGE_SIZE))
7775
#else
7876
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_BANK1_END + 1) - FLASH_PAGE_SIZE))
7977
#endif // FLASH_BANK2_END
80-
#elif defined (STM32F2xx)
78+
#elif defined (STM32F2xx) || defined (STM32F4xx) || defined (STM32F7xx)
8179
#define FLASH_BASE_ADDRESS ((uint32_t)(FLASH_END + 1) - FLASH_PAGE_SIZE)
8280
#define FLASH_DATA_SECTOR ((uint32_t)(FLASH_SECTOR_TOTAL - 1))
8381
#elif defined (STM32F3xx)
@@ -109,12 +107,6 @@ static inline uint32_t get_flash_end(void) {
109107
}
110108
#define FLASH_END_ADDR get_flash_end()
111109
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END_ADDR + 1) - FLASH_PAGE_SIZE))
112-
#elif defined (STM32F4xx)
113-
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
114-
#define FLASH_DATA_SECTOR ((uint32_t)(FLASH_SECTOR_TOTAL - 1))
115-
#elif defined (STM32F7xx)
116-
#define FLASH_BASE_ADDRESS ((uint32_t)((FLASH_END + 1) - FLASH_PAGE_SIZE))
117-
#define FLASH_DATA_SECTOR ((uint32_t)(FLASH_SECTOR_TOTAL - 1))
118110
#elif defined (STM32L0xx)
119111
#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE))
120112
#elif defined (STM32L4xx)

0 commit comments

Comments
 (0)