XilinxProcessorIPLib/drivers/iicps/examples/xiicps_eeprom_intr_example.c
int IicPsEepromIntrExample(void)
{
	u32 Index;
	int Status;
	AddressType Address = EEPROM_START_ADDRESS;
	int WrBfrOffset;


	Status = IicPsFindEeprom(&EepromSlvAddr,&PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	/*
	 * Initialize the data to write and the read buffer.
	 */
	if (PageSize == 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; Index++) {
		WriteBuffer[WrBfrOffset + Index] = 0xFF;
		ReadBuffer[Index] = 0;
	}

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

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

	/*
	 * Verify the data read against the data written.
	 */
	for (Index = 0; Index < PageSize; Index++) {
		if (ReadBuffer[Index] != WriteBuffer[Index + WrBfrOffset]) {
			return XST_FAILURE;
		}
	}

	/*
	 * Initialize the data to write and the read buffer.
	 */
	if (PageSize == 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; Index++) {
		WriteBuffer[WrBfrOffset + Index] = Index + 10;
		ReadBuffer[Index] = 0;
	}

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

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

	/*
	 * Verify the data read against the data written.
	 */
	for (Index = 0; Index < PageSize; Index++) {
		if (ReadBuffer[Index] != WriteBuffer[Index + WrBfrOffset]) {
			return XST_FAILURE;
		}
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
* This function writes, reads, and verifies the data to the IIC EEPROM. It
* does the write as a single page write, performs a buffered read.
*
*
* @return	XST_SUCCESS if successful else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function writes, reads, and verifies the data to the IIC EEPROM. It
does the write as a single page write, performs a buffered read.
This function writes reads and verifies the data to the IIC EEPROM . It does the write as a single page write performs a buffered read .
int IicPsEepromIntrExample(void)
{
	u32 Index;
	int Status;
	AddressType Address = EEPROM_START_ADDRESS;
	int WrBfrOffset;
	Status = IicPsFindEeprom(&EepromSlvAddr,&PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	if (PageSize == 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; Index++) {
		WriteBuffer[WrBfrOffset + Index] = 0xFF;
		ReadBuffer[Index] = 0;
	}
	Status = EepromWriteData(&IicInstance, WrBfrOffset + PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = EepromReadData(&IicInstance, ReadBuffer, PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	for (Index = 0; Index < PageSize; Index++) {
		if (ReadBuffer[Index] != WriteBuffer[Index + WrBfrOffset]) {
			return XST_FAILURE;
		}
	}
	if (PageSize == 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; Index++) {
		WriteBuffer[WrBfrOffset + Index] = Index + 10;
		ReadBuffer[Index] = 0;
	}
	Status = EepromWriteData(&IicInstance, WrBfrOffset + PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = EepromReadData(&IicInstance, ReadBuffer, PageSize);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	for (Index = 0; Index < PageSize; Index++) {
		if (ReadBuffer[Index] != WriteBuffer[Index + WrBfrOffset]) {
			return XST_FAILURE;
		}
	}
	return XST_SUCCESS;
}
int IicPsEepromIntrExample ( void ) { u32 Index ; int Status ; AddressType Address = EEPROM_START_ADDRESS ; int WrBfrOffset ; Status = IicPsFindEeprom ( & EepromSlvAddr , & PageSize ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } if ( PageSize == 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 ; Index ++ ) { WriteBuffer [ WrBfrOffset + Index ] = 0xFF ; ReadBuffer [ Index ] = 0 ; } Status = EepromWriteData ( & IicInstance , WrBfrOffset + PageSize ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = EepromReadData ( & IicInstance , ReadBuffer , PageSize ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } for ( Index = 0 ; Index < PageSize ; Index ++ ) { if ( ReadBuffer [ Index ] != WriteBuffer [ Index + WrBfrOffset ] ) { return XST_FAILURE ; } } if ( PageSize == 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 ; Index ++ ) { WriteBuffer [ WrBfrOffset + Index ] = Index + 10 ; ReadBuffer [ Index ] = 0 ; } Status = EepromWriteData ( & IicInstance , WrBfrOffset + PageSize ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = EepromReadData ( & IicInstance , ReadBuffer , PageSize ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } for ( Index = 0 ; Index < PageSize ; Index ++ ) { if ( ReadBuffer [ Index ] != WriteBuffer [ Index + WrBfrOffset ] ) { return XST_FAILURE ; } } return XST_SUCCESS ; }
This function writes, reads, and verifies the data to the IIC EEPROM.
This function writes reads and verifies the data to the IIC EEPROM .
/*
	 * 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.
	 */ /*
	 * 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.
	 */