File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change 7676
7777/*** FLASH ***/
7878#define FLASH_BASE (0x58004000)
79- #define FLASH_ACR (*(volatile uint32_t *)(FLASH_BASE + 0x00)) //RM0444 - 3.7.1 - FLASH_ACR
80- #define FLASH_KEY (*(volatile uint32_t *)(FLASH_BASE + 0x08)) //RM0444 - 3.7.2 - FLASH_KEYR
81- #define FLASH_SR (*(volatile uint32_t *)(FLASH_BASE + 0x10)) //RM0444 - 3.7.4 - FLASH_SR
82- #define FLASH_CR (*(volatile uint32_t *)(FLASH_BASE + 0x14)) //RM0444 - 3.7.5 - FLASH_CR
79+ #define FLASH_ACR (*(volatile uint32_t *)(FLASH_BASE + 0x00))
80+ #define FLASH_KEY (*(volatile uint32_t *)(FLASH_BASE + 0x08))
81+ #define FLASH_SR (*(volatile uint32_t *)(FLASH_BASE + 0x10))
82+ #define FLASH_CR (*(volatile uint32_t *)(FLASH_BASE + 0x14))
8383
8484#define FLASHMEM_ADDRESS_SPACE (0x08000000)
85- #define FLASH_PAGE_SIZE (0x800 ) /* 2KB */
85+ #define FLASH_PAGE_SIZE (0x1000 ) /* 4KB */
8686
8787/* Register values */
8888#define FLASH_ACR_LATENCY_MASK (0x07)
@@ -195,11 +195,11 @@ int RAMFUNCTION hal_flash_erase(uint32_t address, int len)
195195 end_address = address + len - 1 ;
196196 for (p = address ; p < end_address ; p += FLASH_PAGE_SIZE ) {
197197 uint32_t reg = FLASH_CR & (~(FLASH_CR_PNB_MASK << FLASH_CR_PNB_SHIFT ));
198- FLASH_CR = reg | ((p >> 11 ) << FLASH_CR_PNB_SHIFT ) | FLASH_CR_PER ;
198+ FLASH_CR = reg | ((p >> 12 ) << FLASH_CR_PNB_SHIFT ) | FLASH_CR_PER | FLASH_CR_PG ;
199199 DMB ();
200200 FLASH_CR |= FLASH_CR_STRT ;
201201 flash_wait_complete ();
202- FLASH_CR &= ~FLASH_CR_PER ;
202+ FLASH_CR &= ~( FLASH_CR_PER | FLASH_CR_PG ) ;
203203 }
204204 return 0 ;
205205}
You can’t perform that action at this time.
0 commit comments