NXP Semiconductors
In all the master mode routines, the transmit buffer's first byte must be the slave address
with the R/W bit set to "0". To enable a master read, the receive buffer's first byte must be
the slave address with the R/W bit set to "1".
The following conditions must be fulfilled to use the I2C driver routines in master mode:
•
•
•
•
•
•
When using the interrupt function calls, the callback functions must be define. Upon the
completion of a read/write as specified by the PARAM structure, the callback functions will
be invoked.
23.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:
The following routines are interrupt driven routines:
Where:
•
•
UM10601
Preliminary user manual
For 7-bit addressing, the first byte of the send buffer must have the slave address in
the most significant 7 bits and the least significant (R/W) bit = 0. Example: Slave
address 0x53, first byte is 0xA6.
For 7-bit addressing, the first byte of the receive buffer must have the slave address in
the most significant 7 bits and the least significant (R/W) bit = 1. Example: Slave Addr
0x53, first byte 0xA7.
For 10-bit address, the first byte of the transmit buffer must have the slave address
most significant 2 bits with the (R/W) bit =0. The second byte must contain the
remaining 8-bit of the slave address.
For 10-bit address, the first byte of the receive buffer must have the slave address
most significant 2 bits with the (R/W) bit =1. The second byte must contain the
remaining 8-bit of the slave address.
The number of bytes to be transmitted should include the first byte of the buffer which
is the slave address byte. Example: 2 data bytes + 7-bit slave addr = 3.
The application program must enable I2C interrupts. When I2C interrupt occurs, the
i2c_isr_handler function must be called from the application program.
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*)
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*)
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.
All information provided in this document is subject to legal disclaimers.
Rev. 1.0 — 7 November 2012
UM10601
Chapter 23: LPC800 I2C-bus ROM API
Section
© NXP B.V. 2012. All rights reserved.
23.4.22.
281 of 313
Need help?
Do you have a question about the LPC800 and is the answer not in the manual?
Questions and answers