MOTOROLA
Appendix E. MPC8240 Drivers
E-15
buffer is a pointer to the buffer that contains the data (xmit mode) or receives the data
(rcv mode)
stop controls sending an I2C STOP signal after completion (curently use I2C_STOP
only)
retry is the timeout retry value (currently ignored)
rsta controls I2C restart (currently use I2C_NO_RESTART only)
Return: I2C_Status return value is either I2C_SUCCESS or I2C_ERROR.
Description:
Act as the I2C master to transmit (or receive) a buffer of data to (or from) an I2C slave
device.
This function currently only implements a simple master-transmit or a master-receive
transaction. It does not yet support the application retaining I2C bus ownership between
transactions, operating in interrupt mode, or acting as an I2C slave device.
E.2.3.2
API Example Usage
The ROM monitor program DINK32 uses the I2C API in both currently implemented
modes: master-transmit and master-receive. The DINK32 program runs interactively to
allow the user to transmit or receive a buffer of data from an I2C device at address 0x50 on
the Kahlua PMC card. DINK32 obtains information from the user as follows: read/write
mode, I2C device address for the data (this is the address of the data on the I2C device, not
the I2C bus address of the device itself, which is hard-coded in DINK32), the raw data (if
in write mode), and the length of the data to transfer to or from the device. Note that the
initialization call to configure the I2C interface is actually made only once, the first time
the user requests an I2C transmit or receive operation. Each transmit or receive operation
is performed by a single call to an I2C API function. The DINK32 program is an interactive
application, so it gives the I2C library access to its own print output function.
These are the steps DINK32 takes to perform a master-transmit transaction:
1. Call I2C_Initialize (if needed) to set the Kahlua I2C address, polling mode, and
identify the optional print function.
2. Call I2C_do_transaction to transmit the buffer of data.
These are the steps DINK32 takes to perform a master-receive transaction in polling mode:
1. Call I2C_Initialize (if needed) to set the Kahlua I2C address, polling mode, and
identify the optional print function.
2. Call I2C_do_transaction to receive the buffer of data.
The following code samples have been excerpted from the DINK32 application to illustrate
the use of the I2C API:
#define PRINT dink_printf
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.