![]() |
iic
Vitis Drivers API Documentation
|
Defines IIC low-level register offsets and access macros.
This header file contains identifiers and driver functions (or macros) that can be used to access the device in normal and dynamic controller mode. High-level driver functions are defined in xiic.h.
MODIFICATION HISTORY:
Ver Who Date Changes
1.00b jhl 05/07/02 First release 1.01c ecm 12/05/02 new rev 1.01d jhl 10/08/03 Added general purpose output feature 1.02a mta 03/09/06 Implemented Repeated Start in the Low Level Driver. 1.03a mta 04/04/06 Implemented Dynamic IIC core routines. 1.03a rpm 09/08/06 Added include of xstatus.h for completeness 1.13a wgr 03/22/07 Converted to new coding style. 1.16a ktn 07/18/09 Updated the notes in XIIC_RESET macro to clearly indicate that only the Interrupt Registers are reset. 1.16a ktn 10/16/09 Updated the notes in the XIIC_RESET macro to mention that the complete IIC core is Reset on giving a software reset to the IIC core. Some previous versions of the core only reset the Interrupt Logic/Registers, please refer to the HW specification for further details. 2.00a sdm 10/22/09 Converted all register accesses to 32 bit access, the register offsets are defined to be on 32 bit boundary. Removed the macro XIIC_RESET, XIic_Reset API should be used in its place. Some of the macros have been renamed to be consistent - XIIC_GINTR_DISABLE is renamed as XIic_IntrGlobalDisable, XIIC_GINTR_ENABLE is renamed as XIic_IntrGlobalEnable, XIIC_IS_GINTR_ENABLED is renamed as XIic_IsIntrGlobalEnabled, XIIC_WRITE_IISR is renamed as XIic_WriteIisr, XIIC_READ_IISR is renamed as XIic_ReadIisr, XIIC_WRITE_IIER is renamed as XIic_WriteIier The _m prefix in the name of the macros has been removed - XIic_mClearIisr is now XIic_ClearIisr, XIic_mSend7BitAddress is now XIic_Send7BitAddress, XIic_mDynSend7BitAddress is now XIic_DynSend7BitAddress, XIic_mDynSendStartStopAddress is now XIic_DynSendStartStopAddress, XIic_mDynSendStop is now XIic_DynSendStop. 3.2 sk 11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425. Changed the prototypes of XIic_Recv, XIic_Send, XIic_DynRecv, XIic_DynSend and XIic_DynInit APIs. 3.3 als 06/27/16 Added Low-level XIic_CheckIsBusBusy API. 3.3 als 06/27/16 Added low-level XIic_WaitBusFree API. 3.15 vlt 12/05/25 Add timing register offsets for clock configuration. vlt 01/27/26 Fixed codespell issues 3.16 vn 07/30/26 Fix Doxygen warnings 3.16 tb 09/22/26 Align Doxygen comments with AMD documentation standards
#include "xil_types.h"#include "xil_assert.h"#include "xstatus.h"#include "xil_io.h"Macros | |
| #define | XIIC_TX_ADDR_SENT 0x00 |
| TX address sent. More... | |
| #define | XIIC_TX_ADDR_MSTR_RECV_MASK 0x02 |
| TX ADDR MSTR RECV bit mask. More... | |
| #define | XIIC_READ_OPERATION 1 |
| Read operation on the IIC bus. More... | |
| #define | XIIC_WRITE_OPERATION 0 |
| Write operation on the IIC bus. More... | |
| #define | XIIC_MASTER_ROLE 1 |
| Master on the IIC bus. More... | |
| #define | XIIC_SLAVE_ROLE 0 |
| Slave on the IIC bus. More... | |
| #define | XIIC_STOP 0x00 |
| Send a stop on the IIC bus after the current data transfer. More... | |
| #define | XIIC_REPEATED_START 0x01 |
| Do not send a stop on the IIC bus after the current transfer. More... | |
| #define | XIic_In32 Xil_In32 |
| 32-bit register read function. More... | |
| #define | XIic_Out32 Xil_Out32 |
| 32-bit register write function. More... | |
| #define | XIic_ReadReg(BaseAddress, RegOffset) XIic_In32((BaseAddress) + (RegOffset)) |
| Reads from the specified IIC device register. More... | |
| #define | XIic_WriteReg(BaseAddress, RegOffset, RegisterValue) XIic_Out32((BaseAddress) + (RegOffset), (RegisterValue)) |
| Writes to the specified IIC device register. More... | |
| #define | XIic_IntrGlobalDisable(BaseAddress) XIic_WriteReg((BaseAddress), XIIC_DGIER_OFFSET, 0) |
| Disables all interrupts for the device at the global level. More... | |
| #define | XIic_IntrGlobalEnable(BaseAddress) |
| Enables interrupts from the device at the global level. More... | |
| #define | XIic_IsIntrGlobalEnabled(BaseAddress) |
| Determines if interrupts are enabled at the global level. More... | |
| #define | XIic_WriteIisr(BaseAddress, Status) XIic_WriteReg((BaseAddress), XIIC_IISR_OFFSET, (Status)) |
| Sets the Interrupt status register to the specified value. More... | |
| #define | XIic_ReadIisr(BaseAddress) XIic_ReadReg((BaseAddress), XIIC_IISR_OFFSET) |
| Gets the contents of the Interrupt Status Register. More... | |
| #define | XIic_WriteIier(BaseAddress, Enable) XIic_WriteReg((BaseAddress), XIIC_IIER_OFFSET, (Enable)) |
| Sets the contents of the Interrupt Enable Register. More... | |
| #define | XIic_ReadIier(BaseAddress) XIic_ReadReg((BaseAddress), XIIC_IIER_OFFSET) |
| Gets the Interrupt Enable Register contents. More... | |
| #define | XIic_ClearIisr(BaseAddress, InterruptMask) |
| Clears the specified interrupt in the Interrupt Status register. More... | |
| #define | XIic_Send7BitAddress(BaseAddress, SlaveAddress, Operation) |
| Sends a 7-bit address for reads and writes. More... | |
| #define | XIic_DynSend7BitAddress(BaseAddress, SlaveAddress, Operation) |
| Sends a 7-bit address for reads and writes. More... | |
| #define | XIic_DynSendStartStopAddress(BaseAddress, SlaveAddress, Operation) |
| Sends the address, start, and stop for a 7-bit address write. More... | |
| #define | XIic_DynSendStop(BaseAddress, ByteCount) |
| Sends a stop condition on the IIC bus for dynamic logic. More... | |
Register Map | |
Register offsets for the XIic device. | |
| #define | XIIC_DGIER_OFFSET 0x1C |
| Global Interrupt Enable Register. More... | |
| #define | XIIC_IISR_OFFSET 0x20 |
| Interrupt Status Register. More... | |
| #define | XIIC_IIER_OFFSET 0x28 |
| Interrupt Enable Register. More... | |
| #define | XIIC_RESETR_OFFSET 0x40 |
| Reset Register. More... | |
| #define | XIIC_CR_REG_OFFSET 0x100 |
| Control Register. More... | |
| #define | XIIC_SR_REG_OFFSET 0x104 |
| Status Register. More... | |
| #define | XIIC_DTR_REG_OFFSET 0x108 |
| Data Tx Register. More... | |
| #define | XIIC_DRR_REG_OFFSET 0x10C |
| Data Rx Register. More... | |
| #define | XIIC_ADR_REG_OFFSET 0x110 |
| Address Register. More... | |
| #define | XIIC_TFO_REG_OFFSET 0x114 |
| Tx FIFO Occupancy. More... | |
| #define | XIIC_RFO_REG_OFFSET 0x118 |
| Rx FIFO Occupancy. More... | |
| #define | XIIC_TBA_REG_OFFSET 0x11C |
| 10 Bit Address reg More... | |
| #define | XIIC_RFD_REG_OFFSET 0x120 |
| Rx FIFO Depth reg. More... | |
| #define | XIIC_GPO_REG_OFFSET 0x124 |
| Output Register. More... | |
Timing register offsets | |
Timing register offsets from RegisterBase. These are used only for setting i2c clock frequency for the line. | |
| #define | XIIC_TSUSTA_REG_OFFSET 0x128 /* TSUSTA Register */ |
| TSUSTA REG register offset. More... | |
| #define | XIIC_TSUSTO_REG_OFFSET 0x12C /* TSUSTO Register */ |
| TSUSTO REG register offset. More... | |
| #define | XIIC_THDSTA_REG_OFFSET 0x130 /* THDSTA Register */ |
| THDSTA REG register offset. More... | |
| #define | XIIC_TSUDAT_REG_OFFSET 0x134 /* TSUDAT Register */ |
| TSUDAT REG register offset. More... | |
| #define | XIIC_TBUF_REG_OFFSET 0x138 /* TBUF Register */ |
| TBUF REG register offset. More... | |
| #define | XIIC_THIGH_REG_OFFSET 0x13C /* THIGH Register */ |
| THIGH REG register offset. More... | |
| #define | XIIC_TLOW_REG_OFFSET 0x140 /* TLOW Register */ |
| TLOW REG register offset. More... | |
| #define | XIIC_THDDAT_REG_OFFSET 0x144 /* THDDAT Register */ |
| THDDAT REG register offset. More... | |
Device Global Interrupt Enable Register masks (CR) mask(s) | |
| #define | XIIC_GINTR_ENABLE_MASK 0x80000000 |
| Global Interrupt Enable Mask. More... | |
IIC Device Interrupt Status/Enable (INTR) Register Masks | |
Interrupt Status Register (IISR) This register holds the interrupt status flags for the Spi device. Interrupt Enable Register (IIER) This register is used to enable interrupt sources for the IIC device. Writing a '1' to a bit in this register enables the corresponding Interrupt. Writing a '0' to a bit in this register disables the corresponding Interrupt. IISR/IIER registers have the same bit definitions and are only defined once. | |
| #define | XIIC_INTR_ARB_LOST_MASK 0x00000001 |
| 1 = Arbitration lost More... | |
| #define | XIIC_INTR_TX_ERROR_MASK 0x00000002 |
| 1 = Tx error/msg complete More... | |
| #define | XIIC_INTR_TX_EMPTY_MASK 0x00000004 |
| 1 = Tx FIFO/reg empty More... | |
| #define | XIIC_INTR_RX_FULL_MASK 0x00000008 |
| 1 = Rx FIFO/reg=OCY level More... | |
| #define | XIIC_INTR_BNB_MASK 0x00000010 |
| 1 = Bus not busy More... | |
| #define | XIIC_INTR_AAS_MASK 0x00000020 |
| 1 = When addr as slave More... | |
| #define | XIIC_INTR_NAAS_MASK 0x00000040 |
| 1 = Not addr as slave More... | |
| #define | XIIC_INTR_TX_HALF_MASK 0x00000080 |
| 1 = Tx FIFO half empty More... | |
| #define | XIIC_TX_INTERRUPTS |
| Commonly used Tx interrupts. More... | |
| #define | XIIC_TX_RX_INTERRUPTS (XIIC_INTR_RX_FULL_MASK | XIIC_TX_INTERRUPTS) |
| Commonly used Tx and Rx interrupts. More... | |
Reset Register mask | |
| #define | XIIC_RESET_MASK 0x0000000A |
| RESET Mask. More... | |
Control Register masks (CR) mask(s) | |
| #define | XIIC_CR_ENABLE_DEVICE_MASK 0x00000001 |
| Device enable = 1. More... | |
| #define | XIIC_CR_TX_FIFO_RESET_MASK 0x00000002 |
| Transmit FIFO reset=1. More... | |
| #define | XIIC_CR_MSMS_MASK 0x00000004 |
| Master starts Txing=1. More... | |
| #define | XIIC_CR_DIR_IS_TX_MASK 0x00000008 |
| Dir of Tx. More... | |
| #define | XIIC_CR_NO_ACK_MASK 0x00000010 |
| Tx Ack. More... | |
| #define | XIIC_CR_REPEATED_START_MASK 0x00000020 |
| Repeated start = 1. More... | |
| #define | XIIC_CR_GENERAL_CALL_MASK 0x00000040 |
| Gen Call enabled = 1. More... | |
Status Register masks (SR) mask(s) | |
| #define | XIIC_SR_GEN_CALL_MASK 0x00000001 |
| 1 = A Master issued a GC. More... | |
| #define | XIIC_SR_ADDR_AS_SLAVE_MASK 0x00000002 |
| 1 = When addressed as slave. More... | |
| #define | XIIC_SR_BUS_BUSY_MASK 0x00000004 |
| 1 = Bus is busy More... | |
| #define | XIIC_SR_MSTR_RDING_SLAVE_MASK 0x00000008 |
| 1 = Dir: Master <– slave. More... | |
| #define | XIIC_SR_TX_FIFO_FULL_MASK 0x00000010 |
| 1 = Tx FIFO full More... | |
| #define | XIIC_SR_RX_FIFO_FULL_MASK 0x00000020 |
| 1 = Rx FIFO full More... | |
| #define | XIIC_SR_RX_FIFO_EMPTY_MASK 0x00000040 |
| 1 = Rx FIFO empty More... | |
| #define | XIIC_SR_TX_FIFO_EMPTY_MASK 0x00000080 |
| 1 = Tx FIFO empty More... | |
Data Tx Register (DTR) mask(s) | |
| #define | XIIC_TX_DYN_START_MASK 0x00000100 |
| 1 = Set dynamic start More... | |
| #define | XIIC_TX_DYN_STOP_MASK 0x00000200 |
| 1 = Set dynamic stop More... | |
| #define | IIC_TX_FIFO_DEPTH 16 |
| Tx fifo capacity. More... | |
Data Rx Register (DRR) mask(s) | |
| #define | IIC_RX_FIFO_DEPTH 16 |
| Rx fifo capacity. More... | |
Functions | |
| unsigned | XIic_Recv (UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option) |
| Receives data as a master on the IIC bus. More... | |
| unsigned | XIic_Send (UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option) |
| Sends data as a master on the IIC bus. More... | |
| unsigned | XIic_DynRecv (UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, u8 ByteCount) |
| Receives data as a master on the IIC bus. More... | |
| unsigned | XIic_DynSend (UINTPTR BaseAddress, u16 Address, u8 *BufferPtr, u8 ByteCount, u8 Option) |
| Sends data as a master on the IIC bus. More... | |
| int | XIic_DynInit (UINTPTR BaseAddress) |
| Initializes the IIC core for dynamic functionality. More... | |
| u32 | XIic_CheckIsBusBusy (UINTPTR BaseAddress) |
| Checks whether the I2C bus is busy or free. More... | |
| u32 | XIic_WaitBusFree (UINTPTR BaseAddress) |
| Waits until the I2C bus is free or a timeout occurs. More... | |