Flash only unlocked when needed
This commit is contained in:
@@ -144,6 +144,7 @@ void delay_01us(uint16_t nb);
|
||||
// Flash Write driver
|
||||
#define FLASH_PAGESIZE 256
|
||||
void unlockFlash();
|
||||
void lockFlash();
|
||||
void writeFlash(uint32_t * address, uint32_t * buffer);
|
||||
uint32_t isFirmwareStart(const void * buffer);
|
||||
uint32_t isBootloaderStart(const void * buffer);
|
||||
|
||||
@@ -16,6 +16,12 @@ void unlockFlash()
|
||||
FLASH->KEYR = 0xCDEF89AB;
|
||||
}
|
||||
|
||||
void lockFlash()
|
||||
{
|
||||
while (!FLASH->SR & FLASH_SR_BSY);
|
||||
FLASH->CR |= FLASH_CR_LOCK;
|
||||
}
|
||||
|
||||
void waitFlashIdle()
|
||||
{
|
||||
while (FLASH->SR & FLASH_FLAG_BSY) {
|
||||
|
||||
Reference in New Issue
Block a user