![]() |
LPCOpen Platform for LPC18XX/43XX microcontrollers
18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
|
This driver only works in master mode. To describe the I2C transactions following symbols are used in driver documentation.
S (1 bit) : Start bit P (1 bit) : Stop bit Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0. A, NA (1 bit) : Acknowledge and Not-Acknowledge bit. Addr (7 bits): I2C 7 bit address. Note that this can be expanded as usual to get a 10 bit I2C address. Data (8 bits): A plain data byte. Sometimes, I write DataLow, DataHigh for 16 bit data. [..]: Data sent by I2C device, as opposed to data sent by the host adapter.
Data Structures | |
| struct | I2CM_XFER_T |
| Master transfer data structure definitions. More... | |
Functions | |
| void | Chip_I2CM_Init (LPC_I2C_T *pI2C) |
| Initialize I2C Interface. More... | |
| void | Chip_I2CM_DeInit (LPC_I2C_T *pI2C) |
| Shutdown I2C Interface. More... | |
| static INLINE void | Chip_I2CM_SetDutyCycle (LPC_I2C_T *pI2C, uint16_t sclH, uint16_t sclL) |
| Sets HIGH and LOW duty cycle registers. More... | |
| void | Chip_I2CM_SetBusSpeed (LPC_I2C_T *pI2C, uint32_t busSpeed) |
| Set up bus speed for LPC_I2C controller. More... | |
| static INLINE void | Chip_I2CM_SendStart (LPC_I2C_T *pI2C) |
| Transmit START or Repeat-START signal on I2C bus. More... | |
| static INLINE void | Chip_I2CM_ResetControl (LPC_I2C_T *pI2C) |
| Reset I2C controller state. More... | |
| static INLINE void | Chip_I2CM_WriteByte (LPC_I2C_T *pI2C, uint8_t data) |
| Transmit a single data byte through the I2C peripheral. More... | |
| static INLINE uint8_t | Chip_I2CM_ReadByte (LPC_I2C_T *pI2C) |
| Read a single byte data from the I2C peripheral. More... | |
| static INLINE void | Chip_I2CM_NackNextByte (LPC_I2C_T *pI2C) |
| Generate NACK after receiving next byte. More... | |
| static INLINE void | Chip_I2CM_SendStop (LPC_I2C_T *pI2C) |
| Transmit STOP signal on I2C bus. More... | |
| static INLINE void | Chip_I2CM_ForceStart (LPC_I2C_T *pI2C) |
| Force start I2C transmit. More... | |
| static INLINE void | Chip_I2CM_SendStartAfterStop (LPC_I2C_T *pI2C) |
| Transmit STOP+START signal on I2C bus. More... | |
| static INLINE uint32_t | Chip_I2CM_StateChanged (LPC_I2C_T *pI2C) |
| Check if I2C controller state changed. More... | |
| static INLINE void | Chip_I2CM_ClearSI (LPC_I2C_T *pI2C) |
| Clear state change interrupt flag. More... | |
| static INLINE uint32_t | Chip_I2CM_BusFree (LPC_I2C_T *pI2C) |
| Check if I2C bus is free per our controller. More... | |
| static INLINE uint32_t | Chip_I2CM_GetCurState (LPC_I2C_T *pI2C) |
| Get current state of the I2C controller. More... | |
| static INLINE void | Chip_I2CM_Disable (LPC_I2C_T *pI2C) |
| Disable I2C interface. More... | |
| uint32_t | Chip_I2CM_XferHandler (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer) |
| Transfer state change handler handler. More... | |
| void | Chip_I2CM_Xfer (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer) |
| Transmit and Receive data in master mode. More... | |
| uint32_t | Chip_I2CM_XferBlocking (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer) |
| Transmit and Receive data in master mode. More... | |
| uint32_t | Chip_I2CM_Write (LPC_I2C_T *pI2C, const uint8_t *buff, uint32_t len) |
| Write given buffer of data to I2C interface. More... | |
| uint32_t | Chip_I2CM_Read (LPC_I2C_T *pI2C, uint8_t *buff, uint32_t len) |
| Read data from I2C slave to given buffer. More... | |
| #define I2CM_STATUS_ARBLOST 0x05 |
Arbitration lost.
Definition at line 82 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_BUS_ERROR 0x03 |
I2C bus error
Definition at line 80 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_BUSY 0xFF |
I2C transmitter is busy.
Definition at line 83 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_ERROR 0x01 |
Unknown error condition.
Definition at line 78 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_NAK 0x02 |
No acknowledgement received from slave.
Definition at line 79 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_OK 0x00 |
I2CM_18XX_43XX_STATUS_TYPES I2C master transfer status typesRequested Request was executed successfully.
Definition at line 77 of file i2cm_18xx_43xx.h.
| #define I2CM_STATUS_SLAVE_NAK 0x04 |
No device responded for given slave address during SLA+W or SLA+R
Definition at line 81 of file i2cm_18xx_43xx.h.
| #define I2CM_XFER_OPTION_IGNORE_NACK 0x01 |
I2CM_18XX_43XX_OPTIONS_TYPES I2C master transfer optionsIgnore NACK during data transfer. By default transfer is aborted.
Definition at line 65 of file i2cm_18xx_43xx.h.
| #define I2CM_XFER_OPTION_LAST_RX_ACK 0x02 |
ACK last byte received. By default we NACK last byte we receive per I2C spec.
Definition at line 67 of file i2cm_18xx_43xx.h.
Check if I2C bus is free per our controller.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 290 of file i2cm_18xx_43xx.h.
Clear state change interrupt flag.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 277 of file i2cm_18xx_43xx.h.
| void Chip_I2CM_DeInit | ( | LPC_I2C_T * | pI2C | ) |
Shutdown I2C Interface.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 68 of file i2cm_18xx_43xx.c.
Disable I2C interface.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 313 of file i2cm_18xx_43xx.h.
Force start I2C transmit.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 237 of file i2cm_18xx_43xx.h.
Get current state of the I2C controller.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 302 of file i2cm_18xx_43xx.h.
| void Chip_I2CM_Init | ( | LPC_I2C_T * | pI2C | ) |
Initialize I2C Interface.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 59 of file i2cm_18xx_43xx.c.
Generate NACK after receiving next byte.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 209 of file i2cm_18xx_43xx.h.
| uint32_t Chip_I2CM_Read | ( | LPC_I2C_T * | pI2C, |
| uint8_t * | buff, | ||
| uint32_t | len | ||
| ) |
Read data from I2C slave to given buffer.
| pI2C | : Pointer to selected I2C peripheral |
| buff | : Pointer to buffer for data received from I2C slave |
| len | : Length of the buffer |
S [Data0] A [Data1] A ... [DataN] A
Definition at line 231 of file i2cm_18xx_43xx.c.
Read a single byte data from the I2C peripheral.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 197 of file i2cm_18xx_43xx.h.
Reset I2C controller state.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 168 of file i2cm_18xx_43xx.h.
Transmit START or Repeat-START signal on I2C bus.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 157 of file i2cm_18xx_43xx.h.
Transmit STOP+START signal on I2C bus.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 255 of file i2cm_18xx_43xx.h.
Transmit STOP signal on I2C bus.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 220 of file i2cm_18xx_43xx.h.
| void Chip_I2CM_SetBusSpeed | ( | LPC_I2C_T * | pI2C, |
| uint32_t | busSpeed | ||
| ) |
Set up bus speed for LPC_I2C controller.
| pI2C | : Pointer to selected I2C peripheral |
| busSpeed | : I2C bus clock rate |
Definition at line 77 of file i2cm_18xx_43xx.c.
Sets HIGH and LOW duty cycle registers.
| pI2C | : Pointer to selected I2C peripheral |
| sclH | : Number of I2C_PCLK cycles for the SCL HIGH time. |
| sclL | : Number of I2C_PCLK cycles for the SCL LOW time. |
Definition at line 130 of file i2cm_18xx_43xx.h.
Check if I2C controller state changed.
| pI2C | : Pointer to selected I2C peripheral |
Definition at line 266 of file i2cm_18xx_43xx.h.
| uint32_t Chip_I2CM_Write | ( | LPC_I2C_T * | pI2C, |
| const uint8_t * | buff, | ||
| uint32_t | len | ||
| ) |
Write given buffer of data to I2C interface.
| pI2C | : Pointer to selected I2C peripheral |
| buff | : Pointer to buffer to be transmitted |
| len | : Length of the buffer |
S Data0 [A] Data1 [A] ... DataN [A]
Definition at line 194 of file i2cm_18xx_43xx.c.
Transmit a single data byte through the I2C peripheral.
| pI2C | : Pointer to selected I2C peripheral |
| data | : Byte to transmit |
Definition at line 184 of file i2cm_18xx_43xx.h.
| void Chip_I2CM_Xfer | ( | LPC_I2C_T * | pI2C, |
| I2CM_XFER_T * | xfer | ||
| ) |
Transmit and Receive data in master mode.
| pI2C | : Pointer to selected I2C peripheral |
| xfer | : Pointer to a I2CM_XFER_T structure see notes below |
Write-only transfer: When rxSz member of xfer is set to 0.
S Addr Wr [A] txBuff0 [A] txBuff1 [A] ... txBuffN [A] P
If I2CM_XFER_OPTION_IGNORE_NACK is set in options member
S Addr Wr [A] txBuff0 [A or NA] ... txBuffN [A or NA] P
Read-only transfer: When txSz member of xfer is set to 0.
S Addr Rd [A] [rxBuff0] A [rxBuff1] A ... [rxBuffN] NA P
If I2CM_XFER_OPTION_LAST_RX_ACK is set in options member
S Addr Rd [A] [rxBuff0] A [rxBuff1] A ... [rxBuffN] A P
S Addr Wr [A] txBuff0 [A] txBuff1 [A] ... txBuffN [A]
S Addr Rd [A] [rxBuff0] A [rxBuff1] A ... [rxBuffN] NA P Definition at line 167 of file i2cm_18xx_43xx.c.
| uint32_t Chip_I2CM_XferBlocking | ( | LPC_I2C_T * | pI2C, |
| I2CM_XFER_T * | xfer | ||
| ) |
Transmit and Receive data in master mode.
| pI2C | : Pointer to selected I2C peripheral |
| xfer | : Pointer to a I2CM_XFER_T structure see notes below |
Definition at line 178 of file i2cm_18xx_43xx.c.
| uint32_t Chip_I2CM_XferHandler | ( | LPC_I2C_T * | pI2C, |
| I2CM_XFER_T * | xfer | ||
| ) |
Transfer state change handler handler.
| pI2C | : Pointer to selected I2C peripheral |
| xfer | : Pointer to a I2CM_XFER_T structure see notes below |
Definition at line 85 of file i2cm_18xx_43xx.c.
1.8.3.1