
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
426 of 487
NXP Semiconductors
UM10800
Chapter 29: LPC82x ROM API I2C driver routines
receive mode, all of these addresses (or groups if masks are used) will be monitored for a
match. If the General Call bit (least significant bit of any of the four slave address bytes) is
set, then the General Call address of 0x00 is monitored as well.
size_in_bytes = LPC_I2CD_API->i2c_get_mem_size();
i2c_handle = LPC_I2CD_API->i2c_setup(LPC_I2C_BASE, (uint32_t *)&I2C_Handle[0] );
error_code = LPC_I2CD_API->i2c_set_bitrate((I2C_HANDLE_T*)i2c_handle, PCLK_in_Hz,
bps_in_hz);
error_code = LPC_I2CD_API->i2c_set_slave_addr((I2C_HANDLE_T*)i2c_handle, slave_addr,
slave_addr_mask) ;
29.5.4 I2C Master Transmit/Receive
The Master mode drivers give the user the choice of either polled (wait for the message to
finish) or interrupt driven routines (non-blocking). Polled routines are recommended for
testing purposes or very simple I2C applications. These routines allow the Master to send
to Slaves with 7-bit or 10-bit addresses.
The following routines are polled routines:
err_code i2c_master_transmit_poll(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_master_receive_poll(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_master_tx_rx_poll (I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
The following routines are interrupt driven routines:
err_code i2c_master_transmit_intr(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_master_receive_intr(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT*)
err_code i2c_master_tx_rx_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 Error Table.
•
I2C_PARM* is a structure with parameters passed to the function. Refer to
•
I2C_RESULT* is a containing the results after the function executes.
Fig 63. I2C slave mode set-up address packing
31 25
24 23
17
16 15
9
8
7
1
0
Slave Address 3 GC Slave Address 2 GC Slave Address 1 GC Slave Address 0 GC