libpynq (release 5EWC0-2023 version 0.2.2 of 2023-09-24 22:22)
Loading...
Searching...
No Matches
xiic_l.c File Reference
#include <unistd.h>
#include "xiic_l.h"
#include "xil_types.h"
Include dependency graph for xiic_l.c:

Go to the source code of this file.

Macros

#define _DEFAULT_SOURCE
 

Functions

unsigned XIic_Recv (UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)
 
unsigned XIic_Send (UINTPTR BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)
 
u32 XIic_CheckIsBusBusy (UINTPTR BaseAddress)
 
u32 XIic_WaitBusFree (UINTPTR BaseAddress)
 

Macro Definition Documentation

◆ _DEFAULT_SOURCE

#define _DEFAULT_SOURCE

This file contains low-level driver functions that can be used to access the device in normal and dynamic controller mode. The user should refer to the hardware device specification for more details of the device operation.

MODIFICATION HISTORY:

Ver   Who  Date     Changes
----- --- -------   -----------------------------------------------
1.01b jhl 05/13/02  First release
1.01b jhl 10/14/02  Corrected bug in the receive function, the setup of the
                    interrupt status mask was not being done in the loop such
                    that a read would sometimes fail on the last byte because
                    the transmit error which should have been ignored was
                    being used.  This would leave an extra byte in the FIFO
                    and the bus throttled such that the next operation would
                    also fail.  Also updated the receive function to not
                    disable the device after the last byte until after the
                    bus transitions to not busy which is more consistent
                    with the expected behavior.
1.01c ecm  12/05/02 new rev
1.02a mta  03/09/06 Implemented Repeated Start in the Low Level Driver.
1.03a mta  04/04/06 Implemented Dynamic IIC core routines.
1.03a ecm  06/15/06 Fixed the hang in low_level_eeprom_test with -O0
                    Added polling loops for BNB to allow the slave to
                    respond correctly. Also added polling loop prior
                    to reset in _Recv.
1.13a wgr  03/22/07 Converted to new coding style.
1.13b ecm  11/29/07 added BB polling loops to the DynSend and DynRecv
        routines to handle the race condition with BNB in IISR.
2.00a sdm  10/22/09 Converted all register accesses to 32 bit access.
          Updated to use the HAL APIs/macros.
          Some of the macros have been renamed to remove _m from
          the name and Some of the macros have been renamed to be
          consistent, see the xiic_i.h and xiic_l.h files for
          further information.
2.02a sdm  10/08/10 Updated to disable the device at the end of the transfer,
          only when addressed as slave in XIic_Send for CR565373.
2.04a sdm  07/22/11 Removed a compiler warning by adding parenthesis around &
          at line 479.
2.08a adk  29/07/13 In Low level driver In repeated start condition the
          Direction of Tx bit must be disabled in Receive
          condition It Fixes the CR:685759 Changes are done
          in the function XIic_Recv.
3.2   sk   11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425.
                    Changed the prototypes of RecvData, SendData,
                    DynRecvData, DynSendData APIs.
3.2 sd   18/02/16 In Low level driver in repeated start condition
                    NACK for last byte is added. Changes are done in
                    XIic_Recv for CR# 862303
3.3   sk   06/17/16 Added bus busy checks for slave send/recv and master
                    send/recv.
3.3   als  06/27/16 Added Low-level XIic_CheckIsBusBusy API.
3.3   als  06/27/16 Added low-level XIic_WaitBusFree API.
3.4 nk   16/11/16 Reduced sleeping time in Bus-busy check.
3.5   sd   08/29/18 Fix bus busy check for the NACK case.

Definition at line 71 of file xiic_l.c.

Function Documentation

◆ XIic_CheckIsBusBusy()

u32 XIic_CheckIsBusBusy ( UINTPTR  BaseAddress)

Definition at line 604 of file xiic_l.c.

Here is the caller graph for this function:

◆ XIic_Recv()

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

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
BaseAddresscontains the base address of the IIC device.
Addresscontains the 7 bit IIC address of the device to send the specified data to.
BufferPtrpoints to the data to be sent.
ByteCountis the number of bytes to be sent.
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.
Note
None.

Definition at line 113 of file xiic_l.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XIic_Send()

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

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
BaseAddresscontains the base address of the IIC device.
Addresscontains the 7 bit IIC address of the device to send the specified data to.
BufferPtrpoints to the data to be sent.
ByteCountis the number of bytes to be sent.
Optionindicates whether to hold or free the bus after transmitting the data.
Returns
The number of bytes sent.
Note
None.

Definition at line 369 of file xiic_l.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XIic_WaitBusFree()

u32 XIic_WaitBusFree ( UINTPTR  BaseAddress)

This function will wait until the I2C bus is free or timeout.

Parameters
BaseAddresscontains the base address of the I2C device.
Returns
  • XST_SUCCESS if the I2C bus was freed before the timeout.
  • XST_FAILURE otherwise.
Note
None.

Definition at line 628 of file xiic_l.c.

Here is the call graph for this function:
Here is the caller graph for this function: