lib/sw_apps/imgsel/src/xis_i2c.c
static int XIs_MuxInitChannel(u16 MuxIicAddr, u8 Channel)
{
	int Status = XST_FAILURE;
	u8 Buffer = 0U;
	u32 Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;


	/*
	 * Wait until bus is idle to start another transfer.
	 */
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}

	/*
	 * Send the Data.
	 */
	Status = XIicPs_MasterSendPolled(&IicInstance, &Channel, 1U,
			MuxIicAddr);
	if (Status != XST_SUCCESS) {
		Status = XIS_IICPS_MASTER_SEND_POLLED_ERROR;
		goto END;
	}

	Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;

	/*
	 * Wait until bus is idle to start another transfer.
	 */
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}

	/*
	 * Receive the Data.
	 */
	Status = XIicPs_MasterRecvPolled(&IicInstance, &Buffer, 1U, MuxIicAddr);
	if (Status != XST_SUCCESS) {
		Status = XIS_IICPS_MASTER_RECV_POLLED_ERROR;
		goto END;
	}

	Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;

	/*
	 * Wait until bus is idle to start another transfer.
	 */
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}

END:
	return Status;
}
/*****************************************************************************/
/**
 * This function initializes the IIC MUX to select the required channel.
 *
 * @param	MuxAddress Contains the address of IIC MUX
 * @param 	Channel Contains the channel number.
 *
 * @return	XST_SUCCESS if pass, otherwise XST_FAILURE.
 *
 * @note		None.
 *
 ****************************************************************************/
This function initializes the IIC MUX to select the required channel.
@param       MuxAddress Contains the address of IIC MUX
@param       Channel Contains the channel number.



@note                None.
This function initializes the IIC MUX to select the required channel . @param MuxAddress Contains the address of IIC MUX @param Channel Contains the channel number . @note None .
static int XIs_MuxInitChannel(u16 MuxIicAddr, u8 Channel)
{
	int Status = XST_FAILURE;
	u8 Buffer = 0U;
	u32 Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}
	Status = XIicPs_MasterSendPolled(&IicInstance, &Channel, 1U,
			MuxIicAddr);
	if (Status != XST_SUCCESS) {
		Status = XIS_IICPS_MASTER_SEND_POLLED_ERROR;
		goto END;
	}
	Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}
	Status = XIicPs_MasterRecvPolled(&IicInstance, &Buffer, 1U, MuxIicAddr);
	if (Status != XST_SUCCESS) {
		Status = XIS_IICPS_MASTER_RECV_POLLED_ERROR;
		goto END;
	}
	Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL;
	while (Timeout != 0U) {
		if(XIicPs_BusIsBusy(&IicInstance) == FALSE ) {
			break;
		}
		XIs_Delay(XIS_DELAY);
		Timeout--;
		if(!Timeout) {
			Status = XIS_IICPS_TIMEOUT;
			goto END;
		}
	}
END:
	return Status;
}
static int XIs_MuxInitChannel ( u16 MuxIicAddr , u8 Channel ) { int Status = XST_FAILURE ; u8 Buffer = 0U ; u32 Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL ; while ( Timeout != 0U ) { if ( XIicPs_BusIsBusy ( & IicInstance ) == FALSE ) { break ; } XIs_Delay ( XIS_DELAY ) ; Timeout -- ; if ( ! Timeout ) { Status = XIS_IICPS_TIMEOUT ; goto END ; } } Status = XIicPs_MasterSendPolled ( & IicInstance , & Channel , 1U , MuxIicAddr ) ; if ( Status != XST_SUCCESS ) { Status = XIS_IICPS_MASTER_SEND_POLLED_ERROR ; goto END ; } Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL ; while ( Timeout != 0U ) { if ( XIicPs_BusIsBusy ( & IicInstance ) == FALSE ) { break ; } XIs_Delay ( XIS_DELAY ) ; Timeout -- ; if ( ! Timeout ) { Status = XIS_IICPS_TIMEOUT ; goto END ; } } Status = XIicPs_MasterRecvPolled ( & IicInstance , & Buffer , 1U , MuxIicAddr ) ; if ( Status != XST_SUCCESS ) { Status = XIS_IICPS_MASTER_RECV_POLLED_ERROR ; goto END ; } Timeout = XIICPS_POLL_DEFAULT_TIMEOUT_VAL ; while ( Timeout != 0U ) { if ( XIicPs_BusIsBusy ( & IicInstance ) == FALSE ) { break ; } XIs_Delay ( XIS_DELAY ) ; Timeout -- ; if ( ! Timeout ) { Status = XIS_IICPS_TIMEOUT ; goto END ; } } END : return Status ; }
This function initializes the IIC MUX to select the required channel.
This function initializes the IIC MUX to select the required channel .
/*
	 * Wait until bus is idle to start another transfer.
	 */ /*
	 * Send the Data.
	 */ /*
	 * Wait until bus is idle to start another transfer.
	 */ /*
	 * Receive the Data.
	 */ /*
	 * Wait until bus is idle to start another transfer.
	 */