XilinxProcessorIPLib/drivers/iicps/examples/xiicps_eeprom_intr_example.c
static int IicPsFindEeprom(u16 *Eeprom_Addr,u32 *PageSize)
{
	int Status;
	u16 DeviceId;
	int MuxIndex,Index;
	u8 MuxChannel;

	for (DeviceId = 0; DeviceId < XPAR_XIICPS_NUM_INSTANCES; DeviceId++) {
		for(MuxIndex=0;MuxAddr[MuxIndex] != 0;MuxIndex++){
			Status = IicPsFindDevice(MuxAddr[MuxIndex], DeviceId);
			if (Status == XST_SUCCESS) {
				for(Index=0;EepromAddr[Index] != 0;Index++) {
					for(MuxChannel = 0x01; MuxChannel <= MAX_CHANNELS; MuxChannel = MuxChannel << 1) {
						Status = MuxInitChannel(MuxAddr[MuxIndex], MuxChannel);
						if (Status != XST_SUCCESS) {
							xil_printf("Failed to enable the MUX channel\r\n");
							return XST_FAILURE;
						}
						Status = FindEepromDevice(EepromAddr[Index]);
						FindEepromDevice(MUX_ADDR);
						if (Status == XST_SUCCESS) {
							*Eeprom_Addr = EepromAddr[Index];
						Status = FindEepromPageSize(EepromAddr[Index], PageSize);
						if (Status != XST_SUCCESS) {
							xil_printf("Failed to find the page size of 0X%X EEPROM\r\n", EepromAddr[Index]);
							return XST_FAILURE;
						}
						xil_printf("Page size %d\r\n", *PageSize);
						return XST_SUCCESS;
						}
					}
				}
			}
		}
		for(Index=0;EepromAddr[Index] != 0;Index++) {
			Status = IicPsFindDevice(EepromAddr[Index], DeviceId);
			if (Status == XST_SUCCESS) {
				*Eeprom_Addr = EepromAddr[Index];
				*PageSize = PAGE_SIZE_32;
				return XST_SUCCESS;
			}
		}
	}
	return XST_FAILURE;
}
/*****************************************************************************/
/**
* This function is use to figure out the Eeprom slave device
*
* @param	Eeprom slave address
*
* @param	Pagesize pointer
*
* @return	XST_SUCCESS if successful and also update the epprom slave
* device address in addr variable else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function is use to figure out the Eeprom slave device
This function is use to figure out the Eeprom slave device
static int IicPsFindEeprom(u16 *Eeprom_Addr,u32 *PageSize)
{
	int Status;
	u16 DeviceId;
	int MuxIndex,Index;
	u8 MuxChannel;
	for (DeviceId = 0; DeviceId < XPAR_XIICPS_NUM_INSTANCES; DeviceId++) {
		for(MuxIndex=0;MuxAddr[MuxIndex] != 0;MuxIndex++){
			Status = IicPsFindDevice(MuxAddr[MuxIndex], DeviceId);
			if (Status == XST_SUCCESS) {
				for(Index=0;EepromAddr[Index] != 0;Index++) {
					for(MuxChannel = 0x01; MuxChannel <= MAX_CHANNELS; MuxChannel = MuxChannel << 1) {
						Status = MuxInitChannel(MuxAddr[MuxIndex], MuxChannel);
						if (Status != XST_SUCCESS) {
							xil_printf("Failed to enable the MUX channel\r\n");
							return XST_FAILURE;
						}
						Status = FindEepromDevice(EepromAddr[Index]);
						FindEepromDevice(MUX_ADDR);
						if (Status == XST_SUCCESS) {
							*Eeprom_Addr = EepromAddr[Index];
						Status = FindEepromPageSize(EepromAddr[Index], PageSize);
						if (Status != XST_SUCCESS) {
							xil_printf("Failed to find the page size of 0X%X EEPROM\r\n", EepromAddr[Index]);
							return XST_FAILURE;
						}
						xil_printf("Page size %d\r\n", *PageSize);
						return XST_SUCCESS;
						}
					}
				}
			}
		}
		for(Index=0;EepromAddr[Index] != 0;Index++) {
			Status = IicPsFindDevice(EepromAddr[Index], DeviceId);
			if (Status == XST_SUCCESS) {
				*Eeprom_Addr = EepromAddr[Index];
				*PageSize = PAGE_SIZE_32;
				return XST_SUCCESS;
			}
		}
	}
	return XST_FAILURE;
}
static int IicPsFindEeprom ( u16 * Eeprom_Addr , u32 * PageSize ) { int Status ; u16 DeviceId ; int MuxIndex , Index ; u8 MuxChannel ; for ( DeviceId = 0 ; DeviceId < XPAR_XIICPS_NUM_INSTANCES ; DeviceId ++ ) { for ( MuxIndex = 0 ; MuxAddr [ MuxIndex ] != 0 ; MuxIndex ++ ) { Status = IicPsFindDevice ( MuxAddr [ MuxIndex ] , DeviceId ) ; if ( Status == XST_SUCCESS ) { for ( Index = 0 ; EepromAddr [ Index ] != 0 ; Index ++ ) { for ( MuxChannel = 0x01 ; MuxChannel <= MAX_CHANNELS ; MuxChannel = MuxChannel << 1 ) { Status = MuxInitChannel ( MuxAddr [ MuxIndex ] , MuxChannel ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " ) ; return XST_FAILURE ; } Status = FindEepromDevice ( EepromAddr [ Index ] ) ; FindEepromDevice ( MUX_ADDR ) ; if ( Status == XST_SUCCESS ) { * Eeprom_Addr = EepromAddr [ Index ] ; Status = FindEepromPageSize ( EepromAddr [ Index ] , PageSize ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \r \n " , EepromAddr [ Index ] ) ; return XST_FAILURE ; } xil_printf ( " \r \n " , * PageSize ) ; return XST_SUCCESS ; } } } } } for ( Index = 0 ; EepromAddr [ Index ] != 0 ; Index ++ ) { Status = IicPsFindDevice ( EepromAddr [ Index ] , DeviceId ) ; if ( Status == XST_SUCCESS ) { * Eeprom_Addr = EepromAddr [ Index ] ; * PageSize = PAGE_SIZE_32 ; return XST_SUCCESS ; } } } return XST_FAILURE ; }
This function is use to figure out the Eeprom slave device
This function is use to figure out the Eeprom slave device