XilinxProcessorIPLib/drivers/dfeccf/examples/xdfesi570_mgt.c
int XDfeSi570_InitI2C(void)
{
#ifdef __BAREMETAL__
	XIicPs_Config *Config_iic;
	int Status;
	u32 ClkRate = 100000U;

	/* I2C1 */
	Config_iic = XIicPs_LookupConfig(1);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}

	Status = XIicPs_CfgInitialize(&Iic1, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	Status = XIicPs_SetSClk(&Iic1, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#else
	/* I2C1 */
	fd_i2c1 = open(XDFESI570_I2C1_DEVICE, O_RDWR);
	if (fd_i2c1 < 0) {
		Xil_AssertNonvoid("i2c1 open");
		return XST_FAILURE;
	}
	fd_device = open(XDFESI570_I2C1_MGT_DEVICE, O_RDWR);
	if (fd_device < 0) {
		Xil_AssertNonvoid("i2c device open");
		return XST_FAILURE;
	}
#endif
	return XST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function is used to open and configure I2C drivers.
*
* @param None
*
* @return
*	- XST_SUCCESS if successful.
*	- XST_FAILURE if failed.
*
* @note		None
*
****************************************************************************/
This function is used to open and configure I2C drivers.
This function is used to open and configure I2C drivers .
int XDfeSi570_InitI2C(void)
{
#ifdef __BAREMETAL__
	XIicPs_Config *Config_iic;
	int Status;
	u32 ClkRate = 100000U;
	Config_iic = XIicPs_LookupConfig(1);
	if (NULL == Config_iic) {
		return XST_FAILURE;
	}
	Status = XIicPs_CfgInitialize(&Iic1, Config_iic,
				      Config_iic->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XIicPs_SetSClk(&Iic1, ClkRate);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
#else
	fd_i2c1 = open(XDFESI570_I2C1_DEVICE, O_RDWR);
	if (fd_i2c1 < 0) {
		Xil_AssertNonvoid("i2c1 open");
		return XST_FAILURE;
	}
	fd_device = open(XDFESI570_I2C1_MGT_DEVICE, O_RDWR);
	if (fd_device < 0) {
		Xil_AssertNonvoid("i2c device open");
		return XST_FAILURE;
	}
#endif
	return XST_SUCCESS;
}
int XDfeSi570_InitI2C ( void ) { #ifdef __BAREMETAL__ XIicPs_Config * Config_iic ; int Status ; u32 ClkRate = 100000U ; Config_iic = XIicPs_LookupConfig ( 1 ) ; if ( NULL == Config_iic ) { return XST_FAILURE ; } Status = XIicPs_CfgInitialize ( & Iic1 , Config_iic , Config_iic -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XIicPs_SetSClk ( & Iic1 , ClkRate ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } #else fd_i2c1 = open ( XDFESI570_I2C1_DEVICE , O_RDWR ) ; if ( fd_i2c1 < 0 ) { Xil_AssertNonvoid ( " " ) ; return XST_FAILURE ; } fd_device = open ( XDFESI570_I2C1_MGT_DEVICE , O_RDWR ) ; if ( fd_device < 0 ) { Xil_AssertNonvoid ( " " ) ; return XST_FAILURE ; } #endif return XST_SUCCESS ; }
This function is used to open and configure I2C drivers.
This function is used to open and configure I2C drivers .
/* I2C1 */ /* I2C1 */