| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
i2c_001.h File Reference
`#include "sys_config.h"`
`#include "cmsis.h"`

Go to the source code of this file.

## Data Structures
struct | IP_I2C_001_T
| I2C register block structure. More...
struct | I2C_XFER_T
| Master transfer data structure definitions. More...

## Macros
#define | RET_SLAVE_TX 6
| Return values for SLAVE handler.
#define | RET_SLAVE_RX 5
#define | RET_SLAVE_IDLE 2
#define | RET_SLAVE_BUSY 0
#define | I2C_STA_STO_RECV 0x20
| I2C state handle return values.
#define | I2C_I2CONSET_AA ((0x04))
#define | I2C_I2CONSET_SI ((0x08))
#define | I2C_I2CONSET_STO ((0x10))
#define | I2C_I2CONSET_STA ((0x20))
#define | I2C_I2CONSET_I2EN ((0x40))
#define | I2C_I2CONCLR_AAC ((1 << 2))
#define | I2C_I2CONCLR_SIC ((1 << 3))
#define | I2C_I2CONCLR_STOC ((1 << 4))
#define | I2C_I2CONCLR_STAC ((1 << 5))
#define | I2C_I2CONCLR_I2ENC ((1 << 6))
#define | I2C_CON_AA (1UL << 2)
#define | I2C_CON_SI (1UL << 3)
#define | I2C_CON_STO (1UL << 4)
#define | I2C_CON_STA (1UL << 5)
#define | I2C_CON_I2EN (1UL << 6)
#define | I2C_STAT_CODE_BITMASK ((0xF8))
#define | I2C_STAT_CODE_ERROR ((0xFF))
#define | I2C_I2STAT_NO_INF ((0xF8))
#define | I2C_I2STAT_BUS_ERROR ((0x00))
#define | I2C_I2STAT_M_TX_START ((0x08))
#define | I2C_I2STAT_M_TX_RESTART ((0x10))
#define | I2C_I2STAT_M_TX_SLAW_ACK ((0x18))
#define | I2C_I2STAT_M_TX_SLAW_NACK ((0x20))
#define | I2C_I2STAT_M_TX_DAT_ACK ((0x28))
#define | I2C_I2STAT_M_TX_DAT_NACK ((0x30))
#define | I2C_I2STAT_M_TX_ARB_LOST ((0x38))
#define | I2C_I2STAT_M_RX_START ((0x08))
#define | I2C_I2STAT_M_RX_RESTART ((0x10))
#define | I2C_I2STAT_M_RX_ARB_LOST ((0x38))
#define | I2C_I2STAT_M_RX_SLAR_ACK ((0x40))
#define | I2C_I2STAT_M_RX_SLAR_NACK ((0x48))
#define | I2C_I2STAT_M_RX_DAT_ACK ((0x50))
#define | I2C_I2STAT_M_RX_DAT_NACK ((0x58))
#define | I2C_I2STAT_S_RX_SLAW_ACK ((0x60))
#define | I2C_I2STAT_S_RX_ARB_LOST_M_SLA ((0x68))
#define | I2C_I2STAT_S_RX_GENCALL_ACK ((0x70))
#define | I2C_I2STAT_S_RX_ARB_LOST_M_GENCALL ((0x78))
#define | I2C_I2STAT_S_RX_PRE_SLA_DAT_ACK ((0x80))
#define | I2C_I2STAT_S_RX_PRE_SLA_DAT_NACK ((0x88))
#define | I2C_I2STAT_S_RX_PRE_GENCALL_DAT_ACK ((0x90))
#define | I2C_I2STAT_S_RX_PRE_GENCALL_DAT_NACK ((0x98))
#define | I2C_I2STAT_S_RX_STA_STO_SLVREC_SLVTRX ((0xA0))
#define | I2C_I2STAT_S_TX_SLAR_ACK ((0xA8))
#define | I2C_I2STAT_S_TX_ARB_LOST_M_SLA ((0xB0))
#define | I2C_I2STAT_S_TX_DAT_ACK ((0xB8))
#define | I2C_I2STAT_S_TX_DAT_NACK ((0xC0))
#define | I2C_I2STAT_S_TX_LAST_DAT_ACK ((0xC8))
#define | I2C_SLAVE_TIME_OUT 0x10000000UL
#define | I2C_I2DAT_BITMASK ((0xFF))
#define | I2C_I2DAT_IDLE_CHAR (0xFF)
#define | I2C_I2MMCTRL_MM_ENA ((1 << 0))
#define | I2C_I2MMCTRL_ENA_SCL ((1 << 1))
#define | I2C_I2MMCTRL_MATCH_ALL ((1 << 2))
#define | I2C_I2MMCTRL_BITMASK ((0x07))
#define | I2DATA_BUFFER_BITMASK ((0xFF))
#define | I2C_I2ADR_GC ((1 << 0))
#define | I2C_I2ADR_BITMASK ((0xFF))
#define | I2C_I2MASK_MASK(n) ((n & 0xFE))
#define | I2C_I2SCLH_BITMASK ((0xFFFF))
#define | I2C_I2SCLL_BITMASK ((0xFFFF))
#define | I2C_SETUP_STATUS_ARBF (1 << 8)
#define | I2C_SETUP_STATUS_NOACKF (1 << 9)
#define | I2C_SETUP_STATUS_DONE (1 << 10)
#define | I2C_OK 0x00
#define | I2C_BYTE_SENT 0x01
#define | I2C_BYTE_RECV 0x02
#define | I2C_LAST_BYTE_RECV 0x04
#define | I2C_SEND_END 0x08
#define | I2C_RECV_END 0x10
#define | I2C_STA_STO_RECV 0x20
| I2C state handle return values.
#define | I2C_ERR (0x10000000)
#define | I2C_NAK_RECV (0x10000000 | 0x01)
#define | I2C_CheckError(ErrorCode) (ErrorCode & 0x10000000)
#define | I2C_MONITOR_CFG_SCL_OUTPUT I2C_I2MMCTRL_ENA_SCL
#define | I2C_MONITOR_CFG_MATCHALL I2C_I2MMCTRL_MATCH_ALL

## Enumerations
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
STATIC INLINE void | IP_I2C_Init (IP_I2C_001_T *pI2C)
| Initializes the pI2C peripheral.
STATIC INLINE void | IP_I2C_DeInit (IP_I2C_001_T *pI2C)
| De-initializes the I2C peripheral registers to their default reset values.
STATIC INLINE void | IP_I2C_SetClockRate (IP_I2C_001_T *pI2C, uint32_t SCLValue)
| Set up clock rate for I2Cx.
STATIC INLINE uint32_t | IP_I2C_GetClockDiv (IP_I2C_001_T *pI2C)
| Get current divisor clock value.
STATIC INLINE void | IP_I2C_Master_StartXfer (IP_I2C_001_T *pI2C)
| Enable I2C and start master transfer.
int | IP_I2C_MasterXfer_StateHandler (IP_I2C_001_T *pI2C, I2C_XFER_T *xfer)
| Master transfer state change handler.
STATIC INLINE int | IP_I2C_IsStateChanged (IP_I2C_001_T *pI2C)
| I2C State change checking.
STATIC INLINE void | IP_I2C_Disable (IP_I2C_001_T *pI2C)
| Disable I2C peripheral's operation.
STATIC INLINE void | IP_I2C_SetSlaveAddress (IP_I2C_001_T *pI2C, I2C_SLAVE_ID sid, uint8_t addr, uint8_t mask)
| Set OWN slave address for specific slave ID.
STATIC INLINE int | IP_I2C_GetCurrentState (IP_I2C_001_T *pI2C)
| Get current state of the I2C peripheral.
I2C_SLAVE_ID | IP_I2C_GetSlaveIndex (IP_I2C_001_T *pI2C)
| Get the slave ID of the active slave.
int | IP_I2C_SlaveXfer_StateHandler (IP_I2C_001_T *pI2C, I2C_XFER_T *xfer)
| Slave transfer state change handler.
STATIC INLINE void | IP_I2C_Slave_StartXfer (IP_I2C_001_T *pI2C)
| Enable I2C and enable slave transfers.
STATIC INLINE int | IP_I2C_BusFree (IP_I2C_001_T *pI2C)
| Check if I2C bus is free.
STATIC INLINE int | IP_I2C_IsMasterState (IP_I2C_001_T *pI2C)
| Check if the active state belongs to master mode.