XilinxProcessorIPLib/drivers/iicps/examples/xiicps_eeprom_intr_example.c
static int FindEepromPageSize(u16 EepromAddr, u32 *PageSize_ptr)
{
	u32 Index, i;
	int Status = XST_FAILURE;
	AddressType Address = EEPROM_START_ADDRESS;
	int WrBfrOffset = 0;
	u32 ps[3] = {64, 32, 16};
	u32 PageSize_test, count;

	for (i = 0; i < 3; i++)
	{
		count = 0;
		PageSize_test = ps[i];
		*PageSize_ptr = PageSize_test;
		/*
		 * Initialize the data to write and the read buffer.
		 */
		if (PageSize_test == PAGE_SIZE_16) {
			WriteBuffer[0] = (u8) (Address);
			WrBfrOffset = 1;
		} else {
			WriteBuffer[0] = (u8) (Address >> 8);
			WriteBuffer[1] = (u8) (Address);
			WrBfrOffset = 2;
		}

		for (Index = 0; Index < PageSize_test; Index++) {
			WriteBuffer[WrBfrOffset + Index] = Index + i;
			ReadBuffer[Index] = 0;
		}

		/*
		 * Write to the EEPROM.
		 */
		Status = EepromWriteData(&IicInstance, WrBfrOffset + PageSize_test);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}

		/*
		 * Read from the EEPROM.
		 */
		Status = EepromReadData(&IicInstance, ReadBuffer, PageSize_test);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}

		/*
		 * Verify the data read against the data written.
		 */
		for (Index = 0; Index < PageSize_test; Index++) {
			if (ReadBuffer[Index] == Index + i) {
				count++;
			}
		}
		if (count == PageSize_test)
		{
			return XST_SUCCESS;
		}
	}
	return Status;
}
/*****************************************************************************/
/**
* This function is used to figure out page size Eeprom slave device
*
* @param	Eeprom Address
*
* @param	Pagesize pointer
*
* @return	XST_SUCCESS if successful and also update the epprom slave
* device pagesize else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function is used to figure out page size Eeprom slave device
This function is used to figure out page size Eeprom slave device
static int FindEepromPageSize(u16 EepromAddr, u32 *PageSize_ptr)
{
	u32 Index, i;
	int Status = XST_FAILURE;
	AddressType Address = EEPROM_START_ADDRESS;
	int WrBfrOffset = 0;
	u32 ps[3] = {64, 32, 16};
	u32 PageSize_test, count;
	for (i = 0; i < 3; i++)
	{
		count = 0;
		PageSize_test = ps[i];
		*PageSize_ptr = PageSize_test;
		if (PageSize_test == PAGE_SIZE_16) {
			WriteBuffer[0] = (u8) (Address);
			WrBfrOffset = 1;
		} else {
			WriteBuffer[0] = (u8) (Address >> 8);
			WriteBuffer[1] = (u8) (Address);
			WrBfrOffset = 2;
		}
		for (Index = 0; Index < PageSize_test; Index++) {
			WriteBuffer[WrBfrOffset + Index] = Index + i;
			ReadBuffer[Index] = 0;
		}
		Status = EepromWriteData(&IicInstance, WrBfrOffset + PageSize_test);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}
		Status = EepromReadData(&IicInstance, ReadBuffer, PageSize_test);
		if (Status != XST_SUCCESS) {
			return XST_FAILURE;
		}
		for (Index = 0; Index < PageSize_test; Index++) {
			if (ReadBuffer[Index] == Index + i) {
				count++;
			}
		}
		if (count == PageSize_test)
		{
			return XST_SUCCESS;
		}
	}
	return Status;
}
static int FindEepromPageSize ( u16 EepromAddr , u32 * PageSize_ptr ) { u32 Index , i ; int Status = XST_FAILURE ; AddressType Address = EEPROM_START_ADDRESS ; int WrBfrOffset = 0 ; u32 ps [ 3 ] = { 64 , 32 , 16 } ; u32 PageSize_test , count ; for ( i = 0 ; i < 3 ; i ++ ) { count = 0 ; PageSize_test = ps [ i ] ; * PageSize_ptr = PageSize_test ; if ( PageSize_test == PAGE_SIZE_16 ) { WriteBuffer [ 0 ] = ( u8 ) ( Address ) ; WrBfrOffset = 1 ; } else { WriteBuffer [ 0 ] = ( u8 ) ( Address >> 8 ) ; WriteBuffer [ 1 ] = ( u8 ) ( Address ) ; WrBfrOffset = 2 ; } for ( Index = 0 ; Index < PageSize_test ; Index ++ ) { WriteBuffer [ WrBfrOffset + Index ] = Index + i ; ReadBuffer [ Index ] = 0 ; } Status = EepromWriteData ( & IicInstance , WrBfrOffset + PageSize_test ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = EepromReadData ( & IicInstance , ReadBuffer , PageSize_test ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } for ( Index = 0 ; Index < PageSize_test ; Index ++ ) { if ( ReadBuffer [ Index ] == Index + i ) { count ++ ; } } if ( count == PageSize_test ) { return XST_SUCCESS ; } } return Status ; }
This function is used to figure out page size Eeprom slave device
This function is used to figure out page size Eeprom slave device
/*
		 * Initialize the data to write and the read buffer.
		 */ /*
		 * Write to the EEPROM.
		 */ /*
		 * Read from the EEPROM.
		 */ /*
		 * Verify the data read against the data written.
		 */