
UM10800
All information provided in this document is subject to legal disclaimers.
© NXP Semiconductors N.V. 2016. All rights reserved.
User manual
Rev. 1.2 — 5 October 2016
428 of 487
NXP Semiconductors
UM10800
Chapter 29: LPC82x ROM API I2C driver routines
29.5.5 I2C Slave Mode Transmit/Receive
In slave mode, polled routines are intended for testing purposes. It is up to the user to
decide whether to use the polled or interrupt driven mode. While operating the Slave
driver in polled mode can be useful for program development and debugging, most
applications will need the interrupt-driven versions of Slave Receive and Transmit in the
final software.
The following routines are polled routines:
err_code i2c_slave_receive_poll(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_slave_transmit_poll(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
The following routines are interrupt driven routines:
err_code i2c_slave_receive_intr(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_slave_transmit_intr(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
Where:
•
err_code is the return state of the function. An 0 indicates success. All non-zero
indicates an error. Refer to the Error Code Table.
•
I2C_PARM is a structure with parameters passed to the function.
.
•
I2C_RESULT is a containing the results after the function executes.
To initiate a master-mode write/read the I2C_PARAM has to be setup. The I2C_PARAM is
a structure with various variables needed by the I2C ROM Driver to operate correctly. The
structure contains the following:
•
Number of bytes to be transmitted.
•
Number of bytes to be received.
•
Pointer to the transmit buffer.
•
Pointer to the receive buffer.
•
Pointer to callback function.
•
Stop flag.
The RESULT structure contains the results after the function executes. The structure
contains the following:
•
Number of bytes transmitted.
•
Number of bytes received.
Remark:
The number of bytes transmitted is updated only for i2c_slave_send_poll() and
i2c_slave_send_intr(). The number of bytes received is updated only for
i2c_slave_receive_poll() and i2c_slave_receive_intr().
To initiate a slave mode communication, the receive function is called. This can be either
the polling or interrupt driven function, i2c_slave_receive_poll() or
i2c_slave_receive_intr(), respectively. The receive buffer should be as large or larger than
any data or command that will be received. If the amount of data exceed the receive buffer
size, an error code will be returned.