Description
Source
Call Graph
Start Line: 243
unsigned char AT26D_EraseBlock(At26 *pAt26, unsigned int address)
{
unsigned char status;
unsigned char error;
SANITY_CHECK(pAt26);
// Check that the flash is ready and unprotected
status = AT26D_ReadStatus(pAt26);
if ((status & AT26_STATUS_RDYBSY) != AT26_STATUS_RDYBSY_READY) {
TRACE_ERROR("AT26D_EraseBlock : Flash busy\n\r");
return AT26_ERROR_BUSY;
}
else if ((status & AT26_STATUS_SWP) != AT26_STATUS_SWP_PROTNONE) {
TRACE_ERROR("AT26D_EraseBlock : Flash protected\n\r");
return AT26_ERROR_PROTECTED;
}
// Enable critical write operation
AT26D_EnableWrite(pAt26);
// Start the block erase command
error = AT26_SendCommand(pAt26, AT26_BlockEraseCmd(pAt26), 4, 0, 0, address, 0, 0);
ASSERT(!error, "-F- AT26_EraseBlock: Could not issue command.\n\r");
// Wait for transfer to finish
AT26D_Wait(pAt26);
// Poll the Serial flash status register until the operation is achieved
AT26D_WaitReady(pAt26);
return 0;
}