XilinxProcessorIPLib/drivers/dp14txss/examples/src/tx_only/idt_8t49n24x.c
static int IDT_8T49N24x_SetRegister(u32 I2CBaseAddress, u8 I2CSlaveAddress,
				u16 RegisterAddress, u8 Value)
{
	u32 ByteCount = 0;
	u8 Buffer[3];
	u8 Retry = 0;
	u32 Status;

	/* Write data */
	Buffer[0] = (RegisterAddress >> 8);
	Buffer[1] = RegisterAddress & 0xff;
	Buffer[2] = Value;

	while (1) {
		ByteCount = 0;
#ifdef versal
		Status = XIicPs_MasterSendPolled(&Ps_Iic0,
		                                             (u8 *)&Buffer,
		                                             3,
													 I2CSlaveAddress);
		if(Status == XST_SUCCESS)
		{
			ByteCount = 3;
		}
#else
		ByteCount = XIic_Send(I2CBaseAddress, I2CSlaveAddress,
					(u8*)Buffer, 3, XIIC_STOP);
#endif
		if (ByteCount != 3)
		{
			Retry++;

			/* Maximum retries */
			if (Retry == 255) {
				xil_printf ("Set reg failed here\r\n");
				return XST_FAILURE;
			}
		} else {
			return XST_SUCCESS;
		}
	}
}
/*****************************************************************************/
/**
*
* This function send 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 send a single byte to the IDT 8T49N24x
This function send a single byte to the IDT 8T49N24x
static int IDT_8T49N24x_SetRegister(u32 I2CBaseAddress, u8 I2CSlaveAddress,
				u16 RegisterAddress, u8 Value)
{
	u32 ByteCount = 0;
	u8 Buffer[3];
	u8 Retry = 0;
	u32 Status;
	Buffer[0] = (RegisterAddress >> 8);
	Buffer[1] = RegisterAddress & 0xff;
	Buffer[2] = Value;
	while (1) {
		ByteCount = 0;
#ifdef versal
		Status = XIicPs_MasterSendPolled(&Ps_Iic0,
		                                             (u8 *)&Buffer,
		                                             3,
													 I2CSlaveAddress);
		if(Status == XST_SUCCESS)
		{
			ByteCount = 3;
		}
#else
		ByteCount = XIic_Send(I2CBaseAddress, I2CSlaveAddress,
					(u8*)Buffer, 3, XIIC_STOP);
#endif
		if (ByteCount != 3)
		{
			Retry++;
			if (Retry == 255) {
				xil_printf ("Set reg failed here\r\n");
				return XST_FAILURE;
			}
		} else {
			return XST_SUCCESS;
		}
	}
}
static int IDT_8T49N24x_SetRegister ( u32 I2CBaseAddress , u8 I2CSlaveAddress , u16 RegisterAddress , u8 Value ) { u32 ByteCount = 0 ; u8 Buffer [ 3 ] ; u8 Retry = 0 ; u32 Status ; Buffer [ 0 ] = ( RegisterAddress >> 8 ) ; Buffer [ 1 ] = RegisterAddress & 0xff ; Buffer [ 2 ] = Value ; while ( 1 ) { ByteCount = 0 ; #ifdef versal Status = XIicPs_MasterSendPolled ( & Ps_Iic0 , ( u8 * ) & Buffer , 3 , I2CSlaveAddress ) ; if ( Status == XST_SUCCESS ) { ByteCount = 3 ; } #else ByteCount = XIic_Send ( I2CBaseAddress , I2CSlaveAddress , ( u8 * ) Buffer , 3 , XIIC_STOP ) ; #endif if ( ByteCount != 3 ) { Retry ++ ; if ( Retry == 255 ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } } else { return XST_SUCCESS ; } } }
This function send a single byte to the IDT 8T49N24x
This function send a single byte to the IDT 8T49N24x
/* Write data */ /* Maximum retries */