API description

The I2C API contains functions to configure the I2C and send and receive data in master and slave modes.

Table 1. I2C API I2C API calls
API call Description Reference
void i2c_isr_handler(I2C_HANDLE_T*) I2C ROM Driver interrupt service routine. I2C API ISR handler
ErrorCode_t i2c_master_transmit_poll(I2C_HANDLE_T*, I2C_PARAM*, I2C_RESULT* ) I2C Master Transmit Polling I2C API I2C Master Transmit Polling
ErrorCode_t i2c_master_receive_poll(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Master Receive Polling I2C API I2C Master Receive Polling
ErrorCode_t i2c_master_tx_rx_poll(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Master Transmit and Receive Polling I2C API I2C Master Transmit and Receive Polling
ErrorCode_t i2c_master_transmit_intr(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Master Transmit Interrupt I2C API I2C Master Transmit Interrupt
ErrorCode_t i2c_master_receive_intr(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Master Receive Interrupt I2C API I2C Master Receive Interrupt
ErrorCode_t i2c_master_tx_rx_intr(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Master Transmit Receive Interrupt I2C API I2C Master Transmit Receive Interrupt
ErrorCode_t i2c_slave_receive_poll(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Slave Receive Polling I2C API I2C Slave Receive Polling
ErrorCode_t i2c_slave_transmit_poll(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Slave Transmit Polling I2C API I2C Slave Transmit Polling
ErrorCode_t i2c_slave_receive_intr(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Slave Receive Interrupt I2C API I2C Slave Receive Interrupt
ErrorCode_t i2c_slave_transmit_intr(I2C_HANDLE_T* , I2C_PARAM* , I2C_RESULT*) I2C Slave Transmit Interrupt I2C API I2C Slave Transmit Interrupt
ErrorCode_t i2c_set_slave_addr(I2C_HANDLE_T*, slave_addr_0_3, slave_mask_0_3) I2C Set Slave Address I2C API I2C Set Slave Address
uint32_t i2c_get_mem_size(void) I2C Get Memory Size I2C API I2C Get Memory Size
I2C_HANDLE_T* i2c_setup(i2c_base_addr, *start_of_ram) I2C Setup I2C API I2C Setup
ErrorCode_t i2c_set_bitrate(I2C_HANDLE_T*, P_clk_in_hz, bitrate_in_bps) I2C Set Bit Rate I2C API I2C Set Bit Rate
uint32_t i2c_get_firmware_version(void ) I2C Get Firmware Version I2C API I2C Get Firmware Version
I2C_MODE_T i2c_get_status(I2C_HANDLE_T* ) I2C Get Status I2C API I2C Get Status
ErrorCode_t i2c_set_timeout(I2C_HANDLE_T* h_i2c, uint32_t timeout) I2C time-out value I2C API I2C time-out value

The following structure has to be defined to use the I2C API:

typedef struct I2CD_API {	   // index of allthe i2c driver functions-->
void (*i2c_isr_handler) (I2C_HANDLE_T* h_i2c) ; // ISR interruptservice request-->
// MASTER functions ***-->
ErrorCode_t (*i2c_master_transmit_poll)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp,                                                          I2C_RESULT* ptr );-->
ErrorCode_t (*i2c_master_receive_poll)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp,                                                       I2C_RESULT* ptr );-->
ErrorCode_t (*i2c_master_tx_rx_poll)(I2C_HANDLE_T* h_i2c,	I2C_PARAM*ptp,                                                      I2C_RESULT*ptr ) ;-->
ErrorCode_t (*i2c_master_transmit_intr)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
ErrorCode_t (*i2c_master_receive_intr)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
ErrorCode_t (*i2c_master_tx_rx_intr)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
// SLAVE functions *** -->
ErrorCode_t (*i2c_slave_receive_poll)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
ErrorCode_t (*i2c_slave_transmit_poll)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
ErrorCode_t (*i2c_slave_receive_intr)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ;-->
ErrorCode_t (*i2c_slave_transmit_intr)(I2C_HANDLE_T* h_i2c,I2C_PARAM* ptp, I2C_RESULT* ptr ) ; -->
ErrorCode_t (*i2c_set_slave_addr)(I2C_HANDLE_T* h_i2c,                              uint32_t slave_addr_0_3, uint32_t slave_mask_0_3)	;-->
// OTHER functions-->
uint32_t (*i2c_get_mem_size)(void) ; //ramsize_in_bytes memoryneeded by I2C drivers-->
I2C_HANDLE_T*   (*i2c_setup)(uint32_t i2c_base_addr, uint32_t*start_of_ram ) ;-->
ErrorCode_t   (*i2c_set_bitrate)(I2C_HANDLE_T* h_i2c, uint32_tP_clk_in_hz,                             uint32_t bitrate_in_bps);-->
uint32_t (*i2c_get_firmware_version)() ;	-->
I2C_MODE_T (*i2c_get_status)(I2C_HANDLE_T* h_i2c ) ;-->
} I2CD_API_T ; -->
-->
-->
#define LPC_I2CD_API    ((I2CD_API_T *) ((*(ROM_API_T * *)(ROM_DRIVER_BASE))->pI2CD))-->

See ROM-based APIs for how to include the ROM driver structure.


-->