Classes | |
struct | I2C_XFER_T |
Master transfer data structure definitions. More... | |
struct | LPC_I2C_T |
I2C register block structure. More... | |
Typedefs | |
typedef void(* | I2C_EVENTHANDLER_T) (I2C_ID_T, I2C_EVENT_T) |
Event handler function type. More... | |
typedef enum I2C_ID | I2C_ID_T |
I2C interface IDs. More... | |
Enumerations | |
enum | I2C_EVENT_T { I2C_EVENT_WAIT = 1, I2C_EVENT_DONE, I2C_EVENT_LOCK, I2C_EVENT_UNLOCK, I2C_EVENT_SLAVE_RX, I2C_EVENT_SLAVE_TX } |
I2C master events. More... | |
enum | I2C_ID { I2C0, I2C_NUM_INTERFACE } |
I2C interface IDs. More... | |
enum | I2C_SLAVE_ID { I2C_SLAVE_GENERAL, I2C_SLAVE_0, I2C_SLAVE_1, I2C_SLAVE_2, I2C_SLAVE_3, I2C_SLAVE_NUM_INTERFACE } |
I2C Slave Identifiers. More... | |
enum | I2C_STATUS_T { I2C_STATUS_DONE, I2C_STATUS_NAK, I2C_STATUS_ARBLOST, I2C_STATUS_BUSERR, I2C_STATUS_BUSY } |
I2C transfer status. More... | |
Functions | |
void | Chip_I2C_DeInit (I2C_ID_T id) |
De-initializes the I2C peripheral registers to their default reset values. More... | |
void | Chip_I2C_Disable (I2C_ID_T id) |
Disable I2C peripheral's operation. More... | |
void | Chip_I2C_EventHandler (I2C_ID_T id, I2C_EVENT_T event) |
Default event handler for interrupt base operation. More... | |
void | Chip_I2C_EventHandlerPolling (I2C_ID_T id, I2C_EVENT_T event) |
Default event handler for polling operation. More... | |
uint32_t | Chip_I2C_GetClockRate (I2C_ID_T id) |
Get current clock rate for LPC_I2C peripheral. More... | |
I2C_EVENTHANDLER_T | Chip_I2C_GetMasterEventHandler (I2C_ID_T id) |
Get pointer to current function handling the events. More... | |
void | Chip_I2C_Init (I2C_ID_T id) |
Initializes the LPC_I2C peripheral with specified parameter. More... | |
int | Chip_I2C_IsMasterActive (I2C_ID_T id) |
Checks if master xfer in progress. More... | |
int | Chip_I2C_IsStateChanged (I2C_ID_T id) |
I2C peripheral state change checking. More... | |
int | Chip_I2C_MasterCmdRead (I2C_ID_T id, uint8_t slaveAddr, uint8_t cmd, uint8_t *buff, int len) |
Transfer a command to slave and receive data from slave after a repeated start. More... | |
int | Chip_I2C_MasterRead (I2C_ID_T id, uint8_t slaveAddr, uint8_t *buff, int len) |
Set function that must handle I2C events. More... | |
int | Chip_I2C_MasterSend (I2C_ID_T id, uint8_t slaveAddr, const uint8_t *buff, uint8_t len) |
Transmit data to I2C slave using I2C Master mode. More... | |
void | Chip_I2C_MasterStateHandler (I2C_ID_T id) |
I2C Master transfer state change handler. More... | |
int | Chip_I2C_MasterTransfer (I2C_ID_T id, I2C_XFER_T *xfer) |
Transmit and Receive data in master mode. More... | |
void | Chip_I2C_SetClockRate (I2C_ID_T id, uint32_t clockrate) |
Set up clock rate for LPC_I2C peripheral. More... | |
int | Chip_I2C_SetMasterEventHandler (I2C_ID_T id, I2C_EVENTHANDLER_T event) |
Set function that must handle I2C events. More... | |
void | Chip_I2C_SlaveSetup (I2C_ID_T id, I2C_SLAVE_ID sid, I2C_XFER_T *xfer, I2C_EVENTHANDLER_T event, uint8_t addrMask) |
Setup a slave I2C device. More... | |
void | Chip_I2C_SlaveStateHandler (I2C_ID_T id) |
I2C Slave event handler. More... | |
#define I2C_BYTE_RECV 0x02 |
Definition at line 221 of file i2c_11xx.h.
#define I2C_BYTE_SENT 0x01 |
Definition at line 220 of file i2c_11xx.h.
#define I2C_CheckError | ( | ErrorCode | ) | (ErrorCode & 0x10000000) |
Definition at line 230 of file i2c_11xx.h.
#define I2C_CON_AA (1UL << 2) |
Assert acknowledge bit
Definition at line 101 of file i2c_11xx.h.
#define I2C_CON_I2EN (1UL << 6) |
I2C interface bit
Definition at line 105 of file i2c_11xx.h.
#define I2C_CON_SI (1UL << 3) |
I2C interrupt bit
Definition at line 102 of file i2c_11xx.h.
#define I2C_CON_STA (1UL << 5) |
START flag bit
Definition at line 104 of file i2c_11xx.h.
#define I2C_CON_STO (1UL << 4) |
I2C STOP bit
Definition at line 103 of file i2c_11xx.h.
#define I2C_ERR (0x10000000) |
Definition at line 227 of file i2c_11xx.h.
#define I2C_I2ADR_BITMASK ((0xFF)) |
I2C Slave Address registers bit mask
Definition at line 192 of file i2c_11xx.h.
#define I2C_I2ADR_GC ((1 << 0)) |
General Call enable bit
Definition at line 191 of file i2c_11xx.h.
#define I2C_I2CONCLR_AAC ((1 << 2)) |
Assert acknowledge Clear bit
Definition at line 92 of file i2c_11xx.h.
#define I2C_I2CONCLR_I2ENC ((1 << 6)) |
I2C interface Disable bit
Definition at line 96 of file i2c_11xx.h.
#define I2C_I2CONCLR_SIC ((1 << 3)) |
I2C interrupt Clear bit
Definition at line 93 of file i2c_11xx.h.
#define I2C_I2CONCLR_STAC ((1 << 5)) |
START flag Clear bit
Definition at line 95 of file i2c_11xx.h.
#define I2C_I2CONCLR_STOC ((1 << 4)) |
I2C STOP Clear bit
Definition at line 94 of file i2c_11xx.h.
#define I2C_I2CONSET_AA ((0x04)) |
Assert acknowledge flag
Definition at line 83 of file i2c_11xx.h.
#define I2C_I2CONSET_I2EN ((0x40)) |
I2C interface enable
Definition at line 87 of file i2c_11xx.h.
#define I2C_I2CONSET_SI ((0x08)) |
I2C interrupt flag
Definition at line 84 of file i2c_11xx.h.
#define I2C_I2CONSET_STA ((0x20)) |
START flag
Definition at line 86 of file i2c_11xx.h.
#define I2C_I2CONSET_STO ((0x10)) |
STOP flag
Definition at line 85 of file i2c_11xx.h.
#define I2C_I2DAT_BITMASK ((0xFF)) |
Mask for I2DAT register
Definition at line 171 of file i2c_11xx.h.
#define I2C_I2DAT_IDLE_CHAR (0xFF) |
Idle data value will be send out in slave mode in case of the actual expecting data requested from the master is greater than its sending data length that can be supported
Definition at line 172 of file i2c_11xx.h.
#define I2C_I2MASK_MASK | ( | n | ) | ((n & 0xFE)) |
I2C Mask Register mask field
Definition at line 197 of file i2c_11xx.h.
#define I2C_I2MMCTRL_BITMASK ((0x07)) |
Mask for I2MMCTRL register
Definition at line 181 of file i2c_11xx.h.
#define I2C_I2MMCTRL_ENA_SCL ((1 << 1)) |
SCL output enable
Definition at line 179 of file i2c_11xx.h.
#define I2C_I2MMCTRL_MATCH_ALL ((1 << 2)) |
Select interrupt register match
Definition at line 180 of file i2c_11xx.h.
#define I2C_I2MMCTRL_MM_ENA ((1 << 0)) |
Monitor mode enable
Definition at line 178 of file i2c_11xx.h.
#define I2C_I2SCLH_BITMASK ((0xFFFF)) |
I2C SCL HIGH duty cycle Register bit mask
Definition at line 202 of file i2c_11xx.h.
#define I2C_I2SCLL_BITMASK ((0xFFFF)) |
I2C SCL LOW duty cycle Register bit mask
Definition at line 207 of file i2c_11xx.h.
#define I2C_I2STAT_BUS_ERROR ((0x00)) |
Bus Error
Definition at line 117 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_ARB_LOST ((0x38)) |
Arbitration lost
Definition at line 135 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_DAT_ACK ((0x50)) |
Data has been received, ACK has been returned
Definition at line 138 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_DAT_NACK ((0x58)) |
Data has been received, NACK has been returned
Definition at line 139 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_RESTART ((0x10)) |
A repeat start condition has been transmitted
Definition at line 134 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_SLAR_ACK ((0x40)) |
SLA+R has been transmitted, ACK has been received
Definition at line 136 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_SLAR_NACK ((0x48)) |
SLA+R has been transmitted, NACK has been received
Definition at line 137 of file i2c_11xx.h.
#define I2C_I2STAT_M_RX_START ((0x08)) |
A start condition has been transmitted
Definition at line 133 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_ARB_LOST ((0x38)) |
Arbitration lost in SLA+R/W or Data bytes
Definition at line 128 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_DAT_ACK ((0x28)) |
Data has been transmitted, ACK has been received
Definition at line 126 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_DAT_NACK ((0x30)) |
Data has been transmitted, NACK has been received
Definition at line 127 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_RESTART ((0x10)) |
A repeat start condition has been transmitted
Definition at line 123 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_SLAW_ACK ((0x18)) |
SLA+W has been transmitted, ACK has been received
Definition at line 124 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_SLAW_NACK ((0x20)) |
SLA+W has been transmitted, NACK has been received
Definition at line 125 of file i2c_11xx.h.
#define I2C_I2STAT_M_TX_START ((0x08)) |
A start condition has been transmitted
Definition at line 122 of file i2c_11xx.h.
#define I2C_I2STAT_NO_INF ((0xF8)) |
No relevant information
Definition at line 116 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_ARB_LOST_M_GENCALL ((0x78)) |
Arbitration lost in SLA+R/W (GENERAL CALL) as master
Definition at line 148 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_ARB_LOST_M_SLA ((0x68)) |
Arbitration lost in SLA+R/W as master
Definition at line 145 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_GENCALL_ACK ((0x70)) |
General call address has been received, ACK has been returned
Definition at line 147 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_PRE_GENCALL_DAT_ACK ((0x90)) |
Previously addressed with General Call; Data has been received and ACK has been returned
Definition at line 152 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_PRE_GENCALL_DAT_NACK ((0x98)) |
Previously addressed with General Call; Data has been received and NOT ACK has been returned
Definition at line 153 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_PRE_SLA_DAT_ACK ((0x80)) |
Previously addressed with own SLA; Data has been received, ACK has been returned
Definition at line 150 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_PRE_SLA_DAT_NACK ((0x88)) |
Previously addressed with own SLA;Data has been received and NOT ACK has been returned
Definition at line 151 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_SLAW_ACK ((0x60)) |
Own slave address has been received, ACK has been returned
Definition at line 144 of file i2c_11xx.h.
#define I2C_I2STAT_S_RX_STA_STO_SLVREC_SLVTRX ((0xA0)) |
A STOP condition or repeated START condition has been received while still addressed as SLV/REC (Slave Receive) or SLV/TRX (Slave Transmit)
Definition at line 154 of file i2c_11xx.h.
#define I2C_I2STAT_S_TX_ARB_LOST_M_SLA ((0xB0)) |
Arbitration lost in SLA+R/W as master
Definition at line 161 of file i2c_11xx.h.
#define I2C_I2STAT_S_TX_DAT_ACK ((0xB8)) |
Data has been transmitted, ACK has been received
Definition at line 163 of file i2c_11xx.h.
#define I2C_I2STAT_S_TX_DAT_NACK ((0xC0)) |
Data has been transmitted, NACK has been received
Definition at line 164 of file i2c_11xx.h.
#define I2C_I2STAT_S_TX_LAST_DAT_ACK ((0xC8)) |
Last data byte in I2DAT has been transmitted (AA = 0); ACK has been received
Definition at line 165 of file i2c_11xx.h.
#define I2C_I2STAT_S_TX_SLAR_ACK ((0xA8)) |
Own SLA+R has been received, ACK has been returned
Definition at line 160 of file i2c_11xx.h.
#define I2C_LAST_BYTE_RECV 0x04 |
Definition at line 222 of file i2c_11xx.h.
#define I2C_MONITOR_CFG_MATCHALL I2C_I2MMCTRL_MATCH_ALL |
Select interrupt register match
Definition at line 236 of file i2c_11xx.h.
#define I2C_MONITOR_CFG_SCL_OUTPUT I2C_I2MMCTRL_ENA_SCL |
SCL output enable
Definition at line 235 of file i2c_11xx.h.
#define I2C_NAK_RECV (0x10000000 | 0x01) |
Definition at line 228 of file i2c_11xx.h.
#define I2C_OK 0x00 |
Definition at line 219 of file i2c_11xx.h.
#define I2C_RECV_END 0x10 |
Definition at line 224 of file i2c_11xx.h.
#define I2C_SEND_END 0x08 |
Definition at line 223 of file i2c_11xx.h.
#define I2C_SETUP_STATUS_ARBF (1 << 8) |
Arbitration false
Definition at line 212 of file i2c_11xx.h.
#define I2C_SETUP_STATUS_DONE (1 << 10) |
Status DONE
Definition at line 214 of file i2c_11xx.h.
#define I2C_SETUP_STATUS_NOACKF (1 << 9) |
No ACK returned
Definition at line 213 of file i2c_11xx.h.
#define I2C_SLAVE_TIME_OUT 0x10000000UL |
Time out in case of using I2C slave mode
Definition at line 166 of file i2c_11xx.h.
#define I2C_STA_STO_RECV 0x20 |
I2C state handle return values.
Definition at line 225 of file i2c_11xx.h.
#define I2C_STA_STO_RECV 0x20 |
I2C state handle return values.
Definition at line 225 of file i2c_11xx.h.
#define I2C_STAT_CODE_BITMASK ((0xF8)) |
Return Code mask in I2C status register
Definition at line 110 of file i2c_11xx.h.
#define I2C_STAT_CODE_ERROR ((0xFF)) |
Return Code error mask in I2C status register
Definition at line 111 of file i2c_11xx.h.
#define I2DATA_BUFFER_BITMASK ((0xFF)) |
I2C Data buffer register bit mask
Definition at line 186 of file i2c_11xx.h.
#define RET_SLAVE_BUSY 0 |
Return value, when slave is busy
Definition at line 73 of file i2c_11xx.h.
#define RET_SLAVE_IDLE 2 |
Return value, when slave enter idle mode
Definition at line 72 of file i2c_11xx.h.
#define RET_SLAVE_RX 5 |
Return value, when 1 byte RX'd successfully
Definition at line 71 of file i2c_11xx.h.
#define RET_SLAVE_TX 6 |
Return values for SLAVE handler.
Definition at line 70 of file i2c_11xx.h.
typedef void(* I2C_EVENTHANDLER_T) (I2C_ID_T, I2C_EVENT_T) |
Event handler function type.
Definition at line 303 of file i2c_11xx.h.
I2C interface IDs.
enum I2C_EVENT_T |
I2C master events.
Definition at line 291 of file i2c_11xx.h.
enum I2C_ID |
I2C interface IDs.
Enumerator | |
---|---|
I2C0 | ID I2C0 |
I2C_NUM_INTERFACE | Number of I2C interfaces in the chip |
Definition at line 283 of file i2c_11xx.h.
enum I2C_SLAVE_ID |
I2C Slave Identifiers.
Definition at line 241 of file i2c_11xx.h.
enum I2C_STATUS_T |
I2C transfer status.
Enumerator | |
---|---|
I2C_STATUS_DONE | Transfer done successfully |
I2C_STATUS_NAK | NAK received during transfer |
I2C_STATUS_ARBLOST | Aribitration lost during transfer |
I2C_STATUS_BUSERR | Bus error in I2C transfer |
I2C_STATUS_BUSY | I2C is busy doing transfer |
Definition at line 253 of file i2c_11xx.h.
void Chip_I2C_DeInit | ( | I2C_ID_T | id | ) |
De-initializes the I2C peripheral registers to their default reset values.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
void Chip_I2C_Disable | ( | I2C_ID_T | id | ) |
Disable I2C peripheral's operation.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
void Chip_I2C_EventHandler | ( | I2C_ID_T | id, |
I2C_EVENT_T | event | ||
) |
Default event handler for interrupt base operation.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
event | : Event ID of the event that called the function |
void Chip_I2C_EventHandlerPolling | ( | I2C_ID_T | id, |
I2C_EVENT_T | event | ||
) |
Default event handler for polling operation.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
event | : Event ID of the event that called the function |
uint32_t Chip_I2C_GetClockRate | ( | I2C_ID_T | id | ) |
Get current clock rate for LPC_I2C peripheral.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
I2C_EVENTHANDLER_T Chip_I2C_GetMasterEventHandler | ( | I2C_ID_T | id | ) |
Get pointer to current function handling the events.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
void Chip_I2C_Init | ( | I2C_ID_T | id | ) |
Initializes the LPC_I2C peripheral with specified parameter.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Checks if master xfer in progress.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
I2C peripheral state change checking.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Transfer a command to slave and receive data from slave after a repeated start.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
slaveAddr | : Slave address of the I2C device |
cmd | : Command (Address/Register) to be written |
buff | : Pointer to memory that will hold the data received |
len | : Number of bytes to receive |
Set function that must handle I2C events.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
slaveAddr | : Slave address from which data be read |
buff | : Pointer to memory where data read be stored |
len | : Number of bytes to read from slave |
Transmit data to I2C slave using I2C Master mode.
id | : I2C peripheral ID (I2C0, I2C1 .. etc) |
slaveAddr | : Slave address to which the data be written |
buff | : Pointer to buffer having the array of data |
len | : Number of bytes to be transfered from buff |
void Chip_I2C_MasterStateHandler | ( | I2C_ID_T | id | ) |
I2C Master transfer state change handler.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
int Chip_I2C_MasterTransfer | ( | I2C_ID_T | id, |
I2C_XFER_T * | xfer | ||
) |
Transmit and Receive data in master mode.
id | : I2C peripheral selected (I2C0, I2C1 etc) |
xfer | : Pointer to a I2C_XFER_T structure see notes below |
void Chip_I2C_SetClockRate | ( | I2C_ID_T | id, |
uint32_t | clockrate | ||
) |
Set up clock rate for LPC_I2C peripheral.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
clockrate | : Target clock rate value to initialized I2C peripheral (Hz) |
int Chip_I2C_SetMasterEventHandler | ( | I2C_ID_T | id, |
I2C_EVENTHANDLER_T | event | ||
) |
Set function that must handle I2C events.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
event | : Pointer to function that will handle the event (Should not be NULL) |
void Chip_I2C_SlaveSetup | ( | I2C_ID_T | id, |
I2C_SLAVE_ID | sid, | ||
I2C_XFER_T * | xfer, | ||
I2C_EVENTHANDLER_T | event, | ||
uint8_t | addrMask | ||
) |
Setup a slave I2C device.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
sid | : I2C Slave peripheral ID (I2C_SLAVE_0, I2C_SLAVE_1 etc) |
xfer | : Pointer to transfer structure (see note below for more info) |
event | : Event handler for slave transfers |
addrMask | : Address mask to use along with slave address (see notes below for more info) |
void Chip_I2C_SlaveStateHandler | ( | I2C_ID_T | id | ) |
I2C Slave event handler.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |