| iicps Vitis Drivers API Documentation

- Overview
- Data Structures
- APIs
- File List
- Examples

Functions
xiicps_smbus_intr_master_example.c File Reference

## Overview

This example can run on zynqmp / versal platform evaluation board and IIC controller configured as master in interrupt-driven mode and Aardvark Analyzer used as slave.

It sends and receives the data using IIC master device for SMBus transfers.

     MODIFICATION HISTORY:

    Ver   Who Date     Changes

    1.00  gm  06/30/22 First release
    3.18  gm  07/14/23 Added SDT support.

## Functions
int | XIicPsSmbusMasterIntrExample (u16 DeviceId)
| This function does a minimal test on the Iic device and driver as a design example. More...
int | XIicPsSmbusMasterWriteBlockData (XIicPs *InstancePtr, u8 Command, u8 ByteCount, u8 *SendBufferPtr)
| This function writes a buffer of data to the smbus slave. More...
int | XIicPsSmbusMasterReadBlockData (XIicPs *InstancePtr, u8 Command, u8 ByteCount, u8 *RecvBufferPtr)
| This function sends a command and reads a buffer of data from the smbus slave. More...
void | Handler (void *CallBackRef, u32 Event)
| This function is the handler which performs processing to handle data events from the IIC. More...
int | main (void)
| Main function to call the example. More...

## Function Documentation

void Handler | ( | void * | CallBackRef,
|  | u32 | Event
| ) |  |

This function is the handler which performs processing to handle data events from the IIC.

It is called from an interrupt context such that the amount of processing performed should be minimized.

This handler provides an example of how to handle data for the IIC and is application specific.

Parameters

  CallBackRef | contains a callback reference from the driver, in this case it is the instance pointer for the IIC driver.
  Event | contains the specific kind of event that has occurred.

Returns
  None.

Note
  None.

int main | ( | void |  | ) |

Main function to call the example.

Returns
  XST_SUCCESS if successful, XST_FAILURE if unsuccessful.

Note
  None.

References XIicPsSmbusMasterIntrExample().

int XIicPsSmbusMasterIntrExample | ( | u16 | DeviceId | ) |

This function does a minimal test on the Iic device and driver as a design example.

The purpose of this function is to illustrate how to use the XIicPs driver.

This function sends and receives data as a smbus master in interrupt driver mode of the IIC.

Parameters

  DeviceId | is the Device ID of the IicPs Device and is the XPAR_<IICPS_instance>_DEVICE_ID value from xparameters.h

Returns
  XST_SUCCESS if successful, otherwise XST_FAILURE.

Note

This function contains an infinite loop such that if interrupts are not working it may never return.

References XIicPs_Config::BaseAddress, Handler(), XIicPs_BusIsBusy(), XIicPs_CfgInitialize(), XIicPs_LookupConfig(), XIicPs_MasterInterruptHandler(), XIicPs_SelfTest(), XIicPs_SetSClk(), XIicPs_SetStatusHandler(), XIicPsSmbusMasterReadBlockData(), and XIicPsSmbusMasterWriteBlockData().

Referenced by main().

int XIicPsSmbusMasterReadBlockData | ( | XIicPs * | InstancePtr,
|  | u8 | Command,
|  | u8 | ByteCount,
|  | u8 * | RecvBufferPtr
| ) |  |

This function sends a command and reads a buffer of data from the smbus slave.

Parameters

  InstancePtr | contains the address of XIicPs instance.
  Command | contains send command.
  ByteCount | contains the number of bytes to read.
  RecvBufferPtr | contains the address of receive buffer.

Returns
  XST_SUCCESS if successful else XST_FAILURE.

Note
  None

References XIicPs_Config::BaseAddress, XIicPs::Config, TotalErrorCount, XIicPs_BusIsBusy(), XIicPs_ClearOptions(), XIicPs_DisableAllInterrupts, XIICPS_ISR_OFFSET, XIicPs_MasterRecv(), XIicPs_MasterSend(), XIicPs_ReadReg, XIICPS_REP_START_OPTION, and XIicPs_SetOptions().

Referenced by XIicPsSmbusMasterIntrExample().

int XIicPsSmbusMasterWriteBlockData | ( | XIicPs * | InstancePtr,
|  | u8 | Command,
|  | u8 | ByteCount,
|  | u8 * | SendBufferPtr
| ) |  |

This function writes a buffer of data to the smbus slave.

Parameters

  InstancePtr | contains the address of XIicPs instance.
  Command | contains send command.
  ByteCount | contains the number of bytes to write.
  SendBufferPtr | contains the address of send buffer.

Returns
  XST_SUCCESS if successful else XST_FAILURE.

Note
  None

References TotalErrorCount, XIicPs_BusIsBusy(), and XIicPs_MasterSend().

Referenced by XIicPsSmbusMasterIntrExample().