[fal] Execute HAL_FLASH_Lock() in case of error wile writing and erasing (#183)
* Execute HAL_FLASH_Lock() in case of error wile writing and erasing * Also fix fal_flash_stm32f2_port.c * Replace tabs to spaces
This commit is contained in:
parent
d914eb068c
commit
a39f4e2ed6
|
@ -146,6 +146,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
|
|||
/* check data */
|
||||
if (read_data != *buf)
|
||||
{
|
||||
FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +174,7 @@ static int erase(long offset, size_t size)
|
|||
flash_status = FLASH_EraseSector(cur_erase_sector, VoltageRange_3);
|
||||
if (flash_status != FLASH_COMPLETE)
|
||||
{
|
||||
FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
erased_size += stm32_get_sector_size(cur_erase_sector);
|
||||
|
|
|
@ -182,11 +182,13 @@ static int write(long offset, const uint8_t *buf, size_t size)
|
|||
{
|
||||
if (*(uint8_t *) addr != *buf)
|
||||
{
|
||||
HAL_FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HAL_FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +223,7 @@ static int erase(long offset, size_t size)
|
|||
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, (uint32_t *) &SECTORError) != HAL_OK)
|
||||
{
|
||||
HAL_FLASH_Lock();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue