![]() |
LPCOpen Platform for LPC112X microcontrollers
112X
LPCOpen Platform for the NXP LPC112X 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_112x.h.
#define I2CM_STATUS_BUS_ERROR 0x03 |
I2C bus error
Definition at line 80 of file i2cm_112x.h.
#define I2CM_STATUS_BUSY 0xFF |
I2C transmistter is busy.
Definition at line 83 of file i2cm_112x.h.
#define I2CM_STATUS_ERROR 0x01 |
Unknown error condition.
Definition at line 78 of file i2cm_112x.h.
#define I2CM_STATUS_NAK 0x02 |
No acknowledgement received from slave.
Definition at line 79 of file i2cm_112x.h.
#define I2CM_STATUS_OK 0x00 |
I2CM_1125_STATUS_TYPES I2C master transfer status typesRequested Request was executed successfully.
Definition at line 77 of file i2cm_112x.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_112x.h.
#define I2CM_XFER_OPTION_IGNORE_NACK 0x01 |
I2CM_1125_OPTIONS_TYPES I2C master transfer optionsIgnore NACK during data transfer. By default transfer is aborted.
Definition at line 65 of file i2cm_112x.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_112x.h.
Check if I2C bus is free per our controller.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 289 of file i2cm_112x.h.
Clear state change interrupt flag.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 277 of file i2cm_112x.h.
void Chip_I2CM_DeInit | ( | LPC_I2C_T * | pI2C | ) |
Shutdown I2C Interface.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 64 of file i2cm_112x.c.
Disable I2C interface.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 312 of file i2cm_112x.h.
Force start I2C transmit.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 237 of file i2cm_112x.h.
Get current state of the I2C controller.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 301 of file i2cm_112x.h.
void Chip_I2CM_Init | ( | LPC_I2C_T * | pI2C | ) |
Initialize I2C Interface.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 54 of file i2cm_112x.c.
Generate NACK after receiving next byte.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 209 of file i2cm_112x.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 225 of file i2cm_112x.c.
Read a single byte data from the I2C peripheral.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 197 of file i2cm_112x.h.
Reset I2C controller state.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 168 of file i2cm_112x.h.
Transmit START or Repeat-START signal on I2C bus.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 157 of file i2cm_112x.h.
Transmit STOP+START signal on I2C bus.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 255 of file i2cm_112x.h.
Transmit STOP signal on I2C bus.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 220 of file i2cm_112x.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 71 of file i2cm_112x.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_112x.h.
Check if I2C controller state changed.
pI2C | : Pointer to selected I2C peripheral |
Definition at line 266 of file i2cm_112x.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 188 of file i2cm_112x.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_112x.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 memeber
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 memeber
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 161 of file i2cm_112x.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 172 of file i2cm_112x.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 79 of file i2cm_112x.c.