Intel® IXP400 Software

I2C Driver (IxI2cDrv)

Once an arbitration loss error is detected, the unit will stop transmitting. The client will need to call the transfer again and the I2C status register will be checked to determine the busy status of the I2C bus. If the bus is not busy, the transfer that occurred before the bus arbitration loss error will be re- submitted.

26.3.3.2Bus Error

This error occurs when the I2C unit, as a master transmitter, does not receive an ACK in response to transmission. A bus error can also occur when the I2C unit is operating as a slave receiver, and a NACK pulse is generated. In master transmit mode, the hardware will abort the transaction by automatically sending a STOP signal. As a slave receiver, the behavior will depend on the master’s action. The counters for both occurrences will be updated accordingly.

26.4I2C Driver API Usage Models

26.4.1Initialization and General Data Model

This description assumes a single client model where there is a single application-level program configuring the I2C interface and initiating I/O operations.

Initialization

The client must first define the initial configuration of the I2C port by storing a number of values in the IxI2cInitVars structure. The values include the speed selection, data flow mode, pointers to callback functions for various data scenarios, hardware address, and behavior settings for how the I2C unit responds to general call and slave address calls. After the structure is defined, ixI2cDrvInit() may be called to enable the port.

Once the port is enabled, the client will use one of the data models described later in this chapter (either Interrupt or Polling mode) to determine how and when data I/O operations need to occur.

A callback or handler may be registered for interrupt transmit and receive operations in the IxI2cInitVars structure. There are different callbacks for when the I2C unit is operating in master or slave mode, and also for general calls.

Master-Interrupt Mode

The client will use the ixI2cDrvWriteTransfer() and ixI2cDrvReadTransfer() functions for transmitting and receiving data on the I2C bus in master mode. The functions will return immediately, even though the transfer has not completed. Upon function return, the callback routines registered in IxI2cInitVars will be executed. The I2C unit will handle the appropriate arbitration and bus messaging required to support the transfer type and mode.

While the I2C unit is in Master-Interrupt mode, the use of interrupt callbacks is optional. If no callbacks are registered, the read/write transfer functions discussed above will wait until the transfer operation has completed before returning to the calling application. This method can be used if transfer status information is not needed for each transaction and simplifies the implementation of repeated start transfers. The data that is passed in the callback includes transfer mode, buffer pointer and buffer size. Since this data is already known to the client application, processing of this data via the callback would be inefficient.

April 2005

IXP400 Software Version 2.0

Programmer’s Guide

334

Document Number: 252539, Revision: 007

 

Page 334
Image 334
Intel IXP400 manual 26.4 I2C Driver API Usage Models, Bus Error, Initialization, Master-Interrupt Mode