/* Erases all the content of the memory chip.  */
uint8_t s25fl1xx_erase_chip(struct qspid_t *qspid)
/* Erases all the content of the memory chip.  */
uint8_t s25fl1xx_erase_chip(struct qspid_t *qspid)
{
	uint8_t i=0;
	uint8_t status = S25FL1XX_STATUS_RDYBSY;
	uint8_t chip_status= s25fl1xx_read_status1(qspid);
	if(chip_status & S25FL1XX_CHIP_PROTECT_Msk) {
		return 1;
	} else {
		s25fl1xx_enable_write(qspid);
		s25fl1xx_exec_command(qspid, S25FL1XX_CHIP_ERASE_2, 0, 0, QSPI_CMD_ACCESS, 0);
		while(status & S25FL1XX_STATUS_RDYBSY) {
			delay_ms(200);
			i++;
			status = s25fl1xx_read_status1(qspid);
			i = i % 4;
		}
		return 0;
	}
}