![]() |
iic
Vitis Drivers API Documentation
|
Shows IIC dynamic-mode EEPROM transfers.
This file consists of a Interrupt mode design example which uses the Xilinx IIC device and XIic driver to exercise the EEPROM in Dynamic controller mode. The XIic driver uses the complete FIFO functionality to transmit/receive data.
This example writes/reads from the lower 256 bytes of the IIC EEPROMS. refer to the datasheets of the IIC EEPROM's for details about the internal addressing and page size of these devices.
The XIic_DynMasterSend() API is used to transmit the data and XIic_DynMasterRecv() API is used to receive the data.
This example is tested on ML300/ML310/ML403/ML501/ML507/ML510/ML605/SP601 and SP605 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/ML403/ML410/ 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 04/13/06 Created. 2.00a ktn 11/17/09 Updated to use the HAL APIs. 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.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. 3.10 gm 07/09/23 Added SDT support 3.15 vlt 02/11/26 Updated comment 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
#include "xparameters.h"#include "xiic.h"#include "xil_sutil.h"#include "xil_exception.h"#include "xil_printf.h"#include "xinterrupt_wrap.h"Macros | |
| #define | XIIC_BASEADDRESS XPAR_XIIC_0_BASEADDR |
| IIC base address. More... | |
| #define | EEPROM_ADDRESS 0x54 |
| 7-bit IIC EEPROM slave address. More... | |
| #define | PAGE_SIZE 16 |
| EEPROM page size in bytes. More... | |
| #define | EEPROM_TEST_START_ADDRESS 128 |
| EEPROM test start address. More... | |
| #define | MAX_DELAY_CNT 10000 |
| Maximum delay count for timeout handling. More... | |
| #define | EventMask 0xFF |
| Internal IIC event mask. More... | |
| #define | Event_Value 0 |
| Internal event value for IIC event checking. More... | |
Typedefs | |
| typedef u8 | AddressType |
| Defines the EEPROM address type for the target board. More... | |
Functions | |
| int | IicDynEepromExample (void) |
| Writes, reads, and verifies data on the IIC EEPROM in dynamic mode. More... | |
| int | DynEepromWriteData (u16 ByteCount) |
| Writes a buffer of data to the IIC serial EEPROM. More... | |
| int | DynEepromReadData (u8 *BufferPtr, u16 ByteCount) |
| Reads data from the IIC serial EEPROM into a specified buffer. More... | |
| int | main (void) |
| Runs the Dynamic EEPROM example. More... | |
Variables | |
| XIic | IicInstance |
| The instance of the IIC device. More... | |
| u8 | WriteBuffer [sizeof(AddressType)+PAGE_SIZE] |
| Holds the data for writing a page. More... | |
| u8 | ReadBuffer [PAGE_SIZE] |
| Read buffer for reading a page. More... | |
| volatile u8 | TransmitComplete |
| Flag to check completion of Transmission. More... | |
| volatile u8 | ReceiveComplete |
| Flag to check completion of Reception. More... | |
| u8 | EepromIicAddr |
| Variable for storing Eeprom IIC address. More... | |
| #define EEPROM_ADDRESS 0x54 |
7-bit IIC EEPROM slave address.
Referenced by IicDynEepromExample().
| #define EEPROM_TEST_START_ADDRESS 128 |
EEPROM test start address.
Referenced by DynEepromReadData(), and IicDynEepromExample().
| #define Event_Value 0 |
Internal event value for IIC event checking.
Referenced by DynEepromReadData().
| #define EventMask 0xFF |
Internal IIC event mask.
Referenced by DynEepromReadData().
| #define MAX_DELAY_CNT 10000 |
Maximum delay count for timeout handling.
Referenced by DynEepromReadData(), and DynEepromWriteData().
| #define PAGE_SIZE 16 |
EEPROM page size in bytes.
Referenced by IicDynEepromExample().
| #define XIIC_BASEADDRESS XPAR_XIIC_0_BASEADDR |
IIC base address.
Referenced by IicDynEepromExample().
| 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.
| int DynEepromReadData | ( | u8 * | BufferPtr, |
| u16 | ByteCount | ||
| ) |
Reads data from the IIC serial EEPROM into a specified buffer.
This function reads data 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. |
References DynEepromWriteData(), EEPROM_TEST_START_ADDRESS, Event_Value, EventMask, MAX_DELAY_CNT, ReceiveComplete, XIic_DynMasterRecv(), XIic_Start(), and XIic_Stop().
Referenced by IicDynEepromExample().
| int DynEepromWriteData | ( | u16 | ByteCount | ) |
Writes a buffer of data to the IIC serial EEPROM.
This function writes a buffer of data to the IIC serial EEPROM.
| [in] | ByteCount | The number of bytes in the buffer to be written. |
References MAX_DELAY_CNT, XIic::Stats, TransmitComplete, XIicStats::TxErrors, WriteBuffer, XIic_DynMasterSend(), XIic_MasterSend(), XIic_Start(), and XIic_Stop().
Referenced by DynEepromReadData(), and IicDynEepromExample().
| int IicDynEepromExample | ( | void | ) |
Writes, reads, and verifies data on the IIC EEPROM in dynamic mode.
This function writes, reads, and verifies the data to the IIC EEPROM in Dynamic controller mode. It does the write as a single page write, performs a buffered read.
Pointer to configuration data
References XIic_Config::BaseAddress, DynEepromReadData(), DynEepromWriteData(), EEPROM_ADDRESS, EEPROM_TEST_START_ADDRESS, EepromIicAddr, XIic_Config::IntrId, XIic_Config::IntrParent, PAGE_SIZE, ReadBuffer, WriteBuffer, XII_ADDR_TO_SEND_TYPE, XIIC_BASEADDRESS, XIic_CfgInitialize(), XIic_DynamicInitialize(), XIic_InterruptHandler(), XIic_LookupConfig(), XIic_SetAddress(), XIic_SetRecvHandler(), XIic_SetSendHandler(), and XIic_SetStatusHandler().
Referenced by main().
| int main | ( | void | ) |
Runs the Dynamic EEPROM example.
Main function to call the Dynamic EEPROM example.
References IicDynEepromExample().
| u8 EepromIicAddr |
Variable for storing Eeprom IIC address.
Referenced by EepromReadByte(), EepromWriteByte(), IicDynEepromExample(), IicEepromExample(), IicLowLevelDynEeprom(), and IicLowLevelEeprom().
| XIic IicInstance |
The instance of the IIC device.
| u8 ReadBuffer[PAGE_SIZE] |
Read buffer for reading a page.
Referenced by IicDynEepromExample(), IicEepromExample(), IicLowLevelDynEeprom(), IicPmbusInterruptSdtExample(), IicPmbusPolledExample(), IicRepeatedStartExample(), IicSlaveExample(), IicTenBitAddrExample(), ReadWriteVerify(), SlaveReadData(), and TenBitAddrReadData().
| volatile u8 ReceiveComplete |
Flag to check completion of Reception.
Referenced by DynEepromReadData(), EepromReadData(), SlaveReadData(), and TenBitAddrReadData().
| volatile u8 TransmitComplete |
Flag to check completion of Transmission.
Referenced by DynEepromWriteData(), EepromWriteData(), IicMultiMasterExample(), SlaveWriteData(), and TenBitAddrWriteData().
| u8 WriteBuffer[sizeof(AddressType)+PAGE_SIZE] |
Holds the data for writing a page.
Referenced by DynEepromWriteData(), EepromReadData(), EepromWriteByte(), EepromWriteData(), IicDynEepromExample(), IicEepromExample(), IicLowLevelDynEeprom(), IicMultiMasterExample(), IicRepeatedStartExample(), IicSlaveExample(), IicTenBitAddrExample(), ReadWriteVerify(), SlaveWriteData(), and TenBitAddrWriteData().