
MOTOROLA
Appendix E. MPC8240 Drivers
E-37
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 from par_devtest in device.c:
#define PRINT dink_printf
int dink_printf( unsigned char *fmt, ... )
{
/* body of application print output function, */
}
/* In the function par_devtest, for testing the I2C device interface */
{
/* initialize the I2C handler to I2C address 48, if needed */
if ( I2CInited == 0 )
{
I2C_Status status;
if ((status = I2C_Initialize( 48, en_int, PRINT ) ) != I2C_SUCCESS )
{
PRINT( "devtest I2C: error in initiation\n" );
return ERROR;
} else {
I2CInited = 1;
}
}
return test_i2c( action, en_int );
}
static unsigned char rcv_buffer[BUFFER_LENGTH] = { 0 };
static unsigned char xmit_buffer[BUFFER_LENGTH] = { 0 };
/*******************************************************
* function: test_i2c
*
* description: run i2c test by polling the device
*
* note:
* Test i2c device on PMC card, 0x50 serial EPROM.
* The device test data is currently only printable characters.
*
* This function gets some data from the command line, validates it,
* and calls the I2C library function to perform the task.
******************************************************/
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.