iic
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
IIC APIs

Macros

#define XIIC_DYN_MASTER_INCLUDE
 Includes dynamic master code for sending and receiving data. More...
 
#define XIic_Send10BitAddrByte1(SlaveAddress, Operation)
 Sends the first byte of a 10-bit address for reads and writes. More...
 
#define XIic_Send10BitAddrByte2(SlaveAddress)
 Sends the second byte of a 10-bit address for reads and writes. More...
 
#define XIic_Send7BitAddr(SlaveAddress, Operation)
 Sends a 7-bit address for reads and writes. More...
 
#define XIic_DisableIntr(BaseAddress, InterruptMask)
 Disables the specified interrupts in the Interrupt Enable register. More...
 
#define XIic_EnableIntr(BaseAddress, InterruptMask)
 Enables the specified interrupts in the Interrupt Enable register. More...
 
#define XIic_ClearIntr(BaseAddress, InterruptMask)
 Clears the specified interrupt in the Interrupt Status register. More...
 
#define XIic_ClearEnableIntr(BaseAddress, InterruptMask)
 Clears and enables the specified interrupt. More...
 
#define XIic_FlushRxFifo(InstancePtr)
 Flushes the receive FIFO, discarding all bytes in it. More...
 
#define XIic_FlushTxFifo(InstancePtr)
 Flushes the transmit FIFO, discarding all bytes in it. More...
 
#define XIic_ReadRecvByte(InstancePtr)
 Reads the next available received byte from the receive FIFO. More...
 
#define XIic_WriteSendByte(InstancePtr)
 Writes the next byte to be sent to the transmit FIFO. More...
 
#define XIic_SetControlRegister(InstancePtr, ControlRegister, ByteCount)
 Sets up the control register for a master receive operation. More...
 
#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...
 
#define XIIC_MASTER_INCLUDE
 Includes master code for sending and receiving data. More...
 
#define XIIC_REG_VALUES_100KHZ   0
 Timing table index for 100 kHz. More...
 
#define XIIC_REG_VALUES_400KHZ   1
 Timing table index for 400 kHz. More...
 
#define XIIC_REG_VALUES_1MHZ   2
 Timing table index for 1 MHz. More...
 
#define XIIC_STANDARD_MODE   100000U
 Standard mode SCL rate in Hz. More...
 
#define XIIC_FAST_MODE   400000U
 Fast mode SCL rate in Hz. More...
 
#define XIIC_FAST_MODE_PLUS   1000000U
 Fast mode plus SCL rate in Hz. More...
 
#define XIIC_NANOSEC_TO_SEC_DIVISOR   1000000000U
 Number of nanoseconds in one second. More...
 

Functions

int XIic_CfgInitialize (XIic *InstancePtr, XIic_Config *Config, UINTPTR EffectiveAddr)
 Initializes a specific XIic instance. More...
 
int XIic_Start (XIic *InstancePtr)
 Starts the IIC device and driver by enabling the proper interrupts. More...
 
int XIic_Stop (XIic *InstancePtr)
 Stops the IIC device and driver. More...
 
void XIic_Reset (XIic *InstancePtr)
 Resets the IIC device. More...
 
int XIic_SetAddress (XIic *InstancePtr, int AddressType, int Address)
 Sets the bus addresses. More...
 
u16 XIic_GetAddress (XIic *InstancePtr, int AddressType)
 Gets the addresses for the IIC device driver. More...
 
int XIic_SetGpOutput (XIic *InstancePtr, u8 OutputValue)
 Sets the contents of the IIC General Purpose Output register. More...
 
int XIic_GetGpOutput (XIic *InstancePtr, u8 *OutputValuePtr)
 Gets the contents of the IIC General Purpose Output register. More...
 
u32 XIic_IsSlave (XIic *InstancePtr)
 Determines if the device is currently addressed as a slave. More...
 
void XIic_SetRecvHandler (XIic *InstancePtr, void *CallBackRef, XIic_Handler FuncPtr)
 Sets the receive handler that the driver calls after receiving data. More...
 
void XIic_SetSendHandler (XIic *InstancePtr, void *CallBackRef, XIic_Handler FuncPtr)
 Sets the send handler called on confirmation of sent data. More...
 
void XIic_SetStatusHandler (XIic *InstancePtr, void *CallBackRef, XIic_StatusHandler FuncPtr)
 Sets the status handler for events that are not data related. More...
 
int XIic_DynMasterSend (XIic *InstancePtr, u8 *TxMsgPtr, u8 ByteCount)
 Sends data as a Dynamic master on the IIC bus. More...
 
int XIic_DynMasterRecv (XIic *InstancePtr, u8 *RxMsgPtr, u8 ByteCount)
 Receives data as a master from a slave device on the IIC bus. More...
 
int XIic_DynamicInitialize (XIic *InstancePtr)
 Initializes the IIC core for dynamic functionality. More...
 
void XIic_TransmitFifoFill (XIic *InstancePtr, int Role)
 Fills the FIFO using the occupancy register to find available space. More...
 
void XIic_InterruptHandler (void *InstancePtr)
 Handles interrupts for the XIic driver. More...
 
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...
 
int XIic_MasterSend (XIic *InstancePtr, u8 *TxMsgPtr, int ByteCount)
 Sends data as a master on the IIC bus. More...
 
int XIic_MasterRecv (XIic *InstancePtr, u8 *RxMsgPtr, int ByteCount)
 Receives data as a master from a slave device on the IIC bus. More...
 
void XIic_MultiMasterInclude (void)
 Includes multi-master code so multi-master events are handled. More...
 
void XIic_SetOptions (XIic *InstancePtr, u32 NewOptions)
 Sets the options for the IIC device driver. More...
 
u32 XIic_GetOptions (XIic *InstancePtr)
 Gets the current options for the IIC device. More...
 
u32 XIic_SetClk (XIic *InstancePtr, u32 FsclHz)
 Sets the serial clock rate for the IIC device. More...
 
int XIic_SelfTest (XIic *InstancePtr)
 Runs a limited self-test on the driver/device. More...
 
XIic_Config * XIic_LookupConfig (UINTPTR BaseAddress)
 Looks up the device configuration by unique device ID or base address. More...
 
int XIic_Initialize (XIic *InstancePtr, UINTPTR BaseAddress)
 Initializes a specific XIic instance. More...
 
void XIic_SlaveInclude (void)
 Includes slave code so slave events are processed. More...
 
int XIic_SlaveSend (XIic *InstancePtr, u8 *TxMsgPtr, int ByteCount)
 Sends data as a slave on the IIC bus. More...
 
int XIic_SlaveRecv (XIic *InstancePtr, u8 *RxMsgPtr, int ByteCount)
 Receives data as a slave on the IIC bus. More...
 
void XIic_GetStats (XIic *InstancePtr, XIicStats *StatsPtr)
 Gets a copy of the statistics for an IIC device. More...
 
void XIic_ClearStats (XIic *InstancePtr)
 Clears the statistics for the IIC device by zeroing all counts. More...
 

Variables

XIic_Config XIic_ConfigTable [XPAR_XIIC_NUM_INSTANCES]
 Holds the IIC configuration table. More...
 
XIic_Config XIic_ConfigTable []
 Holds the IIC configuration table. 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...
 

Macro Definition Documentation

#define IIC_RX_FIFO_DEPTH   16

Rx fifo capacity.

Referenced by XIic_DynInit(), XIic_DynMasterRecv(), XIic_MasterRecv(), and XIic_SlaveRecv().

#define IIC_TX_FIFO_DEPTH   16

Tx fifo capacity.

Referenced by XIic_TransmitFifoFill().

#define XIIC_ADR_REG_OFFSET   0x110

Address Register.

Referenced by XIic_GetAddress(), and XIic_SetAddress().

#define XIic_ClearEnableIntr (   BaseAddress,
  InterruptMask 
)
Value:
{ \
XIic_WriteIisr(BaseAddress, \
(XIic_ReadIisr(BaseAddress) & (InterruptMask))); \
XIic_WriteIier(BaseAddress, \
(XIic_ReadIier(BaseAddress) | (InterruptMask))); \
}
#define XIic_ReadIisr(BaseAddress)
Gets the contents of the Interrupt Status Register.
Definition: xiic_l.h:417
#define XIic_WriteIier(BaseAddress, Enable)
Sets the contents of the Interrupt Enable Register.
Definition: xiic_l.h:440
#define XIic_ReadIier(BaseAddress)
Gets the Interrupt Enable Register contents.
Definition: xiic_l.h:459
#define XIic_WriteIisr(BaseAddress, Status)
Sets the Interrupt status register to the specified value.
Definition: xiic_l.h:396

Clears and enables the specified interrupt.

This macro clears and enables the specified interrupt in the Interrupt status and enable registers. It is non-destructive in that the registers are read and only the interrupt specified is modified. Clearing an interrupt acknowledges it.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]InterruptMaskThe interrupts to be cleared and enabled.
Note
C-style signature void XIic_ClearEnableIntr(u32 BaseAddress, u32 InterruptMask)

Referenced by XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_MasterRecv(), XIic_MasterSend(), XIic_SlaveSend(), and XIic_Start().

#define XIic_ClearIisr (   BaseAddress,
  InterruptMask 
)
Value:
XIic_WriteIisr((BaseAddress), \
XIic_ReadIisr(BaseAddress) & (InterruptMask))
#define XIic_ReadIisr(BaseAddress)
Gets the contents of the Interrupt Status Register.
Definition: xiic_l.h:417
#define XIic_WriteIisr(BaseAddress, Status)
Sets the Interrupt status register to the specified value.
Definition: xiic_l.h:396

Clears the specified interrupt in the Interrupt Status register.

This macro clears the specified interrupt in the Interrupt status register. It is non-destructive in that the register is read and only the interrupt specified is cleared. Clearing an interrupt acknowledges it.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]InterruptMaskThe bit mask of the interrupts to be cleared.
Note
C-style signature void XIic_ClearIisr(u32 BaseAddress, u32 InterruptMask)

Referenced by XIic_DynRecv(), XIic_DynSend(), XIic_Recv(), and XIic_Send().

#define XIic_ClearIntr (   BaseAddress,
  InterruptMask 
)
Value:
XIic_WriteIisr((BaseAddress), \
XIic_ReadIisr(BaseAddress) & (InterruptMask))
#define XIic_ReadIisr(BaseAddress)
Gets the contents of the Interrupt Status Register.
Definition: xiic_l.h:417
#define XIic_WriteIisr(BaseAddress, Status)
Sets the Interrupt status register to the specified value.
Definition: xiic_l.h:396

Clears the specified interrupt in the Interrupt Status register.

This macro clears the specified interrupt in the Interrupt status register. It is non-destructive in that the register is read and only the interrupt specified is cleared. Clearing an interrupt acknowledges it.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]InterruptMaskThe interrupts to be disabled.
Note
C-style signature void XIic_ClearIntr(u32 BaseAddress, u32 InterruptMask)

Referenced by XIic_SlaveRecv(), and XIic_Start().

#define XIIC_CR_DIR_IS_TX_MASK   0x00000008

Dir of Tx.

Txing=1

Referenced by XIic_DynMasterSend(), XIic_MasterSend(), XIic_Recv(), and XIic_Send().

#define XIIC_CR_ENABLE_DEVICE_MASK   0x00000001
#define XIIC_CR_GENERAL_CALL_MASK   0x00000040

Gen Call enabled = 1.

Referenced by XIic_SetOptions().

#define XIIC_CR_MSMS_MASK   0x00000004
#define XIIC_CR_NO_ACK_MASK   0x00000010

Tx Ack.

NO ack = 1

Referenced by XIic_DynMasterSend(), XIic_MasterSend(), and XIic_Recv().

#define XIIC_CR_REPEATED_START_MASK   0x00000020
#define XIIC_CR_TX_FIFO_RESET_MASK   0x00000002

Transmit FIFO reset=1.

Referenced by EepromReadByte(), EepromWriteByte(), and XIic_DynInit().

#define XIIC_DGIER_OFFSET   0x1C

Global Interrupt Enable Register.

#define XIic_DisableIntr (   BaseAddress,
  InterruptMask 
)
Value:
XIic_WriteIier((BaseAddress), \
XIic_ReadIier(BaseAddress) & ~(InterruptMask))
#define XIic_WriteIier(BaseAddress, Enable)
Sets the contents of the Interrupt Enable Register.
Definition: xiic_l.h:440
#define XIic_ReadIier(BaseAddress)
Gets the Interrupt Enable Register contents.
Definition: xiic_l.h:459

Disables the specified interrupts in the Interrupt Enable register.

This macro disables the specified interrupts in the Interrupt enable register. It is non-destructive in that the register is read and only the interrupts specified is changed.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]InterruptMaskThe interrupts to be disabled.
Note
C-style signature void XIic_DisableIntr(u32 BaseAddress, u32 InterruptMask)

Referenced by XIic_InterruptHandler().

#define XIIC_DRR_REG_OFFSET   0x10C

Data Rx Register.

#define XIIC_DTR_REG_OFFSET   0x108

Data Tx Register.

Referenced by XIic_SetClk().

#define XIIC_DYN_MASTER_INCLUDE
Value:
{ \
XIic_RecvMasterFuncPtr = DynRecvMasterData; \
XIic_SendMasterFuncPtr = DynSendMasterData; \
}

Includes dynamic master code for sending and receiving data.

This macro includes dynamic master code such that dynamic master operations, sending and receiving data, may be used. This function hooks the dynamic master processing to the driver such that events are handled properly and allows dynamic master processing to be optional. It must be called before any functions which are contained in this file are called, such as after the driver is initialized.

Referenced by XIic_DynMasterRecv(), and XIic_DynMasterSend().

#define XIic_DynSend7BitAddress (   BaseAddress,
  SlaveAddress,
  Operation 
)
Value:
{ \
u8 LocalAddr = (u8)(SlaveAddress << 1); \
LocalAddr = (LocalAddr & 0xFE) | (Operation); \
XIIC_TX_DYN_START_MASK | LocalAddr); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_TX_DYN_START_MASK
1 = Set dynamic start
Definition: xiic_l.h:223
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends a 7-bit address for reads and writes.

This macro sends the address for a 7 bit address during both read and write operations. It takes care of the details to format the address correctly. This macro is designed to be called internally to the drivers for Dynamic controller functionality.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]SlaveAddressThe address of the slave to send to.
[in]OperationIndicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION.
Note
C-style signature void XIic_DynSend7BitAddress(u32 BaseAddress, u8 SlaveAddress, u8 Operation)

Referenced by XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_DynRecv(), and XIic_DynSend().

#define XIic_DynSendStartStopAddress (   BaseAddress,
  SlaveAddress,
  Operation 
)
Value:
{ \
u8 LocalAddr = (u8)(SlaveAddress << 1); \
LocalAddr = (LocalAddr & 0xFE) | (Operation); \
LocalAddr); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_TX_DYN_START_MASK
1 = Set dynamic start
Definition: xiic_l.h:223
#define XIIC_TX_DYN_STOP_MASK
1 = Set dynamic stop
Definition: xiic_l.h:224
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends the address, start, and stop for a 7-bit address write.

This macro sends the address, start and stop for a 7 bit address during both write operations. It takes care of the details to format the address correctly. This macro is designed to be called internally to the drivers.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]SlaveAddressThe address of the slave to send to.
[in]OperationIndicates XIIC_WRITE_OPERATION.
Note
C-style signature void XIic_DynSendStartStopAddress(u32 BaseAddress, u8 SlaveAddress, u8 Operation)

Referenced by XIic_DynSend().

#define XIic_DynSendStop (   BaseAddress,
  ByteCount 
)
Value:
{ \
XIIC_TX_DYN_STOP_MASK | ByteCount); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_TX_DYN_STOP_MASK
1 = Set dynamic stop
Definition: xiic_l.h:224
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends a stop condition on the IIC bus for dynamic logic.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]ByteCountThe number of Rx bytes received before the master. doesn't respond with ACK.
Note
C-style signature void XIic_DynSendStop(u32 BaseAddress, u32 ByteCount)

Referenced by XIic_DynMasterRecv(), and XIic_DynRecv().

#define XIic_EnableIntr (   BaseAddress,
  InterruptMask 
)
Value:
XIic_WriteIier((BaseAddress), \
XIic_ReadIier(BaseAddress) | (InterruptMask))
#define XIic_WriteIier(BaseAddress, Enable)
Sets the contents of the Interrupt Enable Register.
Definition: xiic_l.h:440
#define XIic_ReadIier(BaseAddress)
Gets the Interrupt Enable Register contents.
Definition: xiic_l.h:459

Enables the specified interrupts in the Interrupt Enable register.

This macro enables the specified interrupts in the Interrupt enable register. It is non-destructive in that the register is read and only the interrupts specified is changed.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]InterruptMaskThe interrupts to be disabled.
Note
C-style signature void XIic_EnableIntr(u32 BaseAddress, u32 InterruptMask)

Referenced by XIic_SlaveRecv().

#define XIIC_FAST_MODE   400000U

Fast mode SCL rate in Hz.

Referenced by XIic_SetClk().

#define XIIC_FAST_MODE_PLUS   1000000U

Fast mode plus SCL rate in Hz.

Referenced by XIic_SetClk().

#define XIic_FlushRxFifo (   InstancePtr)
Value:
{ \
int LoopCnt; \
u8 BytesToRead = XIic_ReadReg(InstancePtr->BaseAddress, \
for(LoopCnt = 0; LoopCnt < BytesToRead; LoopCnt++) \
{ \
XIic_ReadReg(InstancePtr->BaseAddress, \
} \
}
#define XIIC_DRR_REG_OFFSET
Data Rx Register.
Definition: xiic_l.h:101
#define XIic_ReadReg(BaseAddress, RegOffset)
Reads from the specified IIC device register.
Definition: xiic_l.h:289
#define XIIC_RFO_REG_OFFSET
Rx FIFO Occupancy.
Definition: xiic_l.h:104

Flushes the receive FIFO, discarding all bytes in it.

This macro flushes the receive FIFO such that all bytes contained within it are discarded.

Parameters
[in]InstancePtrPointer to the IIC instance containing the FIFO to be flushed.
Note
C-style signature void XIic_FlushRxFifo(XIic *InstancePtr)
#define XIic_FlushTxFifo (   InstancePtr)
Value:
; \
{ \
u32 CntlReg = XIic_ReadReg(InstancePtr->BaseAddress, \
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_CR_REG_OFFSET, \
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_CR_REG_OFFSET, \
CntlReg); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_CR_REG_OFFSET
Control Register.
Definition: xiic_l.h:98
#define XIIC_CR_TX_FIFO_RESET_MASK
Transmit FIFO reset=1.
Definition: xiic_l.h:194
#define XIic_ReadReg(BaseAddress, RegOffset)
Reads from the specified IIC device register.
Definition: xiic_l.h:289

Flushes the transmit FIFO, discarding all bytes in it.

This macro flushes the transmit FIFO such that all bytes contained within it are discarded.

Parameters
[in]InstancePtrPointer to the IIC instance containing the FIFO to be flushed.
Note
C-style signature void XIic_FlushTxFifo(XIic *InstancePtr)
#define XIIC_GINTR_ENABLE_MASK   0x80000000

Global Interrupt Enable Mask.

#define XIIC_GPO_REG_OFFSET   0x124

Output Register.

Referenced by XIic_GetGpOutput(), and XIic_SetGpOutput().

#define XIIC_IIER_OFFSET   0x28

Interrupt Enable Register.

#define XIIC_IISR_OFFSET   0x20

Interrupt Status Register.

#define XIic_In32   Xil_In32

32-bit register read function.

#define XIIC_INTR_AAS_MASK   0x00000020

1 = When addr as slave

Referenced by XIic_InterruptHandler(), and XIic_Start().

#define XIIC_INTR_ARB_LOST_MASK   0x00000001
#define XIIC_INTR_BNB_MASK   0x00000010
#define XIIC_INTR_NAAS_MASK   0x00000040

1 = Not addr as slave

Referenced by XIic_InterruptHandler().

#define XIIC_INTR_RX_FULL_MASK   0x00000008
#define XIIC_INTR_TX_EMPTY_MASK   0x00000004
#define XIIC_INTR_TX_ERROR_MASK   0x00000002
#define XIIC_INTR_TX_HALF_MASK   0x00000080
#define XIic_IntrGlobalDisable (   BaseAddress)    XIic_WriteReg((BaseAddress), XIIC_DGIER_OFFSET, 0)

Disables all interrupts for the device at the global level.

This macro disables all interrupts for the device by writing to the Global interrupt enable register.

Parameters
[in]BaseAddressThe base address of the IIC device.
Note
C-style signature void XIic_IntrGlobalDisable(u32 BaseAddress)

Referenced by SlaveReadData(), SlaveWriteData(), TenBitAddrReadData(), TenBitAddrWriteData(), XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_MasterRecv(), XIic_MasterSend(), XIic_SetOptions(), XIic_SlaveRecv(), XIic_SlaveSend(), and XIic_Stop().

#define XIic_IntrGlobalEnable (   BaseAddress)
Value:
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_GINTR_ENABLE_MASK
Global Interrupt Enable Mask.
Definition: xiic_l.h:139
#define XIIC_DGIER_OFFSET
Global Interrupt Enable Register.
Definition: xiic_l.h:94

Enables interrupts from the device at the global level.

This macro writes to the global interrupt enable register to enable interrupts from the device. This function does not enable individual interrupts as the Interrupt Enable Register must be set appropriately.

Parameters
[in]BaseAddressThe base address of the IIC device.
Note
C-style signature void XIic_IntrGlobalEnable(u32 BaseAddress)

Referenced by IicPmbusInterruptSdtExample(), SlaveReadData(), SlaveWriteData(), TenBitAddrReadData(), TenBitAddrWriteData(), XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_MasterRecv(), XIic_MasterSend(), XIic_SelfTest(), XIic_SetOptions(), XIic_SlaveRecv(), XIic_SlaveSend(), XIic_Start(), and XIic_Stop().

#define XIic_IsIntrGlobalEnabled (   BaseAddress)
Value:
(XIic_ReadReg((BaseAddress), XIIC_DGIER_OFFSET) == \
#define XIIC_GINTR_ENABLE_MASK
Global Interrupt Enable Mask.
Definition: xiic_l.h:139
#define XIIC_DGIER_OFFSET
Global Interrupt Enable Register.
Definition: xiic_l.h:94
#define XIic_ReadReg(BaseAddress, RegOffset)
Reads from the specified IIC device register.
Definition: xiic_l.h:289

Determines if interrupts are enabled at the global level.

Determines if interrupts are enabled at the global level by reading the global interrupt register.

Parameters
[in]BaseAddressThe base address of the IIC device.
Returns
  • TRUE if the global interrupt is enabled.
  • FALSE if global interrupt is disabled.
Note
C-style signature int XIic_IsIntrGlobalEnabled(u32 BaseAddress)

Referenced by XIic_InterruptHandler(), and XIic_SelfTest().

#define XIIC_MASTER_INCLUDE
Value:
{ \
XIic_RecvMasterFuncPtr = RecvMasterData; \
XIic_SendMasterFuncPtr = SendMasterData; \
}

Includes master code for sending and receiving data.

This macro includes master code such that master operations, sending and receiving data, may be used. This function hooks the master processing to the driver such that events are handled properly and allows master processing to be optional. It must be called before any functions which are contained in this file are called, such as after the driver is initialized.

Referenced by XIic_MasterRecv(), and XIic_MasterSend().

#define XIIC_MASTER_ROLE   1

Master on the IIC bus.

Referenced by XIic_DynMasterSend(), and XIic_MasterSend().

#define XIIC_NANOSEC_TO_SEC_DIVISOR   1000000000U

Number of nanoseconds in one second.

Referenced by XIic_SetClk().

#define XIic_Out32   Xil_Out32

32-bit register write function.

Referenced by XIic_SetClk().

#define XIIC_READ_OPERATION   1

Read operation on the IIC bus.

Referenced by XIic_DynMasterRecv(), XIic_DynRecv(), XIic_MasterRecv(), and XIic_Recv().

#define XIic_ReadIier (   BaseAddress)    XIic_ReadReg((BaseAddress), XIIC_IIER_OFFSET)

Gets the Interrupt Enable Register contents.

Parameters
[in]BaseAddressThe base address of the IIC device.
Returns
The contents read from the Interrupt Enable Register. Bit positions of 1 indicate that the corresponding interrupt is enabled. Bit positions of 0 indicate that the corresponding interrupt is disabled.
Note
C-style signature u32 XIic_ReadIier(u32 BaseAddress)

Referenced by XIic_InterruptHandler(), and XIic_SelfTest().

#define XIic_ReadIisr (   BaseAddress)    XIic_ReadReg((BaseAddress), XIIC_IISR_OFFSET)

Gets the contents of the Interrupt Status Register.

This register indicates the status of interrupt sources for the device. The status is independent of whether interrupts are enabled such that the status register may also be polled when interrupts are not enabled.

Parameters
[in]BaseAddressThe base address of the IIC device.
Returns
The value read from the Interrupt Status Register.
Note
C-style signature u32 XIic_ReadIisr(u32 BaseAddress)

Referenced by XIic_InterruptHandler().

#define XIic_ReadRecvByte (   InstancePtr)
Value:
{ \
*InstancePtr->RecvBufferPtr++ = \
XIic_ReadReg(InstancePtr->BaseAddress, XIIC_DRR_REG_OFFSET); \
InstancePtr->RecvByteCount--; \
InstancePtr->Stats.RecvBytes++; \
}
#define XIIC_DRR_REG_OFFSET
Data Rx Register.
Definition: xiic_l.h:101
#define XIic_ReadReg(BaseAddress, RegOffset)
Reads from the specified IIC device register.
Definition: xiic_l.h:289

Reads the next available received byte from the receive FIFO.

This macro reads the next available received byte from the receive FIFO and updates all the data structures to reflect it.

Parameters
[in]InstancePtrPointer to the IIC instance to be operated on.
Note
C-style signature void XIic_ReadRecvByte(XIic *InstancePtr)
#define XIic_ReadReg (   BaseAddress,
  RegOffset 
)    XIic_In32((BaseAddress) + (RegOffset))

Reads from the specified IIC device register.

Parameters
[in]BaseAddressThe base address of the device.
[in]RegOffsetThe offset from the 1st register of the device to select the specific register.
Returns
The value read from the register.
Note
This macro does not do any checking to ensure that the register exists if the register may be excluded due to parameterization, such as the GPO Register. C-style signature u32 XIic_ReadReg(u32 BaseAddress, u32 RegOffset)

Referenced by EepromReadByte(), EepromWriteByte(), IicLowLevelDynEeprom(), XIic_CheckIsBusBusy(), XIic_DynInit(), XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_DynRecv(), XIic_DynSend(), XIic_GetAddress(), XIic_GetGpOutput(), XIic_InterruptHandler(), XIic_IsSlave(), XIic_MasterRecv(), XIic_MasterSend(), XIic_Recv(), XIic_Send(), XIic_SetClk(), XIic_SetOptions(), XIic_SlaveRecv(), XIic_SlaveSend(), XIic_Stop(), and XIic_TransmitFifoFill().

#define XIIC_REG_VALUES_100KHZ   0

Timing table index for 100 kHz.

Referenced by XIic_SetClk().

#define XIIC_REG_VALUES_1MHZ   2

Timing table index for 1 MHz.

Referenced by XIic_SetClk().

#define XIIC_REG_VALUES_400KHZ   1

Timing table index for 400 kHz.

Referenced by XIic_SetClk().

#define XIIC_REPEATED_START   0x01

Do not send a stop on the IIC bus after the current transfer.

Referenced by EepromReadByte().

#define XIIC_RESET_MASK   0x0000000A

RESET Mask.

Referenced by XIic_DynInit(), and XIic_Reset().

#define XIIC_RESETR_OFFSET   0x40

Reset Register.

Referenced by XIic_DynInit(), and XIic_Reset().

#define XIIC_RFD_REG_OFFSET   0x120
#define XIIC_RFO_REG_OFFSET   0x118

Rx FIFO Occupancy.

#define XIic_Send10BitAddrByte1 (   SlaveAddress,
  Operation 
)
Value:
{ \
u8 LocalAddr = (u8)((SlaveAddress) >> 7); \
LocalAddr = (LocalAddr & 0xF6) | 0xF0 | (Operation); \
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_DTR_REG_OFFSET, \
(u32) LocalAddr); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends the first byte of a 10-bit address for reads and writes.

This macro sends the first byte of the address for a 10 bit address during both read and write operations. It takes care of the details to format the address correctly.

address = 1111_0xxD xx = address MSBits D = Tx direction = 0 = write

Parameters
[in]SlaveAddressThe address of the slave to send to.
[in]OperationIndicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION.
Note
C-style signature void XIic_Send10BitAddrByte1(u16 SlaveAddress, u8 Operation)

Referenced by XIic_MasterRecv(), and XIic_MasterSend().

#define XIic_Send10BitAddrByte2 (   SlaveAddress)
Value:
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_DTR_REG_OFFSET, \
(u32)(SlaveAddress)); \
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends the second byte of a 10-bit address for reads and writes.

This macro sends the second byte of the address for a 10 bit address during both read and write operations. It takes care of the details to format the address correctly.

Parameters
[in]SlaveAddressThe address of the slave to send to.
Note
C-style signature void XIic_Send10BitAddrByte2(u16 SlaveAddress)

Referenced by XIic_MasterRecv(), and XIic_MasterSend().

#define XIic_Send7BitAddr (   SlaveAddress,
  Operation 
)
Value:
{ \
u8 LocalAddr = (u8)(SlaveAddress << 1); \
LocalAddr = (LocalAddr & 0xFE) | (Operation); \
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_DTR_REG_OFFSET, \
(u32) LocalAddr); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends a 7-bit address for reads and writes.

This macro sends the address for a 7 bit address during both read and write operations. It takes care of the details to format the address correctly.

Parameters
[in]SlaveAddressThe address of the slave to send to.
[in]OperationIndicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION.
Note
C-style signature void XIic_Send7BitAddr(u16 SlaveAddress, u8 Operation)

Referenced by XIic_MasterRecv(), and XIic_MasterSend().

#define XIic_Send7BitAddress (   BaseAddress,
  SlaveAddress,
  Operation 
)
Value:
{ \
u8 LocalAddr = (u8)(SlaveAddress << 1); \
LocalAddr = (LocalAddr & 0xFE) | (Operation); \
XIic_WriteReg(BaseAddress, XIIC_DTR_REG_OFFSET, LocalAddr); \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Sends a 7-bit address for reads and writes.

This macro sends the address for a 7 bit address during both read and write operations. It takes care of the details to format the address correctly. This macro is designed to be called internally to the drivers.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]SlaveAddressThe address of the slave to send to.
[in]OperationIndicates XIIC_READ_OPERATION or XIIC_WRITE_OPERATION.
Note
C-style signature void XIic_Send7BitAddress(u32 BaseAddress, u8 SlaveAddress, u8 Operation)

Referenced by XIic_Recv(), and XIic_Send().

#define XIic_SetControlRegister (   InstancePtr,
  ControlRegister,
  ByteCount 
)
Value:
{ \
(ControlRegister) &= ~(XIIC_CR_NO_ACK_MASK | XIIC_CR_DIR_IS_TX_MASK); \
if (InstancePtr->Options & XII_SEND_10_BIT_OPTION) { \
(ControlRegister) |= XIIC_CR_DIR_IS_TX_MASK; \
} else { \
if ((ByteCount) == 1) \
{ \
(ControlRegister) |= XIIC_CR_NO_ACK_MASK; \
} \
} \
}
#define XIIC_CR_DIR_IS_TX_MASK
Dir of Tx.
Definition: xiic_l.h:196
#define XIIC_CR_NO_ACK_MASK
Tx Ack.
Definition: xiic_l.h:197
#define XII_SEND_10_BIT_OPTION
Send 10 bit option.
Definition: xiic.h:357

Sets up the control register for a master receive operation.

This macro sets up the control register for a master receive operation. A write is necessary if a 10 bit operation is being performed.

Parameters
[in]InstancePtrPointer to the IIC instance to be operated on.
[in]ControlRegisterThe contents of the IIC device control register
[in]ByteCountThe number of bytes to be received for the master receive operation
Note
C-style signature void XIic_SetControlRegister(XIic *InstancePtr, u8 ControlRegister, int ByteCount)

Referenced by XIic_DynMasterRecv(), and XIic_MasterRecv().

#define XIIC_SLAVE_ROLE   0

Slave on the IIC bus.

Referenced by XIic_SlaveSend(), and XIic_TransmitFifoFill().

#define XIIC_SR_ADDR_AS_SLAVE_MASK   0x00000002
#define XIIC_SR_BUS_BUSY_MASK   0x00000004
#define XIIC_SR_GEN_CALL_MASK   0x00000001

1 = A Master issued a GC.

#define XIIC_SR_MSTR_RDING_SLAVE_MASK   0x00000008

1 = Dir: Master <– slave.

#define XIIC_SR_RX_FIFO_EMPTY_MASK   0x00000040

1 = Rx FIFO empty

Referenced by IicLowLevelDynEeprom(), and XIic_DynInit().

#define XIIC_SR_RX_FIFO_FULL_MASK   0x00000020

1 = Rx FIFO full

#define XIIC_SR_TX_FIFO_EMPTY_MASK   0x00000080

1 = Tx FIFO empty

Referenced by IicLowLevelDynEeprom(), and XIic_DynInit().

#define XIIC_SR_TX_FIFO_FULL_MASK   0x00000010

1 = Tx FIFO full

#define XIIC_STANDARD_MODE   100000U

Standard mode SCL rate in Hz.

Referenced by XIic_SetClk().

#define XIIC_STOP   0x00

Send a stop on the IIC bus after the current data transfer.

Referenced by EepromReadByte(), EepromWriteByte(), and LowLevelTempSensorExample().

#define XIIC_TBA_REG_OFFSET   0x11C

10 Bit Address reg

Referenced by XIic_GetAddress(), and XIic_SetAddress().

#define XIIC_TBUF_REG_OFFSET   0x138 /* TBUF Register */

TBUF REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TFO_REG_OFFSET   0x114

Tx FIFO Occupancy.

Referenced by XIic_TransmitFifoFill().

#define XIIC_THDDAT_REG_OFFSET   0x144 /* THDDAT Register */

THDDAT REG register offset.

Referenced by XIic_SetClk().

#define XIIC_THDSTA_REG_OFFSET   0x130 /* THDSTA Register */

THDSTA REG register offset.

Referenced by XIic_SetClk().

#define XIIC_THIGH_REG_OFFSET   0x13C /* THIGH Register */

THIGH REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TLOW_REG_OFFSET   0x140 /* TLOW Register */

TLOW REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TSUDAT_REG_OFFSET   0x134 /* TSUDAT Register */

TSUDAT REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TSUSTA_REG_OFFSET   0x128 /* TSUSTA Register */

TSUSTA REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TSUSTO_REG_OFFSET   0x12C /* TSUSTO Register */

TSUSTO REG register offset.

Referenced by XIic_SetClk().

#define XIIC_TX_ADDR_MSTR_RECV_MASK   0x02

TX ADDR MSTR RECV bit mask.

Referenced by XIic_MasterRecv().

#define XIIC_TX_ADDR_SENT   0x00
#define XIIC_TX_DYN_START_MASK   0x00000100

1 = Set dynamic start

#define XIIC_TX_DYN_STOP_MASK   0x00000200

1 = Set dynamic stop

Referenced by XIic_DynSend().

#define XIIC_TX_INTERRUPTS
Value:
#define XIIC_INTR_TX_EMPTY_MASK
1 = Tx FIFO/reg empty
Definition: xiic_l.h:159
#define XIIC_INTR_TX_HALF_MASK
1 = Tx FIFO half empty
Definition: xiic_l.h:164
#define XIIC_INTR_TX_ERROR_MASK
1 = Tx error/msg complete
Definition: xiic_l.h:158

Commonly used Tx interrupts.

#define XIIC_TX_RX_INTERRUPTS   (XIIC_INTR_RX_FULL_MASK | XIIC_TX_INTERRUPTS)

Commonly used Tx and Rx interrupts.

Referenced by XIic_SelfTest().

#define XIIC_WRITE_OPERATION   0

Write operation on the IIC bus.

Referenced by XIic_DynMasterSend(), XIic_DynSend(), XIic_MasterRecv(), XIic_MasterSend(), and XIic_Send().

#define XIic_WriteIier (   BaseAddress,
  Enable 
)    XIic_WriteReg((BaseAddress), XIIC_IIER_OFFSET, (Enable))

Sets the contents of the Interrupt Enable Register.

This function writes only the specified value to the register such that some interrupt sources may be enabled and others disabled. It is the caller's responsibility to get the value of the interrupt enable register prior to setting the value to prevent a destructive behavior.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]EnableThe value to be written to the Interrupt Enable Register. Bit positions of 1 are enabled. Bit positions of 0 are disabled.
Note
C-style signature void XIic_WriteIier(u32 BaseAddress, u32 Enable)

Referenced by XIic_SelfTest(), and XIic_Start().

#define XIic_WriteIisr (   BaseAddress,
  Status 
)    XIic_WriteReg((BaseAddress), XIIC_IISR_OFFSET, (Status))

Sets the Interrupt status register to the specified value.

This register implements a toggle on write functionality. The interrupt is cleared by writing to this register with the bits to be cleared set to a one and all others to zero. Setting a bit which is zero within this register causes an interrupt to be generated.

This function writes only the specified value to the register such that some status bits may be set and others cleared. It is the caller's responsibility to get the value of the register prior to setting the value to prevent an destructive behavior.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]StatusThe value to be written to the Interrupt status register.
Note
C-style signature void XIic_WriteIisr(u32 BaseAddress, u32 Status)

Referenced by XIic_InterruptHandler().

#define XIic_WriteReg (   BaseAddress,
  RegOffset,
  RegisterValue 
)    XIic_Out32((BaseAddress) + (RegOffset), (RegisterValue))

Writes to the specified IIC device register.

Parameters
[in]BaseAddressThe base address of the device.
[in]RegOffsetThe offset from the 1st register of the device to select the specific register.
[in]RegisterValueThe value to be written to the register.
Note
This macro does not do any checking to ensure that the register exists if the register may be excluded due to parameterization, such as the GPO Register. C-style signature void XIic_WriteReg(u32 BaseAddress, u32 RegOffset, u32 RegisterValue)

Referenced by EepromReadByte(), EepromWriteByte(), XIic_DynInit(), XIic_DynMasterRecv(), XIic_DynMasterSend(), XIic_MasterRecv(), XIic_MasterSend(), XIic_Recv(), XIic_Reset(), XIic_Send(), XIic_SetAddress(), XIic_SetGpOutput(), XIic_SetOptions(), XIic_SlaveRecv(), and XIic_Start().

#define XIic_WriteSendByte (   InstancePtr)
Value:
{ \
XIic_WriteReg(InstancePtr->BaseAddress, XIIC_DTR_REG_OFFSET, \
*InstancePtr->SendBufferPtr++); \
InstancePtr->SendByteCount--; \
InstancePtr->Stats.SendBytes++; \
}
#define XIic_WriteReg(BaseAddress, RegOffset, RegisterValue)
Writes to the specified IIC device register.
Definition: xiic_l.h:309
#define XIIC_DTR_REG_OFFSET
Data Tx Register.
Definition: xiic_l.h:100

Writes the next byte to be sent to the transmit FIFO.

This macro writes the next byte to be sent to the transmit FIFO and updates all the data structures to reflect it.

Parameters
[in]InstancePtrPointer to the IIC instance to be operated on.
Note
C-style signature void XIic_WriteSendByte(XIic *InstancePtr)

Referenced by XIic_TransmitFifoFill().

Function Documentation

int XIic_CfgInitialize ( XIic *  InstancePtr,
XIic_Config *  Config,
UINTPTR  EffectiveAddr 
)

Initializes a specific XIic instance.

Initializes a specific XIic instance. The initialization entails:

  • Initialize the driver to allow access to the device registers and initialize other subcomponents necessary for the operation of the device.
  • Default options to:
    • 7-bit slave addressing
    • Send messages as a slave device
    • Repeated start off
    • General call recognition disabled
  • Clear messageing and error statistics

The XIic_Start() function must be called after this function before the device is ready to send and receive data on the IIC bus.

Before XIic_Start() is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the application, and not XIic_Start(), to allow the use of any interrupt controller.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]ConfigReference to a structure containing information about a specific IIC device. This function can initialize multiple instance objects with the use of multiple calls giving different Config information on each call.
[in]EffectiveAddrThe device base address in the virtual memory address space. The caller is responsible for keeping the address mapping from EffectiveAddr to the device physical base address unchanged once this function is invoked. Unexpected errors may occur if the address mapping changes after this function is called. If address translation is not used, use Config->BaseAddress for this parameters, passing the physical address instead.
Returns
  • XST_SUCCESS when successful
  • XST_DEVICE_IS_STARTED indicates the device is started (that is interrupts enabled and messaging is possible). Must stop before re-initialization is allowed.

References XIic_Config::AxiClkFreq, XIic::AxiClkFreq, XIic::BaseAddress, XIic::BNBOnly, XIic_Config::GpOutWidth, XIic::GpOutWidth, XIic_Config::Has10BitAddr, XIic::Has10BitAddr, XIic::IsDynamic, XIic::IsReady, XIic::IsSlaveSetAckOff, XIic::IsStarted, XIic::Options, XIic::RecvBufferPtr, XIic::RecvHandler, XIic::SendBufferPtr, XIic::SendHandler, XIic_Config::SerialClkDelay, XIic::SerialClkDelay, XIic::StatusHandler, XIic_ClearStats(), and XIic_Reset().

Referenced by IicDynEepromExample(), IicEepromExample(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicPmbusPolledExample(), IicRepeatedStartExample(), IicSelfTestExample(), IicSlaveExample(), IicTenBitAddrExample(), TempSensorExample(), and XIic_Initialize().

u32 XIic_CheckIsBusBusy ( UINTPTR  BaseAddress)

Checks whether the I2C bus is busy or free.

This is a function which tells whether the I2C bus is busy or free.

Parameters
[in]BaseAddressThe base address of the I2C core to work on.
Returns
  • TRUE if the bus is busy.
  • FALSE if the bus is NOT busy.

References XIic_ReadReg, XIIC_SR_BUS_BUSY_MASK, and XIIC_SR_REG_OFFSET.

Referenced by XIic_WaitBusFree().

void XIic_ClearStats ( XIic *  InstancePtr)

Clears the statistics for the IIC device by zeroing all counts.

Clears the statistics for the IIC device by zeroing all counts.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.

References XIic::IsReady, and XIic::Stats.

Referenced by XIic_CfgInitialize().

int XIic_DynamicInitialize ( XIic *  InstancePtr)

Initializes the IIC core for dynamic functionality.

Initialize the IIC core for Dynamic Functionality.

Parameters
[in]InstancePtrPointer to the Iic instance to be worked on.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE otherwise.

References XIic::BaseAddress, and XIic_DynInit().

Referenced by IicDynEepromExample().

int XIic_DynInit ( UINTPTR  BaseAddress)

Initializes the IIC core for dynamic functionality.

Initialize the IIC core for Dynamic Functionality.

Parameters
[in]BaseAddressThe base address of the IIC Device.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE otherwise.

References IIC_RX_FIFO_DEPTH, XIIC_CR_ENABLE_DEVICE_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_TX_FIFO_RESET_MASK, XIic_ReadReg, XIIC_RESET_MASK, XIIC_RESETR_OFFSET, XIIC_RFD_REG_OFFSET, XIIC_SR_REG_OFFSET, XIIC_SR_RX_FIFO_EMPTY_MASK, XIIC_SR_TX_FIFO_EMPTY_MASK, and XIic_WriteReg.

Referenced by IicLowLevelDynEeprom(), and XIic_DynamicInitialize().

int XIic_DynMasterRecv ( XIic *  InstancePtr,
u8 *  RxMsgPtr,
u8  ByteCount 
)

Receives data as a master from a slave device on the IIC bus.

This function receives data as a master from a slave device on the IIC bus. If the bus is busy, it indicates so and then enable an interrupt such that the status handler is called when the bus is no longer busy. The slave address which has been set with the XIic_SetAddress() function is the address from which data is received. Receiving data on the bus performs a read operation.

Parameters
[in,out]InstancePtrPointer to the Iic instance to be worked on.
[out]RxMsgPtrPointer to the buffer to hold the data that is received.
[in]ByteCountThe number of message bytes to be received.
Returns
  • XST_SUCCESS indicates the message reception processes has been initiated.
  • XST_IIC_BUS_BUSY indicates the bus was in use and that the BusNotBusy interrupt is enabled which updates the EventStatus when the bus is no longer busy.
  • XST_IIC_GENERAL_CALL_ADDRESS indicates the slave address is set to the general call address. This is not allowed for Master receive mode.
Note
The receive FIFO threshold is a zero based count such that 1 must be subtracted from the desired count to get the correct value. When receiving data it is also necessary to not receive the last byte with the prior bytes because the acknowledge must be setup before the last byte is received.

References XIic::AddrOfSlave, XIic::BaseAddress, IIC_RX_FIFO_DEPTH, XIic::IsDynamic, XIic::RecvBufferPtr, XIic::RecvByteCount, XIicStats::RepeatedStarts, XIic::Stats, XIic::TxAddrMode, XIic_ClearEnableIntr, XIIC_CR_MSMS_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_REPEATED_START_MASK, XIIC_DYN_MASTER_INCLUDE, XIic_DynSend7BitAddress, XIic_DynSendStop, XIIC_INTR_RX_FULL_MASK, XIIC_INTR_TX_ERROR_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIIC_READ_OPERATION, XIic_ReadReg, XIIC_RFD_REG_OFFSET, XIic_SetControlRegister, XIIC_TX_ADDR_SENT, and XIic_WriteReg.

Referenced by DynEepromReadData().

int XIic_DynMasterSend ( XIic *  InstancePtr,
u8 *  TxMsgPtr,
u8  ByteCount 
)

Sends data as a Dynamic master on the IIC bus.

This function sends data as a Dynamic master on the IIC bus. If the bus is busy, it indicates so and then enable an interrupt such that the status handler is called when the bus is no longer busy. The slave address is sent by using XIic_DynSend7BitAddress().

Parameters
[in,out]InstancePtrPointer to the Iic instance to be worked on.
[in]TxMsgPtrPointer to the data to be transmitted.
[in]ByteCountThe number of message bytes to be sent.
Returns
  • XST_SUCCESS if successful.
  • XST_FAILURE otherwise.

References XIic::AddrOfSlave, XIic::BaseAddress, XIic::IsDynamic, XIicStats::RepeatedStarts, XIic::SendBufferPtr, XIic::SendByteCount, XIic::Stats, XIic::TxAddrMode, XIic_ClearEnableIntr, XIIC_CR_DIR_IS_TX_MASK, XIIC_CR_MSMS_MASK, XIIC_CR_NO_ACK_MASK, XIIC_CR_REG_OFFSET, XIIC_DYN_MASTER_INCLUDE, XIic_DynSend7BitAddress, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIIC_INTR_TX_HALF_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIIC_MASTER_ROLE, XIic_ReadReg, XIic_TransmitFifoFill(), XIIC_TX_ADDR_SENT, XIIC_WRITE_OPERATION, and XIic_WriteReg.

Referenced by DynEepromWriteData().

unsigned XIic_DynRecv ( UINTPTR  BaseAddress,
u8  Address,
u8 *  BufferPtr,
u8  ByteCount 
)

Receives data as a master on the IIC bus.

Receive data as a master on the IIC bus. This function receives the data using polled I/O and blocks until the data has been received. It only supports 7 bit addressing. This function returns zero if bus is busy.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]AddressThe 7 bit IIC Device address of the device to receive the data from.
[out]BufferPtrPointer to the buffer to hold the data that is received.
[in]ByteCountThe number of bytes to be received. This value can't be greater than 255 and needs to be greater than 0.
Returns
The number of bytes received.
Note
Upon entry to this function, the IIC interface needs to be already enabled in the CR register.

References XIic_ClearIisr, XIic_DynSend7BitAddress, XIic_DynSendStop, XIIC_INTR_ARB_LOST_MASK, XIIC_INTR_BNB_MASK, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIIC_READ_OPERATION, XIic_ReadReg, XIIC_SR_BUS_BUSY_MASK, XIIC_SR_REG_OFFSET, and XIic_WaitBusFree().

Referenced by EepromReadByte().

unsigned XIic_DynSend ( UINTPTR  BaseAddress,
u16  Address,
u8 *  BufferPtr,
u8  ByteCount,
u8  Option 
)

Sends data as a master on the IIC bus.

Send data as a master on the IIC bus. This function sends the data using polled I/O and blocks until the data has been sent. It only supports 7 bit addressing. This function returns zero if bus is busy.

Parameters
[in]BaseAddressThe base address of the IIC Device.
[in]AddressThe 7 bit IIC address of the device to send the specified data to.
[in]BufferPtrPointer to the data to be sent.
[in]ByteCountThe number of bytes to be sent.
[in]Option,:XIIC_STOP = end with STOP condition, XIIC_REPEATED_START = don't end with STOP condition.
Returns
The number of bytes sent.

References XIic_ClearIisr, XIic_DynSend7BitAddress, XIic_DynSendStartStopAddress, XIIC_INTR_ARB_LOST_MASK, XIIC_INTR_BNB_MASK, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIic_ReadReg, XIIC_SR_BUS_BUSY_MASK, XIIC_SR_REG_OFFSET, XIIC_TX_DYN_STOP_MASK, XIic_WaitBusFree(), and XIIC_WRITE_OPERATION.

Referenced by EepromReadByte(), and EepromWriteByte().

u16 XIic_GetAddress ( XIic *  InstancePtr,
int  AddressType 
)

Gets the addresses for the IIC device driver.

This function gets the addresses for the IIC device driver. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The address returned has the same format whether 7 or 10 bits.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[in]AddressTypeIndicates which address, the address which this responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument.
  XII_ADDR_TO_SEND_TYPE Slave being addressed as a master
  XII_ADDR_TO_RESPOND_TYPE      Slave address to respond to as a slave
If neither of the two valid arguments are used, the function returns the address of the slave device
Returns
The address retrieved.

References XIic::AddrOfSlave, XIic::BaseAddress, XIic::Has10BitAddr, XII_ADDR_TO_RESPOND_TYPE, XIIC_ADR_REG_OFFSET, XIic_ReadReg, and XIIC_TBA_REG_OFFSET.

int XIic_GetGpOutput ( XIic *  InstancePtr,
u8 *  OutputValuePtr 
)

Gets the contents of the IIC General Purpose Output register.

This function gets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[out]OutputValuePtrThe value which was read from the register.
Returns
  • XST_SUCCESS if the given data is read from the GPO register.
  • XST_NO_FEATURE if the hardware is configured such that this register does not contain any bits to read or write.

References XIic::BaseAddress, XIic::GpOutWidth, XIIC_GPO_REG_OFFSET, and XIic_ReadReg.

u32 XIic_GetOptions ( XIic *  InstancePtr)

Gets the current options for the IIC device.

This function gets the current options for the IIC device. Options control the how the device behaves on the IIC bus. See SetOptions for more information on options.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
Returns
The options of the IIC device. See xiic.h for a list of available options.
Note
Options enabled have a 1 in its appropriate bit position.

References XIic::Options.

void XIic_GetStats ( XIic *  InstancePtr,
XIicStats *  StatsPtr 
)

Gets a copy of the statistics for an IIC device.

Gets a copy of the statistics for an IIC device.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[out]StatsPtrPointer to a XIicStats structure which gets a copy of current statistics.

References XIic::IsReady, and XIic::Stats.

int XIic_Initialize ( XIic *  InstancePtr,
UINTPTR  BaseAddress 
)

Initializes a specific XIic instance.

Initializes a specific XIic instance. The initialization entails:

  • Check the device has an entry in the configuration table.
  • Initialize the driver to allow access to the device registers and initialize other subcomponents necessary for the operation of the device.
  • Default options to:
    • 7-bit slave addressing
    • Send messages as a slave device
    • Repeated start off
    • General call recognition disabled
  • Clear messageing and error statistics

The XIic_Start() function must be called after this function before the device is ready to send and receive data on the IIC bus.

Before XIic_Start() is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the application, and not XIic_Start(), to allow the use of any interrupt controller.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[in]BaseAddressThe base address of the device.
Returns
  • XST_SUCCESS when successful
  • XST_DEVICE_NOT_FOUND indicates the given device id/BaseAddress isn't found
  • XST_DEVICE_IS_STARTED indicates the device is started (that is interrupts enabled and messaging is possible). Must stop before re-initialization is allowed.
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XIic_Config::BaseAddress, XIic_CfgInitialize(), and XIic_LookupConfig().

void XIic_InterruptHandler ( void *  InstancePtr)
u32 XIic_IsSlave ( XIic *  InstancePtr)

Determines if the device is currently addressed as a slave.

A function to determine if the device is currently addressed as a slave.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
Returns
  • TRUE if the device is addressed as slave.
  • FALSE if the device is NOT addressed as slave.

References XIic::BaseAddress, XIic_ReadReg, XIIC_SR_ADDR_AS_SLAVE_MASK, and XIIC_SR_REG_OFFSET.

XIic_Config* XIic_LookupConfig ( UINTPTR  BaseAddress)

Looks up the device configuration by unique device ID or base address.

Looks up the device configuration based on the unique device ID/BaseAddress. The XIic_ConfigTable[] contains the configuration info for each device in the system.

Parameters
[in]BaseAddressThe base address of the device.
Returns
A pointer to the configuration found or NULL if the specified device ID/BaseAddress was not found. See xiic.h for the definition of XIic_Config.
Note
In XSCT/classic flow, DeviceId is used to look up the device configuration.

References XIic_Config::Name, and XIic_ConfigTable.

Referenced by IicDynEepromExample(), IicEepromExample(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicPmbusPolledExample(), IicRepeatedStartExample(), IicSelfTestExample(), IicSlaveExample(), IicTenBitAddrExample(), TempSensorExample(), and XIic_Initialize().

int XIic_MasterRecv ( XIic *  InstancePtr,
u8 *  RxMsgPtr,
int  ByteCount 
)

Receives data as a master from a slave device on the IIC bus.

This function receives data as a master from a slave device on the IIC bus. If the bus is busy, it indicates so and then enable an interrupt such that the status handler is called when the bus is no longer busy. The slave address which has been set with the XIic_SetAddress() function is the address from which data is received. Receiving data on the bus performs a read operation.

Parameters
[in,out]InstancePtrPointer to the Iic instance to be worked on.
[out]RxMsgPtrPointer to the buffer to hold the data that is received.
[in]ByteCountThe number of message bytes to be received.
Returns
  • XST_SUCCESS indicates the message reception processes has been initiated.
  • XST_IIC_BUS_BUSY indicates the bus was in use and that the BusNotBusy interrupt is enabled which updates the EventStatus when the bus is no longer busy.
  • XST_IIC_GENERAL_CALL_ADDRESS indicates the slave address is set to the general call address. This is not allowed for Master receive mode.

References XIic::AddrOfSlave, XIic::BaseAddress, IIC_RX_FIFO_DEPTH, XIic::IsDynamic, XIic::Options, XIic::RecvBufferPtr, XIic::RecvByteCount, XIicStats::RepeatedStarts, XIic::SendBufferPtr, XIic::Stats, XIic::TxAddrMode, XII_SEND_10_BIT_OPTION, XIic_ClearEnableIntr, XIIC_CR_MSMS_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_REPEATED_START_MASK, XIIC_INTR_RX_FULL_MASK, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIIC_MASTER_INCLUDE, XIIC_READ_OPERATION, XIic_ReadReg, XIIC_RFD_REG_OFFSET, XIic_Send10BitAddrByte1, XIic_Send10BitAddrByte2, XIic_Send7BitAddr, XIic_SetControlRegister, XIIC_TX_ADDR_MSTR_RECV_MASK, XIIC_TX_ADDR_SENT, XIIC_WRITE_OPERATION, and XIic_WriteReg.

Referenced by EepromReadData(), and TempSensorExample().

int XIic_MasterSend ( XIic *  InstancePtr,
u8 *  TxMsgPtr,
int  ByteCount 
)

Sends data as a master on the IIC bus.

This function sends data as a master on the IIC bus. If the bus is busy, it indicates so and then enable an interrupt such that the status handler is called when the bus is no longer busy. The slave address which has been set with the XIic_SetAddress() function is the address to which the specific data is sent. Sending data on the bus performs a write operation.

Parameters
[in,out]InstancePtrPointer to the Iic instance to be worked on.
[in]TxMsgPtrPointer to the data to be transmitted.
[in]ByteCountThe number of message bytes to be sent.
Returns
  • XST_SUCCESS indicates the message transmission has been initiated.
  • XST_IIC_BUS_BUSY indicates the bus was in use and that the BusNotBusy interrupt is enabled which updates the EventStatus when the bus is no longer busy.

References XIic::AddrOfSlave, XIic::BaseAddress, XIic::IsDynamic, XIic::Options, XIic::RecvBufferPtr, XIicStats::RepeatedStarts, XIic::SendBufferPtr, XIic::SendByteCount, XIic::Stats, XIic::TxAddrMode, XII_SEND_10_BIT_OPTION, XIic_ClearEnableIntr, XIIC_CR_DIR_IS_TX_MASK, XIIC_CR_MSMS_MASK, XIIC_CR_NO_ACK_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_REPEATED_START_MASK, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIIC_INTR_TX_HALF_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIIC_MASTER_INCLUDE, XIIC_MASTER_ROLE, XIic_ReadReg, XIic_Send10BitAddrByte1, XIic_Send10BitAddrByte2, XIic_Send7BitAddr, XIic_TransmitFifoFill(), XIIC_TX_ADDR_SENT, XIIC_WRITE_OPERATION, and XIic_WriteReg.

Referenced by DynEepromWriteData(), EepromWriteData(), and IicMultiMasterExample().

void XIic_MultiMasterInclude ( void  )

Includes multi-master code so multi-master events are handled.

This function includes multi-master code such that multi-master events are handled properly. Multi-master events include a loss of arbitration and the bus transitioning from busy to not busy. This function allows the multi-master processing to be optional. This function must be called prior to allowing any multi-master events to occur, such as after the driver is initialized.

Referenced by IicMultiMasterExample().

unsigned XIic_Recv ( UINTPTR  BaseAddress,
u8  Address,
u8 *  BufferPtr,
unsigned  ByteCount,
u8  Option 
)

Receives data as a master on the IIC bus.

Receive data as a master on the IIC bus. This function receives the data using polled I/O and blocks until the data has been received. It only supports 7 bit addressing mode of operation. This function returns zero if bus is busy.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]AddressThe 7 bit IIC address of the device to receive the data from.
[out]BufferPtrPointer to the buffer to hold the data that is received.
[in]ByteCountThe number of bytes to be received.
[in]OptionIndicates whether to hold or free the bus after reception of data, XIIC_STOP = end with STOP condition, XIIC_REPEATED_START = don't end with STOP condition.
Returns
The number of bytes received.

References XIic_ClearIisr, XIIC_CR_DIR_IS_TX_MASK, XIIC_CR_ENABLE_DEVICE_MASK, XIIC_CR_MSMS_MASK, XIIC_CR_NO_ACK_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_REPEATED_START_MASK, XIIC_INTR_ARB_LOST_MASK, XIIC_INTR_BNB_MASK, XIIC_INTR_RX_FULL_MASK, XIIC_INTR_TX_ERROR_MASK, XIIC_READ_OPERATION, XIic_ReadReg, XIIC_RFD_REG_OFFSET, XIic_Send7BitAddress, XIIC_SR_BUS_BUSY_MASK, XIIC_SR_REG_OFFSET, XIic_WaitBusFree(), and XIic_WriteReg.

Referenced by EepromReadByte(), and LowLevelTempSensorExample().

void XIic_Reset ( XIic *  InstancePtr)

Resets the IIC device.

Resets the IIC device.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
Note
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. Refer to the HW specification for further details about this.

References XIic::BaseAddress, XIic::IsReady, XIIC_RESET_MASK, XIIC_RESETR_OFFSET, and XIic_WriteReg.

Referenced by XIic_CfgInitialize(), and XIic_SelfTest().

int XIic_SelfTest ( XIic *  InstancePtr)

Runs a limited self-test on the driver/device.

Runs a limited self-test on the driver/device. This test does a read/write test of the Interrupt Registers There is no loopback capabilities for the device such that this test does not send or receive data.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
Returns
  • XST_SUCCESS if no errors are found
  • XST_FAILURE if errors are found

References XIic::BaseAddress, XIic::IsReady, XIic_IntrGlobalEnable, XIic_IsIntrGlobalEnabled, XIic_ReadIier, XIic_Reset(), XIIC_TX_RX_INTERRUPTS, and XIic_WriteIier.

Referenced by IicSelfTestExample().

unsigned XIic_Send ( UINTPTR  BaseAddress,
u8  Address,
u8 *  BufferPtr,
unsigned  ByteCount,
u8  Option 
)

Sends data as a master on the IIC bus.

Send data as a master on the IIC bus. This function sends the data using polled I/O and blocks until the data has been sent. It only supports 7 bit addressing mode of operation. This function returns zero if bus is busy.

Parameters
[in]BaseAddressThe base address of the IIC device.
[in]AddressThe 7 bit IIC address of the device to send the specified data to.
[in]BufferPtrPointer to the data to be sent.
[in]ByteCountThe number of bytes to be sent.
[in]OptionIndicates whether to hold or free the bus after transmitting the data.
Returns
The number of bytes sent.

References XIic_ClearIisr, XIIC_CR_DIR_IS_TX_MASK, XIIC_CR_ENABLE_DEVICE_MASK, XIIC_CR_MSMS_MASK, XIIC_CR_REG_OFFSET, XIIC_CR_REPEATED_START_MASK, XIIC_INTR_ARB_LOST_MASK, XIIC_INTR_BNB_MASK, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIic_ReadReg, XIic_Send7BitAddress, XIIC_SR_ADDR_AS_SLAVE_MASK, XIIC_SR_BUS_BUSY_MASK, XIIC_SR_REG_OFFSET, XIic_WaitBusFree(), XIIC_WRITE_OPERATION, and XIic_WriteReg.

Referenced by EepromReadByte(), and EepromWriteByte().

int XIic_SetAddress ( XIic *  InstancePtr,
int  AddressType,
int  Address 
)

Sets the bus addresses.

This function sets the bus addresses. The addresses include the device address that the device responds to as a slave, or the slave address to communicate with on the bus. The IIC device hardware is built to allow either 7 or 10 bit slave addressing only at build time rather than at run time. When this device is a master, slave addressing can be selected at run time to match addressing modes for other bus devices.

Addresses are represented as hex values with no adjustment for the data direction bit as the software manages address bit placement. Example: For a 7 address written to the device of 1010 011X where X is the transfer direction (send/recv), the address parameter for this function needs to be 01010011 or 0x53 where the correct bit alignment is handled for 7 as well as 10 bit devices. This is especially important as the bit placement is not handled the same depending on which options are used such as repeated start.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]AddressTypeIndicates which address is being modified, the address which this device responds to on the IIC bus as a slave, or the slave address to communicate with when this device is a master. One of the following values must be contained in this argument.
  XII_ADDR_TO_SEND_TYPE Slave being addressed by a this master
  XII_ADDR_TO_RESPOND_TYPE      Address to respond to as a slave device
[in]AddressThe address to be set, 7 bit or 10 bit address. A ten bit address must be within the range: 0 - 1023 and a 7 bit address must be within the range 0 - 127.
Returns
  • XST_SUCCESS is returned if the address was successfully set.
  • XST_IIC_NO_10_BIT_ADDRESSING indicates only 7 bit addressing supported.
  • XST_INVALID_PARAM indicates an invalid parameter was specified.
Note
Upper bits of 10-bit address is written only when current device is built as a ten bit device.

References XIic::AddrOfSlave, XIic::BaseAddress, XIic::Has10BitAddr, XII_ADDR_TO_RESPOND_TYPE, XII_ADDR_TO_SEND_TYPE, XIIC_ADR_REG_OFFSET, XIIC_TBA_REG_OFFSET, and XIic_WriteReg.

Referenced by IicDynEepromExample(), IicEepromExample(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicRepeatedStartExample(), IicSlaveExample(), IicTenBitAddrExample(), and TempSensorExample().

u32 XIic_SetClk ( XIic *  InstancePtr,
u32  FsclHz 
)

Sets the serial clock rate for the IIC device.

The device must be idle before setting these device options. The timing register values are calculated according to the input clock frequency and configured scl frequency. For details, refer to the AXI I2C PG and NXP I2C Spec.

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[in]FsclHzClock frequency in Hz(100kHz, 400kHz, 1MHz).
Returns
  • XST_SUCCESS if options are successfully set.
  • XST_DEVICE_IS_STARTED if the device is currently transferring data. The transfer must complete or be aborted before setting options.
  • XST_INVALID_PARAM if frequency is unsupported or invalid.

References XIic::AxiClkFreq, XIic::BaseAddress, XIic::IsReady, XIic::SerialClkDelay, XIIC_DTR_REG_OFFSET, XIIC_FAST_MODE, XIIC_FAST_MODE_PLUS, XIIC_NANOSEC_TO_SEC_DIVISOR, XIic_Out32, XIic_ReadReg, XIIC_REG_VALUES_100KHZ, XIIC_REG_VALUES_1MHZ, XIIC_REG_VALUES_400KHZ, XIIC_STANDARD_MODE, XIIC_TBUF_REG_OFFSET, XIIC_THDDAT_REG_OFFSET, XIIC_THDSTA_REG_OFFSET, XIIC_THIGH_REG_OFFSET, XIIC_TLOW_REG_OFFSET, XIIC_TSUDAT_REG_OFFSET, XIIC_TSUSTA_REG_OFFSET, and XIIC_TSUSTO_REG_OFFSET.

int XIic_SetGpOutput ( XIic *  InstancePtr,
u8  OutputValue 
)

Sets the contents of the IIC General Purpose Output register.

This function sets the contents of the General Purpose Output register for the IIC device driver. Note that the number of bits in this register is parameterizable in the hardware such that it may not exist. This function checks to ensure that it does exist to prevent bus errors, but does not ensure that the number of bits in the register are sufficient for the value being written (won't cause a bus error).

Parameters
[in]InstancePtrPointer to the XIic instance to be worked on.
[in]OutputValueThe value to be written to the register.
Returns
  • XST_SUCCESS if the given data is written to the GPO register.
  • XST_NO_FEATURE if the hardware is configured such that this register does not contain any bits to read or write.

References XIic::BaseAddress, XIic::GpOutWidth, XIIC_GPO_REG_OFFSET, and XIic_WriteReg.

void XIic_SetOptions ( XIic *  InstancePtr,
u32  NewOptions 
)

Sets the options for the IIC device driver.

This function sets the options for the IIC device driver. The options control how the device behaves relative to the IIC bus. If an option applies to how messages are sent or received on the IIC bus, it must be set prior to calling functions which send or receive data.

To set multiple options, the values must be ORed together. To not change existing options, read/modify/write with the current options using XIic_GetOptions().

USAGE EXAMPLE:

Read/modify/write to enable repeated start:

  u8 Options;
  Options = XIic_GetOptions(&Iic);
  XIic_SetOptions(&Iic, Options | XII_REPEATED_START_OPTION);

Disabling General Call:

  Options = XIic_GetOptions(&Iic);
  XIic_SetOptions(&Iic, Options &= ~XII_GENERAL_CALL_OPTION);
Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]NewOptionsThe options to be set. See xiic.h for a list of the available options.
Note
Sending or receiving messages with repeated start enabled, and then disabling repeated start, does not take effect until another master transaction is completed. That is, after using repeated start, the bus continues to be throttled after repeated start is disabled until a master transaction occurs allowing the IIC to release the bus.

Options enabled have a 1 in its appropriate bit position.

References XIic::BaseAddress, XIic::Options, XII_GENERAL_CALL_OPTION, XIIC_CR_GENERAL_CALL_MASK, XIIC_CR_REG_OFFSET, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIic_ReadReg, and XIic_WriteReg.

Referenced by IicTenBitAddrExample().

void XIic_SetRecvHandler ( XIic *  InstancePtr,
void *  CallBackRef,
XIic_Handler  FuncPtr 
)

Sets the receive handler that the driver calls after receiving data.

Sets the receive callback function, the receive handler, which the driver calls when it finishes receiving data. The number of bytes used to signal when the receive is complete is the number of bytes set in the XIic_Recv function.

The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context.

The number of bytes received is passed to the handler as an argument.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]CallBackRefThe upper layer callback reference passed back when the callback function is invoked.
[in]FuncPtrPointer to the callback function.
Note
The handler is called within interrupt context.

References XIic::IsReady, XIic::RecvCallBackRef, and XIic::RecvHandler.

Referenced by IicDynEepromExample(), IicEepromExample(), IicPmbusInterruptSdtExample(), IicRepeatedStartExample(), IicSlaveExample(), IicTenBitAddrExample(), and TempSensorExample().

void XIic_SetSendHandler ( XIic *  InstancePtr,
void *  CallBackRef,
XIic_Handler  FuncPtr 
)

Sets the send handler called on confirmation of sent data.

Sets the send callback function, the send handler, which the driver calls when it receives confirmation of sent data. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context.

Parameters
[in,out]InstancePtrThe pointer to the XIic instance to be worked on.
[in]CallBackRefThe upper layer callback reference passed back when the callback function is invoked.
[in]FuncPtrThe pointer to the callback function.
Note
The handler is called within interrupt context.

References XIic::IsReady, XIic::SendCallBackRef, and XIic::SendHandler.

Referenced by IicDynEepromExample(), IicEepromExample(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicRepeatedStartExample(), IicSlaveExample(), and IicTenBitAddrExample().

void XIic_SetStatusHandler ( XIic *  InstancePtr,
void *  CallBackRef,
XIic_StatusHandler  FuncPtr 
)

Sets the status handler for events that are not data related.

Sets the status callback function, the status handler, which the driver calls when it encounters conditions which are not data related. The handler executes in an interrupt context such that it must minimize the amount of processing performed such as transferring data to a thread context. The status events that can be returned are described in xiic.h.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]CallBackRefThe upper layer callback reference passed back when the callback function is invoked.
[in]FuncPtrPointer to the callback function.
Note
The handler is called within interrupt context.

References XIic::IsReady, XIic::StatusCallBackRef, and XIic::StatusHandler.

Referenced by IicDynEepromExample(), IicEepromExample(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicRepeatedStartExample(), IicSlaveExample(), IicTenBitAddrExample(), and TempSensorExample().

void XIic_SlaveInclude ( void  )

Includes slave code so slave events are processed.

This function includes slave code such that slave events are processed. It is necessary to allow slave code to be optional to reduce the size of the driver. This function may be called at any time but must be prior to being selected as a slave on the IIC bus. This function may be called prior to the Cfg_Initialize() function and must be called before any functions in this file are called.

Referenced by IicSlaveExample(), and IicTenBitAddrExample().

int XIic_SlaveRecv ( XIic *  InstancePtr,
u8 *  RxMsgPtr,
int  ByteCount 
)

Receives data as a slave on the IIC bus.

This function receives data as a slave on the IIC bus and should not be called until an event has occurred that indicates the device has been selected by a master writing to the slave (XII_MASTER_WRITE_EVENT).

If more data is received than specified a No Acknowledge is sent to signal the Master to stop sending data. Any received data is read to prevent the slave device from throttling the bus.

Parameters
[in,out]InstancePtrPointer to the Iic instance to be worked on.
[out]RxMsgPtrPointer to the buffer to hold the data that is received.
[in]ByteCountThe number of message bytes to be received.
Returns
  • XST_SUCCESS indicates the message reception has been initiated.
  • XST_IIC_NOT_SLAVE indicates the device has not been selected to be a slave on the IIC bus such that data cannot be received.

References XIic::BaseAddress, IIC_RX_FIFO_DEPTH, XIic::RecvBufferPtr, XIic::RecvByteCount, XIic::SendBufferPtr, XIic_ClearIntr, XIic_EnableIntr, XIIC_INTR_RX_FULL_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIic_ReadReg, XIIC_RFD_REG_OFFSET, XIIC_SR_ADDR_AS_SLAVE_MASK, XIIC_SR_REG_OFFSET, and XIic_WriteReg.

Referenced by SlaveReadData(), and TenBitAddrReadData().

int XIic_SlaveSend ( XIic *  InstancePtr,
u8 *  TxMsgPtr,
int  ByteCount 
)

Sends data as a slave on the IIC bus.

This function sends data as a slave on the IIC bus and should not be called until an event has occurred that indicates the device has been selected by a master attempting read from the slave (XII_MASTER_READ_EVENT).

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]TxMsgPtrPointer to the data to be transmitted.
[in]ByteCountThe number of message bytes to be sent.
Returns
  • XST_SUCCESS indicates the message transmission has been initiated.
  • XST_IIC_NOT_SLAVE indicates the device has not been selected to be a slave on the IIC bus such that data cannot be sent.

References XIic::BaseAddress, XIic::RecvBufferPtr, XIic::SendBufferPtr, XIic::SendByteCount, XIic_ClearEnableIntr, XIIC_INTR_TX_EMPTY_MASK, XIIC_INTR_TX_ERROR_MASK, XIIC_INTR_TX_HALF_MASK, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIic_ReadReg, XIIC_SLAVE_ROLE, XIIC_SR_ADDR_AS_SLAVE_MASK, XIIC_SR_REG_OFFSET, and XIic_TransmitFifoFill().

Referenced by SlaveWriteData(), and TenBitAddrWriteData().

int XIic_Start ( XIic *  InstancePtr)

Starts the IIC device and driver by enabling the proper interrupts.

This function starts the IIC device and driver by enabling the proper interrupts such that data may be sent and received on the IIC bus. This function must be called before the functions to send and receive data.

Before XIic_Start() is called, the interrupt control must connect the ISR routine to the interrupt handler. This is done by the application, and not XIic_Start(), to allow the use of any interrupt controller.

Start enables:

  • IIC device
  • Interrupts:
    • Addressed as slave to allow messages from another master
    • Arbitration Lost to detect Tx arbitration errors
    • Global IIC interrupt
Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
Returns
XST_SUCCESS always.
Note
The device interrupt is connected to the interrupt controller, but no "messaging" interrupts are enabled. Addressed as Slave is enabled to reception of messages when this devices address is written to the bus. The correct messaging interrupts are enabled when sending or receiving via the IicSend() and IicRecv() functions. No action is required by the application to control any IIC interrupts as the driver completely manages all 8 interrupts. Start and Stop control the ability to use the device. Stopping the device completely stops all device interrupts from the processor.

References XIic::BaseAddress, XIic::IsDynamic, XIic::IsReady, XIic::IsStarted, XIic_ClearEnableIntr, XIic_ClearIntr, XIIC_CR_ENABLE_DEVICE_MASK, XIIC_CR_REG_OFFSET, XIIC_INTR_AAS_MASK, XIIC_INTR_ARB_LOST_MASK, XIic_IntrGlobalEnable, XIIC_RFD_REG_OFFSET, XIic_WriteIier, and XIic_WriteReg.

Referenced by DynEepromReadData(), DynEepromWriteData(), EepromReadData(), EepromWriteData(), IicMultiMasterExample(), IicPmbusInterruptSdtExample(), IicPmbusPolledExample(), SlaveReadData(), SlaveWriteData(), TempSensorExample(), TenBitAddrReadData(), and TenBitAddrWriteData().

int XIic_Stop ( XIic *  InstancePtr)

Stops the IIC device and driver.

This function stops the IIC device and driver such that data is no longer sent or received on the IIC bus. This function stops the device by disabling interrupts. This function only disables interrupts within the device such that the caller is responsible for disconnecting the interrupt handler of the device from the interrupt source and disabling interrupts at other levels.

Due to bus throttling that could hold the bus between messages when using repeated start option, stop does not occur when the device is actively sending or receiving data from the IIC bus or the bus is being throttled by this device, but instead return XST_IIC_BUS_BUSY.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
Returns
  • XST_SUCCESS indicates all IIC interrupts are disabled. No messages can be received or transmitted until XIic_Start() is called.
  • XST_IIC_BUS_BUSY indicates this device is currently engaged in message traffic and cannot be stopped.

References XIic::BaseAddress, XIic::IsStarted, XIIC_CR_MSMS_MASK, XIIC_CR_REG_OFFSET, XIic_IntrGlobalDisable, XIic_IntrGlobalEnable, XIic_ReadReg, XIIC_SR_ADDR_AS_SLAVE_MASK, and XIIC_SR_REG_OFFSET.

Referenced by DynEepromReadData(), DynEepromWriteData(), EepromReadData(), EepromWriteData(), IicMultiMasterExample(), SlaveReadData(), SlaveWriteData(), TenBitAddrReadData(), and TenBitAddrWriteData().

void XIic_TransmitFifoFill ( XIic *  InstancePtr,
int  Role 
)

Fills the FIFO using the occupancy register to find available space.

This function fills the FIFO using the occupancy register to determine the available space to be filled. When the repeated start option is on, the last byte is withheld to allow the control register to be properly set on the last byte.

Parameters
[in,out]InstancePtrPointer to the XIic instance to be worked on.
[in]RoleIndicates the role of this IIC device, a slave or a master, on the IIC bus (XIIC_SLAVE_ROLE or XIIC_MASTER_ROLE).

References XIic::BaseAddress, IIC_TX_FIFO_DEPTH, XIic::Options, XIic::SendByteCount, XII_REPEATED_START_OPTION, XIic_ReadReg, XIIC_SLAVE_ROLE, XIIC_TFO_REG_OFFSET, and XIic_WriteSendByte.

Referenced by XIic_DynMasterSend(), XIic_MasterSend(), and XIic_SlaveSend().

u32 XIic_WaitBusFree ( UINTPTR  BaseAddress)

Waits until the I2C bus is free or a timeout occurs.

This function waits until the I2C bus is free or timeout.

Parameters
[in]BaseAddressThe base address of the I2C device.
Returns
  • XST_SUCCESS if the I2C bus was freed before the timeout.
  • XST_FAILURE otherwise.

References XIic_CheckIsBusBusy().

Referenced by XIic_DynRecv(), XIic_DynSend(), XIic_Recv(), and XIic_Send().

Variable Documentation

XIic_Config XIic_ConfigTable[XPAR_XIIC_NUM_INSTANCES]
Initial value:
= {
{
XPAR_IIC_0_DEVICE_ID,
XPAR_IIC_0_BASEADDR,
XPAR_IIC_0_TEN_BIT_ADR,
XPAR_IIC_0_GPO_WIDTH
}
,
{
XPAR_IIC_1_DEVICE_ID,
XPAR_IIC_1_BASEADDR,
XPAR_IIC_1_TEN_BIT_ADR,
XPAR_IIC_1_GPO_WIDTH
}
}

Holds the IIC configuration table.

Sized by the instance count in xparameters.h.

Referenced by XIic_LookupConfig().

XIic_Config XIic_ConfigTable[]

Holds the IIC configuration table.

Sized by the instance count in xparameters.h.

Referenced by XIic_LookupConfig().