iic: xiic_tempsensor_example.c File Reference

| iic Xilinx SDK Drivers API Documentation

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

Functions
xiic_tempsensor_example.c File Reference

## Overview

This file contains an interrupt based design example which uses the Xilinx IIC device and driver to exercise the temperature sensor on the ML300 board.

This example only performs read operations (receive) from the IIC temperature sensor of the platform.

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

This example assumes that there is an interrupt controller in the hardware system and the IIC device is connected to the interrupt controller.

Note

7-bit addressing is used to access the tempsensor.

None

    MODIFICATION HISTORY:

    Ver   Who  Date  Changes

    1.00a jhl  09/10/03 Created
    1.00a sv   05/09/05 Minor changes to comply to Doxygen and coding guidelines
    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.

## Functions
int | TempSensorExample (u16 IicDeviceId, u8 TempSensorAddress, u8 *TemperaturePtr)
| The function reads the temperature of the IIC temperature sensor on the IIC bus. More...
int | main (void)
| The purpose of this function is to illustrate how to use the IIC driver to read the temperature. More...

## Function Documentation

int main | ( | void |  | ) |

The purpose of this function is to illustrate how to use the IIC driver to read the temperature.

Parameters

  None |

Returns
  XST_SUCCESS if successful, XST_FAILURE if unsuccessful

Note
  None

References TempSensorExample().

int TempSensorExample | ( | u16 | IicDeviceId,
|  | u8 | TempSensorAddress,
|  | u8 * | TemperaturePtr
| ) |  |

The function reads the temperature of the IIC temperature sensor on the IIC bus.

It initializes the IIC device driver and sets it up to communicate with the temperature sensor. This function does contain a loop that polls for completion of the IIC processing such that it may not return if interrupts or the hardware are not working.

Parameters

  IicDeviceId | is the XPAR_<IIC_instance>_DEVICE_ID value from xparameters.h for the IIC Device
  TempSensorAddress | is the address of the Temperature Sensor device on the IIC bus
  TemperaturePtr | is the data byte read from the temperature sensor

Returns
  XST_SUCCESS to indicate success, else XST_FAILURE to indicate a Failure.

Note
  None.

References XIic_Config::BaseAddress, XII_ADDR_TO_SEND_TYPE, XIic_CfgInitialize(), XIic_LookupConfig(), XIic_MasterRecv(), XIic_SetAddress(), XIic_SetRecvHandler(), XIic_SetStatusHandler(), and XIic_Start().

Referenced by main().