DRAFT
DRAFT DRAFT DR
DRAFT DRAFT DRAFT
D
RAF
DRAFT DRAFT DRA
FT D
RAFT DR
AFT D
DRA
FT DRAFT DRAFT
D
RAFT
DRAFT
D
RAFT
DRA
UM10601
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2012. All rights reserved.
Preliminary user manual
Rev. 1.0 — 7 November 2012
277 of 313
NXP Semiconductors
UM10601
Chapter 23: LPC800 I2C-bus ROM API
After the definition of the handle, the handle must be initialized with I2C base address and
RAM reserved for the I2C ROM driver by making a call to the i2c_setup() function.
The callback function type must be defined if interrupts for the I2C ROM driver are used:
typedef void (*I2C_CALLBK_T) (uint32_t err_code, uint32_t n)
The callback function will be called by the I2C ROM driver upon completion of a task when
interrupts are used.
23.4.22 PARAM and RESULT structure
The I2C ROM driver input parameters consist of two structures, a PARAM structure and a
RESULT structure. The PARAM structure contains the parameters passed to the I2C
ROM driver and the RESULT structure contains the results after the I2C ROM driver is
called.
The PARAM structure is as follows:
typedef struct i2c_A { //parameters passed to ROM function
uint32_t num_bytes_send ;
uint32_t num_bytes_rec ;
uint8_t *buffer_ptr_send ;
uint8_t *buffer_ptr_rec ;
I2C_CALLBK_T func_pt; // callback function pointer
uint8_t stop_flag;
uint8_t dummy[3] ; // required for word alignment
} I2C_PARAM ;
The RESULT structure is as follows:
typedef struct i2c_R { // RESULTs struct--results are here when returned
uint32_t n_bytes_sent ;
uint32_t n_bytes_recd ;
} I2C_RESULT ;
23.4.23 Error structure
The error code returned by the I2C ROM driver is an enum structure. The Error structure
is as follows:
typedef enum
{
LPC_OK=0, /**< enum value returned on Success */
ERROR,
ERR_I2C_BASE = 0x00060000,
/*0x00060001*/ ERR_I2C_NAK=ERR_I1,
/*0x00060002*/ ERR_I2C_BUFFER_OVERFLOW,
/*0x00060003*/ ERR_I2C_BYTE_COUNT_ERR,
/*0x00060004*/ ERR_I2C_LOSS_OF_ARBRITRATION,
/*0x00060005*/ ERR_I2C_SLAVE_NOT_ADDRESSED,
/*0x00060006*/ ERR_I2C_LOSS_OF_ARBRITRATION_NAK_BIT,
/*0x00060007*/ ERR_I2C_GENERAL_FAILURE,
/*0x00060008*/ ERR_I2C_REGS_SET_TO_DEFAULT