![]() |
iic
Vitis Drivers API Documentation
|
Shows IIC temperature-sensor reads.
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.
7-bit addressing is used to access the tempsensor.
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. 3.10 gm 07/09/23 Added SDT support. 3.14 bkv 07/07/25 Fixed GCC Warnings. 3.15 vlt 12/12/25 Update Doxygen comments to include SDT flow details. 3.15 vlt 02/17/26 Added timeout handling to polled wait loops. 3.16 vn 07/30/26 Fix Doxygen warnings 3.16 tb 09/22/26 Align Doxygen comments with AMD documentation standards
#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 |
| IIC base address. More... | |
| #define | TEMP_SENSOR_ADDRESS 0x18 |
| 7-bit IIC temperature sensor address. More... | |
| #define | MAX_DELAY_CNT 10000 |
| Maximum delay count for timeout handling. More... | |
Functions | |
| int | TempSensorExample (UINTPTR BaseAddress, u8 TempSensorAddress, u8 *TemperaturePtr) |
| Reads the temperature of the IIC temperature sensor. More... | |
| int | main (void) |
| Runs the IIC temperature sensor example. More... | |
Variables | |
| XIic | Iic |
| The instance of the IIC device. More... | |
| struct { | |
| } | HandlerInfo |
| Holds IIC callback status for interrupt handlers. More... | |
| #define MAX_DELAY_CNT 10000 |
Maximum delay count for timeout handling.
Referenced by TempSensorExample().
| #define TEMP_SENSOR_ADDRESS 0x18 |
7-bit IIC temperature sensor address.
Referenced by main().
| #define XIIC_BASEADDRESS XPAR_XIIC_0_BASEADDR |
IIC base address.
Referenced by main().
| int main | ( | void | ) |
Runs the IIC temperature sensor example.
The purpose of this function is to illustrate how to use the IIC driver to read the temperature.
References TEMP_SENSOR_ADDRESS, TempSensorExample(), and XIIC_BASEADDRESS.
| int TempSensorExample | ( | UINTPTR | BaseAddress, |
| u8 | TempSensorAddress, | ||
| u8 * | TemperaturePtr | ||
| ) |
Reads the temperature of the IIC temperature sensor.
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.
| [in] | BaseAddress | The base address of the device. |
| [in] | TempSensorAddress | The address of the Temperature Sensor device on the IIC bus |
| [out] | TemperaturePtr | The data byte read from the temperature sensor. |
References XIic_Config::BaseAddress, HandlerInfo, XIic_Config::IntrId, XIic_Config::IntrParent, MAX_DELAY_CNT, XII_ADDR_TO_SEND_TYPE, XIic_CfgInitialize(), XIic_InterruptHandler(), XIic_LookupConfig(), XIic_MasterRecv(), XIic_SetAddress(), XIic_SetRecvHandler(), XIic_SetStatusHandler(), and XIic_Start().
Referenced by main().
| struct { ... } HandlerInfo |
Holds IIC callback status for interrupt handlers.
The following structure contains fields that are used with the callbacks (handlers) of the IIC driver. The driver asynchronously calls handlers when abnormal events occur or when data has been sent or received. This structure must be volatile to work when the code is optimized.
Referenced by TempSensorExample().
| XIic Iic |
The instance of the IIC device.