iicps
Xilinx SDK Drivers API Documentation
Iicps_v3_7

Functions

s32 TransmitFifoFill (XIicPs *InstancePtr)
 Put more data into the transmit FIFO, number of bytes is ether expected number of bytes for this transfer or available space in FIFO, which ever is less. More...
 
void XIicPs_SetupSlave (XIicPs *InstancePtr, u16 SlaveAddr)
 This function sets up the device to be a slave. More...
 
void XIicPs_SlaveSend (XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
 This function setup a slave interrupt-driven send. More...
 
void XIicPs_SlaveRecv (XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
 This function setup a slave interrupt-driven receive. More...
 
s32 XIicPs_SlaveSendPolled (XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
 This function sends a buffer in polled mode as a slave. More...
 
s32 XIicPs_SlaveRecvPolled (XIicPs *InstancePtr, u8 *MsgPtr, s32 ByteCount)
 This function receives a buffer in polled mode as a slave. More...
 
void XIicPs_SlaveInterruptHandler (XIicPs *InstancePtr)
 The interrupt handler for slave mode. More...
 

Function Documentation

◆ TransmitFifoFill()

s32 TransmitFifoFill ( XIicPs InstancePtr)

#include <xiicps_slave.c>

Put more data into the transmit FIFO, number of bytes is ether expected number of bytes for this transfer or available space in FIFO, which ever is less.

Parameters
InstancePtris a pointer to the XIicPs instance.
Returns
Number of bytes left for this instance.
Note
This is function is shared by master and slave.

References XIicPs_Config::BaseAddress, XIICPS_FIFO_DEPTH, XIicPs_ReadReg, XIicPs_SendByte, and XIICPS_TRANS_SIZE_OFFSET.

Referenced by XIicPs_SlaveInterruptHandler().

◆ XIicPs_SetupSlave()

void XIicPs_SetupSlave ( XIicPs InstancePtr,
u16  SlaveAddr 
)

#include <xiicps_slave.c>

This function sets up the device to be a slave.

Parameters
InstancePtris a pointer to the XIicPs instance.
SlaveAddris the address of the slave we are receiving from.
Returns
None.
Note
Interrupt is always enabled no matter the tranfer is interrupt- driven or polled mode. Whether device will be interrupted or not depends on whether the device is connected to an interrupt controller and interrupt for the device is enabled.

References XIicPs_Config::BaseAddress, and XIICPS_ADDR_MASK.

Referenced by IicPsSlavePolledExample().

◆ XIicPs_SlaveInterruptHandler()

void XIicPs_SlaveInterruptHandler ( XIicPs InstancePtr)

#include <xiicps_slave.c>

The interrupt handler for slave mode.

It does the protocol handling for the interrupt-driven transfers.

Completion events and errors are signaled to upper layer for proper handling.

The interrupts that are handled are:
  • DATA If the instance is sending, it means that the master wants to read more data from us. Send more data, and check whether we are done with this send.

    If the instance is receiving, it means that the master has writen more data to us. Receive more data, and check whether we are done with with this receive.

  • COMP This marks that stop sequence has been sent from the master, transfer is about to terminate. However, for receiving, the master may have written us some data, so receive that first.

    It is an error if the amount of transfered data is less than expected.

  • NAK This marks that master does not want our data. It is for send only.
  • Other interrupts These interrupts are marked as error.
Parameters
InstancePtris a pointer to the XIicPs instance.
Returns
None.
Note
None.

References XIicPs_Config::BaseAddress, TransmitFifoFill(), XIICPS_EVENT_COMPLETE_SEND, XIICPS_IMR_OFFSET, XIICPS_ISR_OFFSET, XIICPS_IXR_DATA_MASK, XIicPs_ReadReg, and XIicPs_WriteReg.

◆ XIicPs_SlaveRecv()

void XIicPs_SlaveRecv ( XIicPs InstancePtr,
u8 *  MsgPtr,
s32  ByteCount 
)

#include <xiicps_slave.c>

This function setup a slave interrupt-driven receive.

Data processing for the receive is handled by the interrupt handler.

Parameters
InstancePtris a pointer to the XIicPs instance.
MsgPtris the pointer to the receive buffer.
ByteCountis the number of bytes to be received.
Returns
None.
Note
This routine is for interrupt-driven transfer only.

References XIicPs_Config::BaseAddress, XIicPs_EnableInterrupts, XIICPS_IXR_COMP_MASK, XIICPS_IXR_DATA_MASK, XIICPS_IXR_NACK_MASK, XIICPS_IXR_RX_OVR_MASK, XIICPS_IXR_RX_UNF_MASK, and XIICPS_IXR_TO_MASK.

◆ XIicPs_SlaveRecvPolled()

s32 XIicPs_SlaveRecvPolled ( XIicPs InstancePtr,
u8 *  MsgPtr,
s32  ByteCount 
)

#include <xiicps_slave.c>

This function receives a buffer in polled mode as a slave.

Parameters
InstancePtris a pointer to the XIicPs instance.
MsgPtris the pointer to the receive buffer.
ByteCountis the number of bytes to be received.
Returns
  • XST_SUCCESS if everything went well.
  • XST_FAILURE if timed out.
Note
This receive routine is for polled mode transfer only.

References XIicPs_Config::BaseAddress, XIICPS_ISR_OFFSET, XIICPS_IXR_COMP_MASK, XIICPS_IXR_DATA_MASK, XIicPs_ReadReg, XIicPs_RecvByte, XIICPS_SR_OFFSET, XIICPS_SR_RXDV_MASK, and XIicPs_WriteReg.

◆ XIicPs_SlaveSend()

void XIicPs_SlaveSend ( XIicPs InstancePtr,
u8 *  MsgPtr,
s32  ByteCount 
)

#include <xiicps_slave.c>

This function setup a slave interrupt-driven send.

It set the repeated start for the device is the tranfer size is larger than FIFO depth. Data processing for the send is initiated by the interrupt handler.

Parameters
InstancePtris a pointer to the XIicPs instance.
MsgPtris the pointer to the send buffer.
ByteCountis the number of bytes to be sent.
Returns
None.
Note
This send routine is for interrupt-driven transfer only.

References XIicPs_Config::BaseAddress, XIicPs_EnableInterrupts, XIICPS_IXR_COMP_MASK, XIICPS_IXR_DATA_MASK, XIICPS_IXR_NACK_MASK, XIICPS_IXR_TO_MASK, and XIICPS_IXR_TX_OVR_MASK.

◆ XIicPs_SlaveSendPolled()

s32 XIicPs_SlaveSendPolled ( XIicPs InstancePtr,
u8 *  MsgPtr,
s32  ByteCount 
)

#include <xiicps_slave.c>

This function sends a buffer in polled mode as a slave.

Parameters
InstancePtris a pointer to the XIicPs instance.
MsgPtris the pointer to the send buffer.
ByteCountis the number of bytes to be sent.
Returns
  • XST_SUCCESS if everything went well.
  • XST_FAILURE if master sends us data or master terminates the transfer before all data has sent out.
Note
This send routine is for polled mode transfer only.

References XIicPs_Config::BaseAddress, XIICPS_FIFO_DEPTH, XIICPS_ISR_OFFSET, XIICPS_IXR_NACK_MASK, XIicPs_ReadReg, XIicPs_SendByte, XIICPS_SR_OFFSET, XIICPS_SR_RXDV_MASK, XIICPS_SR_RXRW_MASK, XIICPS_SR_TXDV_MASK, and XIicPs_WriteReg.