iic
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
xiic_repeated_start_example.c File Reference

Overview

This file consists of a interrupt mode design example to demonstrate the use of repeated start using the XIic driver.

The XIic_MasterSend() API is used to transmit the data and XIic_MasterRecv() API is used to receive the data.

The IIC devices that are present on the Xilinx boards do not support the repeated start option. These examples have been tested with an IIC device external to the boards.

This code assumes that no Operating System is being used.

Note

None.

MODIFICATION HISTORY:
Ver   Who  Date  Changes


1.00a mta 02/20/06 Created. 2.00a sdm 09/22/09 Updated to use the HAL APIs, replaced call to XIic_Initialize API with XIic_LookupConfig and XIic_CfgInitialize. Updated the example with a fix for CR539763 where XIic_Start was being called instead of XIic_Stop. Added code for setting up the StatusHandler callback. 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 01/27/26 Fixed codespell issues 3.15 vlt 02/17/26 Added timeout handling to polled wait loops.

 
#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
 The following constants map to the XPAR parameters created in the xparameters.h file. More...
 
#define SLAVE_ADDRESS   0x70 /* 0xE0 as an 8 bit number. */
 The following constant defines the address of the IIC device on the IIC bus. More...
 
#define MAX_DELAY_CNT   10000
 Maximum delay count used for timeout handling. More...
 
#define EventMask   0xFF
 IIC event mask. More...
 
#define Event_Value   0
 Internal event value used for IIC event checking. More...
 

Functions

int IicRepeatedStartExample (void)
 This function writes and reads the data to the IIC Slave. More...
 
int main (void)
 Flag to check completion of Reception. More...
 

Variables

u8 WriteBuffer [SEND_COUNT]
 The instance of the IIC device. More...
 
u8 ReadBuffer [RECEIVE_COUNT]
 Write buffer for writing a page. More...
 
volatile u8 TransmitComplete
 Read buffer for reading a page. More...
 
volatile u8 ReceiveComplete
 Flag to check completion of Transmission. More...
 

Macro Definition Documentation

#define Event_Value   0

Internal event value used for IIC event checking.

#define EventMask   0xFF

IIC event mask.

#define MAX_DELAY_CNT   10000

Maximum delay count used for timeout handling.

#define SLAVE_ADDRESS   0x70 /* 0xE0 as an 8 bit number. */

The following constant defines the address of the IIC device on the IIC bus.

Note that since the address is only 7 bits, this constant is the address divided by 2.

Referenced by IicRepeatedStartExample().

#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 IicRepeatedStartExample().

Function Documentation

int IicRepeatedStartExample ( void  )
int main ( void  )

Flag to check completion of Reception.

Main function to call the Repeated Start example.

Returns
XST_SUCCESS if successful else XST_FAILURE.
Note
None.

References IicRepeatedStartExample().

Variable Documentation

u8 ReadBuffer[RECEIVE_COUNT]

Write buffer for writing a page.

volatile u8 ReceiveComplete

Flag to check completion of Transmission.

volatile u8 TransmitComplete

Read buffer for reading a page.

u8 WriteBuffer[SEND_COUNT]

The instance of the IIC device.