/* Erase whole chip memory with build-in erase program.  */
unsigned char AT45DBxxxDChipErase()
/* Erase whole chip memory with build-in erase program.  */
unsigned char AT45DBxxxDChipErase()
{
	unsigned int i = 0;
	if(AT45DBxxxDStatusGet() & AT45DBxxxD_SCPT_EN) return AT45DBxxxD_OP_INVALID;
	while(!AT45DBxxxDWaitReady())
	{
	    if(++i > AT45DBxxxD_OVERTIME)
	    {
	    	return AT45DBxxxD_OP_BUSY;
	    }
	}
    AT45DBxxxD_CS_CLR;
    if(AT45DBxxxDStatusGet() & AT45DBxxxD_SCPT_EN) return AT45DBxxxD_OP_WRITEPROTECT;
    xSPIDataWrite(AT45DBxxxD_SPI_PORT, AT45DBxxxD_CMD_CPER, 4);
    AT45DBxxxD_CS_SET;
    return AT45DBxxxD_OP_OK;
}