![]() |
iic
Vitis Drivers API Documentation
|
Shows low-level dynamic IIC EEPROM transfers.
This file consists of a polled mode design example which uses the Xilinx IIC device in dynamic mode and low-level driver to exercise the EEPROM.
The XIic_DynSend() API is used to transmit the data and XIic_DynRecv() API is used to receive the data.
The example is tested on ML300/ML310/ML403/ML501/ML507/ML510 Xilinx boards.
The ML310/ML410/ML510/SCU35 boards have a on-board 64 Kb serial IIC EEPROM (Microchip 24LC64A). The WP pin of the IIC EEPROM is hardwired to ground on this board.
The ML300 board has an on-board 32 Kb serial IIC EEPROM(Microchip 24LC32A). The WP pin of the IIC EEPROM has to be connected to ground for this example. The WP is connected to pin Y3 of the FPGA.
The ML403 board has an on-board 4 Kb serial IIC EEPROM(Microchip 24LC04A). The WP pin of the IIC EEPROM is hardwired to ground on this board.
The ML501/ML505/ML507/ML605/SP601/SP605 boards have an on-board 8 Kb serial IIC EEPROM(STM M24C08). The WP pin of the IIC EEPROM is hardwired to ground on these boards.
The AddressType for ML300/ML310/ML410/ML510/SCU200/SCU35 boards should be u16 as the address pointer in the on board EEPROM is 2 bytes.
The AddressType for ML403/ML501/ML505/ML507/ML605/SP601/SP605 boards should be u8 as the address pointer for the on board EEPROM is 1 byte.
The 7 bit IIC Slave address of the IIC EEPROM on the ML300/ML310/ML410/ML403/ ML501/ML505/ML507/ML510/SCU200 boards is 0x50. The 7 bit IIC Slave address of the IIC EEPROM on the ML605/SP601/SP605 boards is 0x54. Refer to the User Guide's of the respective boards for further information about the IIC slave address of IIC EEPROM's.
The define EEPROM_ADDRESS in this file needs to be changed depending on the board on which this example is to be run.
This code assumes that no Operating System is being used.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a mta 03/20/06 Created. 2.00a sdm 09/22/09 Converted all register accesses to 32 bit access. 2.01a ktn 03/17/10 Updated the information about the EEPROM's used on ML605/SP601/SP605 boards. Updated the example so that it can be used to access the entire IIC EEPROM for devices like M24C04/M24C08 that use LSB bits of the IIC device select code (IIC slave address) to specify the higher address bits of the EEPROM internal address. 3.3 sk 06/18/16 checked bytes written with the input byte count and returns error if the value is not matched. 3.4 ms 01/23/17 Added xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. ms 04/05/17 Modified Comment lines in functions to recognize it as documentation block for doxygen generation. 3.10 gm 07/09/23 Added SDT support. 3.15 vlt 02/18/26 Updated comments lines for SCU200 and SCU35 EEPROM address, page size, and address type used for testing. 3.16 tb 09/22/26 Align Doxygen comments with AMD documentation standards
Macros | |
| #define | IIC_BASE_ADDRESS XPAR_AXI_IIC_0_BASEADDR |
| IIC device base address. More... | |
| #define | EEPROM_TEST_START_ADDRESS 0x80 |
| EEPROM test start address. More... | |
| #define | EEPROM_ADDRESS 0x50 |
| 7-bit IIC EEPROM slave address. More... | |
| #define | PAGE_SIZE 16 |
| EEPROM page size in bytes. More... | |
| #define | IIC_SLAVE_ADDRESS 1 |
| IIC slave address. More... | |
| #define | MAX_DELAY_CNT 10000 |
| Maximum delay count for timeout handling. More... | |
Typedefs | |
| typedef u8 | AddressType |
| Defines the EEPROM address type for the target board. More... | |
Functions | |
| int | IicLowLevelDynEeprom () |
| Reads the IIC EEPROM using the low-level IIC driver. More... | |
| u8 | EepromReadByte (u8 *BufferPtr, u8 ByteCount) |
| Reads bytes from the IIC serial EEPROM into a specified buffer. More... | |
| u8 | EepromWriteByte (u8 *BufferPtr, u8 ByteCount) |
| Writes a buffer of bytes to the IIC serial EEPROM. More... | |
| int | main (void) |
| Runs the low level Dynamic EEPROM example. More... | |
Variables | |
| u8 | WriteBuffer [PAGE_SIZE] |
| Write buffer for writing a page. More... | |
| u8 | ReadBuffer [PAGE_SIZE] |
| Read buffer for reading a page. More... | |
| #define EEPROM_ADDRESS 0x50 |
7-bit IIC EEPROM slave address.
Referenced by IicLowLevelDynEeprom().
| #define EEPROM_TEST_START_ADDRESS 0x80 |
EEPROM test start address.
Referenced by EepromReadByte(), and EepromWriteByte().
| #define IIC_BASE_ADDRESS XPAR_AXI_IIC_0_BASEADDR |
IIC device base address.
Referenced by EepromReadByte(), EepromWriteByte(), and IicLowLevelDynEeprom().
| #define IIC_SLAVE_ADDRESS 1 |
IIC slave address.
| #define MAX_DELAY_CNT 10000 |
Maximum delay count for timeout handling.
Referenced by EepromReadByte().
| #define PAGE_SIZE 16 |
EEPROM page size in bytes.
Referenced by EepromWriteByte(), and IicLowLevelDynEeprom().
| typedef u8 AddressType |
Defines the EEPROM address type for the target board.
The AddressType for ML300/ML310/ML410/ML510/SCU200/SCU35 boards should be u16 as the address pointer in the on board EEPROM is 2 bytes. The AddressType for ML403/ML501/ML505/ML507/ML605/SP601/SP605 boards should be u8 as the address pointer in the on board EEPROM is 1 bytes.
| u8 EepromReadByte | ( | u8 * | BufferPtr, |
| u8 | ByteCount | ||
| ) |
Reads bytes from the IIC serial EEPROM into a specified buffer.
This function reads a number of bytes from the IIC serial EEPROM into a specified buffer.
| [out] | BufferPtr | The address of the data buffer to be filled. |
| [in] | ByteCount | The number of bytes in the buffer to be read. This value is constrained by the page size of the device such that up to 64K may be read in one call. |
References EEPROM_TEST_START_ADDRESS, EepromIicAddr, IIC_BASE_ADDRESS, MAX_DELAY_CNT, XIic_DynRecv(), XIic_DynSend(), XIic_ReadReg, XIIC_REPEATED_START, XIIC_SR_BUS_BUSY_MASK, and XIIC_SR_REG_OFFSET.
Referenced by IicLowLevelDynEeprom(), IicLowLevelEeprom(), and ReadWriteVerify().
| u8 EepromWriteByte | ( | u8 * | BufferPtr, |
| u8 | ByteCount | ||
| ) |
Writes a buffer of bytes to the IIC serial EEPROM.
This function writes a buffer of bytes to the IIC serial EEPROM.
| [in] | BufferPtr | The address of the data to write. |
| [in] | ByteCount | The number of bytes in the buffer to be written. Note that this should not exceed the page size of the EEPROM as noted by the constant PAGE_SIZE. |
References EEPROM_TEST_START_ADDRESS, EepromIicAddr, IIC_BASE_ADDRESS, PAGE_SIZE, WriteBuffer, XIic_DynSend(), and XIIC_STOP.
Referenced by IicLowLevelDynEeprom(), and ReadWriteVerify().
| int IicLowLevelDynEeprom | ( | ) |
Reads the IIC EEPROM using the low-level IIC driver.
The function uses the low level driver of IIC to read from the IIC EEPROM on the ML300/ML310 board. The addresses tested starts from 128.
References EEPROM_ADDRESS, EepromIicAddr, EepromReadByte(), EepromWriteByte(), IIC_BASE_ADDRESS, PAGE_SIZE, ReadBuffer, WriteBuffer, XIic_DynInit(), XIic_ReadReg, XIIC_SR_BUS_BUSY_MASK, XIIC_SR_REG_OFFSET, XIIC_SR_RX_FIFO_EMPTY_MASK, and XIIC_SR_TX_FIFO_EMPTY_MASK.
Referenced by main().
| int main | ( | void | ) |
Runs the low level Dynamic EEPROM example.
Main function to call the low level Dynamic EEPROM example.
References IicLowLevelDynEeprom().
| u8 ReadBuffer[PAGE_SIZE] |
Read buffer for reading a page.
| u8 WriteBuffer[PAGE_SIZE] |
Write buffer for writing a page.