SPRADL4 January 2025 F29H850TU , F29H859TU-Q1
The Erase_Bank function leverages the Flash API to erase a full EEPROM Unit. This function is only a wrapper around Flash API, and the protection masks are set in the EEPROM_Erase() functions.
It begins by clearing the FSM status and copying the protection masks into Flash API.
ClearFSMStatus(FLASH_BANK_SELECT, u32UserFlashConfig);
Fapi_setupBankSectorEnable((uint32_t*) FLASH_BANK_SELECT, u32UserFlashConfig,
FLASH_NOWRAPPER_O_CMDWEPROTA, WE_Protection_A_Mask);
Fapi_setupBankSectorEnable((uint32_t*) FLASH_BANK_SELECT, u32UserFlashConfig,
FLASH_NOWRAPPER_O_CMDWEPROTB, WE_Protection_B_Mask);
Then, it erases the flash and checks for programming errors.
oReturnCheck = Fapi_issueBankEraseCommand((uint32_t*) FLASH_BANK_SELECT, 0, u32UserFlashConfig);
while(Fapi_checkFsmForReady((uint32_t) FLASH_BANK_SELECT, u32UserFlashConfig) == Fapi_Status_FsmBusy);
if (oReturnCheck != Fapi_Status_Success)
Sample_Error();
oFlashStatus = Fapi_getFsmStatus((uint32_t) FLASH_BANK_SELECT, u32UserFlashConfig);
if (oFlashStatus != 3)
{
FMSTAT_Fail();
}
Finally, if Erase_Blank_Check is set, a blank check is performed.
if (Erase_Blank_Check)
{
uint32_t address = FLASH_BANK_SELECT + FIRST_AND_LAST_SECTOR[EEPROM_ACTIVE_UNIT][0] * FLASH_SECTOR_SIZE;
Fapi_FlashStatusWordType oFlashStatusWord;
oReturnCheck = Fapi_doBlankCheck((uint32_t*) address, BLANK_CHECK_LEN, &oFlashStatusWord, 0,
u32UserFlashConfig);
if (oReturnCheck != Fapi_Status_Success)
{
Sample_Error();
}
}