File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 8484#elif defined (STM32L0xx )
8585#define FLASH_BASE_ADDRESS ((uint32_t)(DATA_EEPROM_BASE)) /* 0x08080000 */
8686#elif defined (STM32L4xx )
87- // Flash base address (Bank2, page 256)
88- #define FLASH_BASE_ADDRESS 0x080FF800
89- #define FLASH_PAGE_NUMBER 255
87+ #ifndef FLASH_BANK_2
88+ #define FLASH_BANK_NUMBER FLASH_BANK_1
89+ #else
90+ #define FLASH_BANK_NUMBER FLASH_BANK_2
91+ #endif // FLASH_BANK_2
92+ // Flash base address
93+ #define FLASH_PAGE_NUMBER ((uint32_t)((FLASH_SIZE/FLASH_PAGE_SIZE) -1))
94+ #define FLASH_BASE_ADDRESS ((uint32_t)(0x08000000 + (FLASH_PAGE_NUMBER*FLASH_PAGE_SIZE)))
9095#endif
91-
9296/**
9397 * @}
9498 */
@@ -176,7 +180,7 @@ void set_data_to_flash(void)
176180 // ERASING page
177181 EraseInitStruct .TypeErase = FLASH_TYPEERASE_PAGES ;
178182#ifdef STM32L4xx
179- EraseInitStruct .Banks = FLASH_BANK_2 ;
183+ EraseInitStruct .Banks = FLASH_BANK_NUMBER ;
180184 EraseInitStruct .Page = FLASH_PAGE_NUMBER ;
181185#else // STM32F4xx
182186 EraseInitStruct .PageAddress = FLASH_BASE_ADDRESS ;
You can’t perform that action at this time.
0 commit comments