[PROJECTS][NUCLEO-F103RB][EEPROM] Replace hard-coded page end address by a variable in EE_VerifyPageFullyErased()

Fixes issue raised in #11.
This commit is contained in:
Ali Labbene 2022-01-21 17:46:47 +01:00 committed by Ali LABBENE
parent c750eab699
commit 156741e067
2 changed files with 34 additions and 32 deletions

View File

@ -305,11 +305,15 @@ uint16_t EE_Init(void)
*/ */
uint16_t EE_VerifyPageFullyErased(uint32_t Address) uint16_t EE_VerifyPageFullyErased(uint32_t Address)
{ {
uint32_t readstatus = 1; uint32_t endAddress;
uint32_t readstatus = 1;
uint16_t addressvalue = 0x5555; uint16_t addressvalue = 0x5555;
/* Compute page end-address */
endAddress = (uint32_t)(Address + (PAGE_SIZE - 4U));
/* Check each active page address starting from end */ /* Check each active page address starting from end */
while (Address <= PAGE0_END_ADDRESS) while (Address <= endAddress)
{ {
/* Get the current location content to be compared with virtual address */ /* Get the current location content to be compared with virtual address */
addressvalue = (*(__IO uint16_t*)Address); addressvalue = (*(__IO uint16_t*)Address);
@ -699,8 +703,6 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data)
return flashstatus; return flashstatus;
} }
/* Return last operation flash status */ /* Return last operation flash status */
return flashstatus; return flashstatus;
} }