/* Get valid Page for write operation */
ValidPage = EE_FindValidPage(WRITE_IN_VALID_PAGE);
/* Check if there is no valid page */
if (ValidPage == NO_VALID_PAGE)
{
CurWrAddress = (uint32_t)(EEPROM_START_ADDRESS + (uint32_t)(ValidPage * PAGE_SIZE));
return NO_VALID_PAGE;
}
/* Get the valid Page end Address */
PageEndAddress = (uint32_t)((EEPROM_START_ADDRESS - 2) + (uint32_t)((1 + ValidPage) * PAGE_SIZE));
/* Check each active page address starting from begining */
while (CurWrAddress < PageEndAddress)
{
/* Verify if Address and Address+2 contents are 0xFFFFFFFF */
if ((*(__IO uint32_t*)CurWrAddress) == 0xFFFFFFFF)
{
/* Set variable virtual address */
FlashStatus = FLASH_COMPLETE;
/* Return program operation status */
return FlashStatus;
}
else
{
/* Next address location */
CurWrAddress = CurWrAddress + 4;
}
}
/* Return PAGE_FULL in case the valid page is full */
return PAGE_FULL;
}
详细请看修改后的例子,读写函数也做了相应更改