/* Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.  */
void s25fl1xx_set_read_latency_control(struct qspid_t *qspid, uint8_t latency)
/* Enables critical writes operation on a serial flash device, such as sector protection, status register, etc.  */
void s25fl1xx_set_read_latency_control(struct qspid_t *qspid, uint8_t latency)
{
	uint8_t status[3];
	status[0] = s25fl1xx_read_status1(qspid);
	status[1] = s25fl1xx_read_status2(qspid);
	status[2] = s25fl1xx_read_status3(qspid);
	status[2] |= latency;
	qspid->qspi_buffer.data_tx = (uint32_t *)&status[2];
	while((status[2] & S25FL1XX_STATUS_LATENCY_CTRL) != latency) {
		s25fl1xx_write_volatile_status(qspid, status);
		status[2] = s25fl1xx_read_status3(qspid);
		delay_ms(50);
	}
}