XilinxProcessorIPLib/drivers/dp14txss/examples/src/tx_only/idt_8t49n24x.c
static u8 IDT_8T49N24x_GetRegister(u32 I2CBaseAddress, u8 I2CSlaveAddress,
				u16 RegisterAddress)
{
	u32 ByteCount = 0;
	u8 Buffer[2];
	u8 Data;
	u8 Retry = 0;
	u8 Exit;


	Exit = FALSE;
	Data = 0;
    u32 Status;

    do {
		/* Set Address */
        Buffer[0] = (RegisterAddress >> 8);
        Buffer[1] = RegisterAddress & 0xff;

        ByteCount = 0;
#ifdef versal
        Status = XIicPs_MasterSendPolled(&Ps_Iic0,(u8 *)&Buffer,
                                                 2,I2CSlaveAddress);
		if(Status == XST_SUCCESS)
		{
			ByteCount = 2;
		}
#else
		ByteCount = XIic_Send(I2CBaseAddress, I2CSlaveAddress,
				(u8*)Buffer, 2, XIIC_REPEATED_START);
#endif
		if (ByteCount != 2)
		{
		    xil_printf ("Send failed\r\n");
			Retry++;
			/* Maximum retries */
			if (Retry == 255) {
				Exit = TRUE;
			}
		} else {
			ByteCount = 0;
			/* Read data. */
#ifdef versal
		    Status = XIicPs_MasterRecvPolled(&Ps_Iic0, &Data, 1, I2CSlaveAddress);
			if(Status == XST_SUCCESS)
			{
				ByteCount = 1;
			}
#else
			ByteCount = XIic_Recv(I2CBaseAddress, I2CSlaveAddress,
						(u8*)Buffer, 1, XIIC_STOP);
#endif
			if (ByteCount != 1)
			{
				xil_printf ("read failed\r\n");
				Exit = FALSE;
				Exit = TRUE;
			} else {
#ifndef versal
				Data = Buffer[0];
#endif
				Exit = TRUE;
			}
		}

    } while (!Exit);
	return Data;
}
/*****************************************************************************/
/**
*
* This function reads a single byte to the IDT 8T49N24x
*
* @param I2CBaseAddress is the baseaddress of the I2C core.
* @param I2CSlaveAddress is the 7-bit I2C slave address.
*
* @return
*    - XST_SUCCESS Initialization was successful.
*    - XST_FAILURE I2C write error.
*
* @note None.
*
******************************************************************************/
This function reads a single byte to the IDT 8T49N24x
This function reads a single byte to the IDT 8T49N24x
static u8 IDT_8T49N24x_GetRegister(u32 I2CBaseAddress, u8 I2CSlaveAddress,
				u16 RegisterAddress)
{
	u32 ByteCount = 0;
	u8 Buffer[2];
	u8 Data;
	u8 Retry = 0;
	u8 Exit;
	Exit = FALSE;
	Data = 0;
    u32 Status;
    do {
        Buffer[0] = (RegisterAddress >> 8);
        Buffer[1] = RegisterAddress & 0xff;
        ByteCount = 0;
#ifdef versal
        Status = XIicPs_MasterSendPolled(&Ps_Iic0,(u8 *)&Buffer,
                                                 2,I2CSlaveAddress);
		if(Status == XST_SUCCESS)
		{
			ByteCount = 2;
		}
#else
		ByteCount = XIic_Send(I2CBaseAddress, I2CSlaveAddress,
				(u8*)Buffer, 2, XIIC_REPEATED_START);
#endif
		if (ByteCount != 2)
		{
		    xil_printf ("Send failed\r\n");
			Retry++;
			if (Retry == 255) {
				Exit = TRUE;
			}
		} else {
			ByteCount = 0;
#ifdef versal
		    Status = XIicPs_MasterRecvPolled(&Ps_Iic0, &Data, 1, I2CSlaveAddress);
			if(Status == XST_SUCCESS)
			{
				ByteCount = 1;
			}
#else
			ByteCount = XIic_Recv(I2CBaseAddress, I2CSlaveAddress,
						(u8*)Buffer, 1, XIIC_STOP);
#endif
			if (ByteCount != 1)
			{
				xil_printf ("read failed\r\n");
				Exit = FALSE;
				Exit = TRUE;
			} else {
#ifndef versal
				Data = Buffer[0];
#endif
				Exit = TRUE;
			}
		}
    } while (!Exit);
	return Data;
}
static u8 IDT_8T49N24x_GetRegister ( u32 I2CBaseAddress , u8 I2CSlaveAddress , u16 RegisterAddress ) { u32 ByteCount = 0 ; u8 Buffer [ 2 ] ; u8 Data ; u8 Retry = 0 ; u8 Exit ; Exit = FALSE ; Data = 0 ; u32 Status ; do { Buffer [ 0 ] = ( RegisterAddress >> 8 ) ; Buffer [ 1 ] = RegisterAddress & 0xff ; ByteCount = 0 ; #ifdef versal Status = XIicPs_MasterSendPolled ( & Ps_Iic0 , ( u8 * ) & Buffer , 2 , I2CSlaveAddress ) ; if ( Status == XST_SUCCESS ) { ByteCount = 2 ; } #else ByteCount = XIic_Send ( I2CBaseAddress , I2CSlaveAddress , ( u8 * ) Buffer , 2 , XIIC_REPEATED_START ) ; #endif if ( ByteCount != 2 ) { xil_printf ( " \r \n " ) ; Retry ++ ; if ( Retry == 255 ) { Exit = TRUE ; } } else { ByteCount = 0 ; #ifdef versal Status = XIicPs_MasterRecvPolled ( & Ps_Iic0 , & Data , 1 , I2CSlaveAddress ) ; if ( Status == XST_SUCCESS ) { ByteCount = 1 ; } #else ByteCount = XIic_Recv ( I2CBaseAddress , I2CSlaveAddress , ( u8 * ) Buffer , 1 , XIIC_STOP ) ; #endif if ( ByteCount != 1 ) { xil_printf ( " \r \n " ) ; Exit = FALSE ; Exit = TRUE ; } else { #ifndef versal Data = Buffer [ 0 ] ; #endif Exit = TRUE ; } } } while ( ! Exit ) ; return Data ; }
This function reads a single byte to the IDT 8T49N24x
This function reads a single byte to the IDT 8T49N24x
/* Set Address */ /* Maximum retries */ /* Read data. */