![]() |
iic
Vitis Drivers API Documentation
|
This file consists of a Interrupt mode design example which uses the Xilinx IIC device and XIic driver to exercise the EEPROM on the Xilinx boards in a Multi master mode.
This example has been tested with an off-board external IIC Master connected on the IIC bus.
This example writes/reads from the lower 256 bytes of the IIC EEPROMS. Please refer to the datasheets of the IIC EEPROM's for details about the internal addressing and page size of these devices.
The XIic_MasterSend() API is used to transmit the data and XIic_MasterRecv() API is used to receive the data.
The example is tested on ML300/ML310/ML403/ML501 Xilinx boards.
The ML310/ML410/ML510 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 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 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.
None.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00a mta 03/01/06 Created. 2.00a sdm 09/22/09 Converted all register accesses to 32 bit access. Updated to use the HAL APIs, replaced call to XIic_Initialize API with XIic_LookupConfig and XIic_CfgInitialize. 2.01a ktn 03/17/10 Updated the information about the EEPROM's used on ML605/SP601/SP605 boards. 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/17/26 Added timeout handling to polled wait loops.
#include "xparameters.h"#include "xiic.h"#include "xil_exception.h"#include "xil_printf.h"#include "xinterrupt_wrap.h"Macros | |
| #define | XIIC_BASEADDRESS XPAR_XIIC_0_BASEADDR |
| The following constants map to the XPAR parameters created in the xparameters.h file. More... | |
| #define | EEPROM_ADDRESS 0x50 /* 0xA0 as an 8 bit number. */ |
| The following constant defines the address of the IIC Slave device on the IIC bus. More... | |
| #define | PAGE_SIZE 16 |
| The page size determines how much data should be written at a time. More... | |
| #define | EEPROM_TEST_START_ADDRESS 128 |
| The Starting address in the IIC EEPROM on which this test is performed. More... | |
| #define | MAX_DELAY_CNT 10000 |
| Maximum delay count used for timeout handling. More... | |
Typedefs | |
| typedef u8 | AddressType |
| The AddressType for ML300/ML310/ML410/ML510 boards should be u16 as the address pointer in the on board EEPROM is 2 bytes. More... | |
Functions | |
| int | IicMultiMasterExample (void) |
| This function writes the data to the IIC EEPROM. More... | |
| int | main (void) |
| IIC bus idle flag. More... | |
Variables | |
| u8 | WriteBuffer [sizeof(AddressType)+PAGE_SIZE] |
| The instance of the IIC device. More... | |
| volatile u8 | ReceiveComplete |
| Transmit completion flag. More... | |
| volatile u8 | BusNotBusy |
| Receive completion flag. More... | |
| #define EEPROM_ADDRESS 0x50 /* 0xA0 as an 8 bit number. */ |
The following constant defines the address of the IIC Slave device on the IIC bus.
Note that since the address is only 7 bits, this constant is the address divided by 2. The 7 bit IIC Slave address of the IIC EEPROM on the ML300/ML310/ML403/ML501/ ML410/ML505/ML507/ML510 boards is 0x50. The 7 bit IIC Slave address of the IIC EEPROM on the ML605/SP601/SP605 boards is 0x54. Please refer the User Guide's of the respective boards for further information about the IIC slave address of IIC EEPROM's.
Referenced by IicMultiMasterExample().
| #define EEPROM_TEST_START_ADDRESS 128 |
The Starting address in the IIC EEPROM on which this test is performed.
Referenced by IicMultiMasterExample().
| #define MAX_DELAY_CNT 10000 |
Maximum delay count used for timeout handling.
Referenced by IicMultiMasterExample().
| #define PAGE_SIZE 16 |
The page size determines how much data should be written at a time.
The ML300 board supports a page size of 32 and 16. The write function should be called with this as a maximum byte count.
Referenced by IicMultiMasterExample().
| #define XIIC_BASEADDRESS XPAR_XIIC_0_BASEADDR |
The following constants map to the XPAR parameters created in the xparameters.h file.
They are defined here such that a user can easily change all the needed parameters in one place.
Referenced by IicMultiMasterExample().
| typedef u8 AddressType |
The AddressType for ML300/ML310/ML410/ML510 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 IicMultiMasterExample | ( | void | ) |
This function writes the data to the IIC EEPROM.
References XIic_Config::BaseAddress, BusNotBusy, EEPROM_ADDRESS, EEPROM_TEST_START_ADDRESS, XIic_Config::IntrId, XIic_Config::IntrParent, MAX_DELAY_CNT, PAGE_SIZE, XIic::Stats, TransmitComplete, XIicStats::TxErrors, WriteBuffer, XII_ADDR_TO_SEND_TYPE, XIIC_BASEADDRESS, XIic_CfgInitialize(), XIic_InterruptHandler(), XIic_LookupConfig(), XIic_MasterSend(), XIic_MultiMasterInclude(), XIic_SetAddress(), XIic_SetSendHandler(), XIic_SetStatusHandler(), XIic_Start(), and XIic_Stop().
Referenced by main().
| int main | ( | void | ) |
IIC bus idle flag.
Main function to call the Multi Master example.
References IicMultiMasterExample().
| volatile u8 BusNotBusy |
Receive completion flag.
Referenced by IicMultiMasterExample().
| volatile u8 ReceiveComplete |
Transmit completion flag.
| u8 WriteBuffer[sizeof(AddressType)+PAGE_SIZE] |
The instance of the IIC device.
Write buffer for writing a page.