LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CHIP: LPC18xx/43xx I2C Driver

Functions

void Chip_I2C_Init (LPC_I2C_Type *I2Cx)
 Initializes the LPC_I2C peripheral with specified parameter.
 
void Chip_I2C_DeInit (LPC_I2C_Type *I2Cx)
 De-initializes the I2C peripheral registers to their default reset values.
 
void Chip_I2C_SetClockRate (LPC_I2C_Type *I2Cx, uint32_t clockrate)
 Set up clock rate for LPC_I2C peripheral.
 
uint32_t Chip_I2C_GetClockRate (LPC_I2C_Type *I2Cx)
 Get current clock rate for LPC_I2C peripheral.
 
Status Chip_I2C_MasterTransferData (LPC_I2C_Type *I2Cx, I2C_M_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Transmit and Receive data in master mode.
 
Status Chip_I2C_MasterTransmitData (LPC_I2C_Type *I2Cx, I2C_M_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Transmit an array of bytes in Master mode.
 
Status Chip_I2C_MasterReceiveData (LPC_I2C_Type *I2Cx, I2C_M_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Receive an array of bytes in Master mode.
 
uint32_t Chip_I2C_MasterWriteReg (LPC_I2C_Type *I2Cx, uint32_t SlaveAddr, uint8_t regAddr, uint8_t *buffer, uint8_t buffer_len)
 Write byte(s) to slave register.
 
uint32_t Chip_I2C_MasterReadReg (LPC_I2C_Type *I2Cx, uint32_t SlaveAddr, uint8_t regAddr, uint8_t *buffer, uint8_t buffer_len)
 Read slave register content.
 
void Chip_I2C_Interrupt_MasterHandler (LPC_I2C_Type *I2Cx)
 General Master Interrupt handler for I2C peripheral.
 
bool Chip_I2C_Interrupt_MasterTransferComplete (LPC_I2C_Type *I2Cx)
 Get status of Master Transfer.
 
Status Chip_I2C_SlaveTransferData (LPC_I2C_Type *I2Cx, I2C_S_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Receive and Transmit data in slave mode.
 
Status Chip_I2C_SlaveTransmitData (LPC_I2C_Type *I2Cx, I2C_S_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Transmit an array of bytes in Slave mode.
 
Status Chip_I2C_SlaveReceiveData (LPC_I2C_Type *I2Cx, I2C_S_SETUP_Type *TransferCfg, I2C_TRANSFER_OPT_Type Opt)
 Receive an array of bytes in Slave mode.
 
void Chip_I2C_Interrupt_SlaveHandler (LPC_I2C_Type *I2Cx)
 General Slave Interrupt handler for I2C peripheral.
 
bool Chip_I2C_Interrupt_SlaveTransferComplete (LPC_I2C_Type *I2Cx)
 Get status of Slave Transfer.
 
STATIC INLINE void Chip_I2C_SetOwnSlaveAddr (LPC_I2C_Type *I2Cx, I2C_OWNSLAVEADDR_CFG_Type *OwnSlaveAddrConfigStruct)
 Set Own slave address in I2C peripheral corresponding to parameter specified in OwnSlaveAddrConfigStruct.
 
STATIC INLINE void Chip_I2C_Cmd (LPC_I2C_Type *I2Cx, I2C_Mode Mode, FunctionalState NewState)
 Enable or disable I2C peripheral's operation.
 

Detailed Description

Function Documentation

STATIC INLINE void Chip_I2C_Cmd ( LPC_I2C_Type I2Cx,
I2C_Mode  Mode,
FunctionalState  NewState 
)

Enable or disable I2C peripheral's operation.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Mode: I2C mode, should be I2C_MASTER_MODE, I2C_SLAVE_MODE or I2C_GENERAL_MODE
NewState,:New State of LPC_I2C peripheral's operation, should be ENABLE or DISABLE
Returns
Nothing

Definition at line 216 of file i2c_18xx_43xx.h.

void Chip_I2C_DeInit ( LPC_I2C_Type I2Cx)

De-initializes the I2C peripheral registers to their default reset values.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Nothing

Definition at line 95 of file i2c_18xx_43xx.c.

uint32_t Chip_I2C_GetClockRate ( LPC_I2C_Type I2Cx)

Get current clock rate for LPC_I2C peripheral.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
the current I2Cx clock rate

Definition at line 134 of file i2c_18xx_43xx.c.

void Chip_I2C_Init ( LPC_I2C_Type I2Cx)

Initializes the LPC_I2C peripheral with specified parameter.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Nothing

Definition at line 85 of file i2c_18xx_43xx.c.

void Chip_I2C_Interrupt_MasterHandler ( LPC_I2C_Type I2Cx)

General Master Interrupt handler for I2C peripheral.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Nothing

Definition at line 247 of file i2c_18xx_43xx.c.

bool Chip_I2C_Interrupt_MasterTransferComplete ( LPC_I2C_Type I2Cx)

Get status of Master Transfer.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Master transfer status: TRUE (transfer completed) or FALSE (not completed yet)

Definition at line 255 of file i2c_18xx_43xx.c.

void Chip_I2C_Interrupt_SlaveHandler ( LPC_I2C_Type I2Cx)

General Slave Interrupt handler for I2C peripheral.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Nothing

Definition at line 300 of file i2c_18xx_43xx.c.

bool Chip_I2C_Interrupt_SlaveTransferComplete ( LPC_I2C_Type I2Cx)

Get status of Slave Transfer.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
Returns
Slave transfer status: TRUE (transfer completed) or FALSE (not completed yet)

Definition at line 308 of file i2c_18xx_43xx.c.

uint32_t Chip_I2C_MasterReadReg ( LPC_I2C_Type I2Cx,
uint32_t  SlaveAddr,
uint8_t  regAddr,
uint8_t *  buffer,
uint8_t  buffer_len 
)

Read slave register content.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
SlaveAddr: Slave address in 7-bit mode
regAddr: Slave register address
buffer: pointer to data array needed to receive
buffer_len: data length (number of bytes)
Returns
Number of bytes received Transmit one byte and continue to receive an array of bytes after a repeated start condition is generated in Master mode. This function is useful for communicating with the I2C slave registers.

Definition at line 222 of file i2c_18xx_43xx.c.

Status Chip_I2C_MasterReceiveData ( LPC_I2C_Type I2Cx,
I2C_M_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Receive an array of bytes in Master mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_M_SETUP_Type structure that contains specified information about the configuration for master transfer.
Opt: a I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode.
Returns
SUCCESS or ERROR

Definition at line 174 of file i2c_18xx_43xx.c.

Status Chip_I2C_MasterTransferData ( LPC_I2C_Type I2Cx,
I2C_M_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Transmit and Receive data in master mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_M_SETUP_Type structure that contains specified information about the configuration for master transfer.
Opt: a I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode
Returns
SUCCESS or ERROR

Definition at line 146 of file i2c_18xx_43xx.c.

Status Chip_I2C_MasterTransmitData ( LPC_I2C_Type I2Cx,
I2C_M_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Transmit an array of bytes in Master mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_M_SETUP_Type structure that contains specified information about the configuration for master transfer
Opt: a I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode
Returns
SUCCESS or ERROR

Definition at line 159 of file i2c_18xx_43xx.c.

uint32_t Chip_I2C_MasterWriteReg ( LPC_I2C_Type I2Cx,
uint32_t  SlaveAddr,
uint8_t  regAddr,
uint8_t *  buffer,
uint8_t  buffer_len 
)

Write byte(s) to slave register.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
SlaveAddr: Slave address in 7-bit mode
regAddr: Slave register address
buffer: pointer to data array needed to send
buffer_len: data length (number of bytes)
Returns
Number of bytes sent Transmit one byte and an array of bytes after a repeated start condition is generated in Master mode. This function is useful for communicating with the I2C slave registers.

Definition at line 191 of file i2c_18xx_43xx.c.

void Chip_I2C_SetClockRate ( LPC_I2C_Type I2Cx,
uint32_t  clockrate 
)

Set up clock rate for LPC_I2C peripheral.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
clockrate: Target clock rate value to initialized I2C peripheral (Hz)
Returns
Nothing

Definition at line 104 of file i2c_18xx_43xx.c.

STATIC INLINE void Chip_I2C_SetOwnSlaveAddr ( LPC_I2C_Type I2Cx,
I2C_OWNSLAVEADDR_CFG_Type OwnSlaveAddrConfigStruct 
)

Set Own slave address in I2C peripheral corresponding to parameter specified in OwnSlaveAddrConfigStruct.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
OwnSlaveAddrConfigStruct: Pointer to a I2C_OWNSLAVEADDR_CFG_Type structure that contains the configuration information for the specified I2C slave address.
Returns
Nothing

Definition at line 204 of file i2c_18xx_43xx.h.

Status Chip_I2C_SlaveReceiveData ( LPC_I2C_Type I2Cx,
I2C_S_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Receive an array of bytes in Slave mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_S_SETUP_Type structure that contains specified information about the configuration for slave transfer.
Opt: a I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode.
Returns
SUCCESS or ERROR

Definition at line 287 of file i2c_18xx_43xx.c.

Status Chip_I2C_SlaveTransferData ( LPC_I2C_Type I2Cx,
I2C_S_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Receive and Transmit data in slave mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_S_SETUP_Type structure that contains specified information about the configuration for master transfer.
Opt: I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode.
Returns
SUCCESS or ERROR

Definition at line 263 of file i2c_18xx_43xx.c.

Status Chip_I2C_SlaveTransmitData ( LPC_I2C_Type I2Cx,
I2C_S_SETUP_Type TransferCfg,
I2C_TRANSFER_OPT_Type  Opt 
)

Transmit an array of bytes in Slave mode.

Parameters
I2Cx: I2C peripheral selected, should be LPC_I2C0 or LPC_I2C1
TransferCfg: Pointer to a I2C_S_SETUP_Type structure that contains specified information about the configuration for slave transfer.
Opt: a I2C_TRANSFER_OPT_Type type that selected for interrupt or polling mode.
Returns
SUCCESS or ERROR

Definition at line 274 of file i2c_18xx_43xx.c.