
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
429 of 487
NXP Semiconductors
UM10800
Chapter 29: LPC82x ROM API I2C driver routines
In slave-receive mode, the driver receives data until one of the following are true:
•
Address matching set in the set_slave_addr() function with the R/W bit set to 1
•
STOP or repeated START is received
•
An error condition is detected
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.
29.5.6 I2C time-out feature
//timeout: Timeout time value. Specifies the timeout interval value in increments of
// 16 I2C function clocks (Min value is 16).
//
if timeout = 0, timeout feature is disabled
// if timeout != 0, time value is timeout*16 i2c function clock.
ErrorCode_t i2c_set_timeout(I2C_HANDLE_T* h_i2c, uint32_t timeout)
{
I2C_DRIVER_TypeDef *h ; // declare pointer to i2c structure [handle]
h = (I2C_DRIVER_TypeDef*) h_i2c ; //assign handle pointer address
if (timeout != 0){
h->i2c_base->TimeOut = (timeout - 1)<<4;
// Enable timeout feature
h->i2c_base->CFG |= BI2C_TIMEOUT_EN;
}
else
// disable timeout feature
h->i2c_base->CFG &= ~BI2C_TIMEOUT_EN;
return(LPC_OK) ;
}//i2c_set_timeout