iicps
Vitis Drivers API Documentation
xiicps_repeated_start_example.c File Reference

Overview

This is a repeated start example runs on zynqmp / versal evaluation boards using xiicps driver in polled mode.

The slave used is an EEPROM.

The example is tested with a 2Kb/8Kb serial IIC EEPROM (ST M24C02/M24C08). The WP pin of this EEPROM is hardwired to ground in the HW in which this was tested. This example can be used directly to read up to 16 pages from start address in this EEPROM (Since single address byte).

The AddressType should be u8 as the address pointer in the on-board EEPROM is 1 bytes.

This code assumes that no Operating System is being used.

Note

The I2C controller does not indicate completion of a receive transfer if HOLD bit is set. Due to this errata, repeated start cannot be used if a receive transfer is followed by any other transfer on Zynq platform.

MODIFICATION HISTORY:
Ver   Who  Date     Changes


2.1 hk 03/15/10 First release 3.7 ask 04/17/18 Updated the Eeprom scanning mechanism as per the other examples (CR#997545) 3.11 rna 10/16/19 Added support for 64 page size eeproms on Veral based boards, scanning for eeprom on all I2C instances rna 03/26/20 Eeprom page size detection support is added. 3.18 gm 07/14/23 Added SDT support.

 

Functions

int IicPsRepeatedStartExample (void)
 This function writes, reads, and verifies the data to the IIC EEPROM. More...
 
int EepromWriteData (u16 ByteCount)
 This function writes a buffer of data to the IIC serial EEPROM. More...
 
int EepromReadDataRepStart (u8 *BufferPtr, u16 ByteCount)
 This function reads data from the IIC serial EEPROM into a specified buffer. More...
 
int main (void)
 Main function to call the Iic repeated start example. More...
 

Function Documentation

int EepromReadDataRepStart ( u8 *  BufferPtr,
u16  ByteCount 
)

This function reads data from the IIC serial EEPROM into a specified buffer.

Parameters
BufferPtrcontains the address of the data buffer to be filled.
ByteCountcontains the number of bytes in the buffer to be read.
Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
None.

References EepromWriteData(), XIicPs_BusIsBusy(), XIicPs_ClearOptions(), XIicPs_MasterRecvPolled(), XIICPS_REP_START_OPTION, and XIicPs_SetOptions().

Referenced by IicPsRepeatedStartExample().

int EepromWriteData ( u16  ByteCount)

This function writes a buffer of data to the IIC serial EEPROM.

Parameters
ByteCountcontains the number of bytes in the buffer to be written.
Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
The Byte count should not exceed the page size of the EEPROM as noted by the constant PAGE_SIZE.

References XIicPs::IsRepeatedStart, XIicPs_BusIsBusy(), and XIicPs_MasterSendPolled().

Referenced by EepromReadDataRepStart(), IicPsEepromIntrExample(), IicPsEepromPolledExample(), and IicPsRepeatedStartExample().

int IicPsRepeatedStartExample ( void  )

This function writes, reads, and verifies the data to the IIC EEPROM.

Page write is used. Buffered read with repeated start option is done.

Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
None.

References XIicPs_Config::BaseAddress, EepromReadDataRepStart(), EepromWriteData(), XIicPs_CfgInitialize(), XIicPs_LookupConfig(), and XIicPs_SetSClk().

Referenced by main().

int main ( void  )

Main function to call the Iic repeated start example.

Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
None.

References IicPsRepeatedStartExample().