![]() |
LPCOpen Platform for LPC112X microcontrollers
112X
LPCOpen Platform for the NXP LPC112X family of Microcontrollers
|
#include "i2c_common_112x.h"
Go to the source code of this file.
Data Structures | |
struct | I2C_XFER_T |
Master transfer data structure definitions. More... | |
#define I2C_BYTE_RECV 0x02 |
Definition at line 78 of file i2c_112x.h.
#define I2C_BYTE_SENT 0x01 |
Definition at line 77 of file i2c_112x.h.
#define I2C_CheckError | ( | ErrorCode | ) | (ErrorCode & 0x10000000) |
Definition at line 87 of file i2c_112x.h.
#define I2C_ERR (0x10000000) |
Definition at line 84 of file i2c_112x.h.
#define I2C_I2STAT_BUS_ERROR ((0x00)) |
Bus Error
Definition at line 64 of file i2c_112x.h.
#define I2C_I2STAT_NO_INF ((0xF8)) |
No relevant information
Definition at line 63 of file i2c_112x.h.
#define I2C_LAST_BYTE_RECV 0x04 |
Definition at line 79 of file i2c_112x.h.
#define I2C_MONITOR_CFG_MATCHALL I2C_I2MMCTRL_MATCH_ALL |
Select interrupt register match
Definition at line 93 of file i2c_112x.h.
#define I2C_MONITOR_CFG_SCL_OUTPUT I2C_I2MMCTRL_ENA_SCL |
SCL output enable
Definition at line 92 of file i2c_112x.h.
#define I2C_NAK_RECV (0x10000000 | 0x01) |
Definition at line 85 of file i2c_112x.h.
#define I2C_OK 0x00 |
Definition at line 76 of file i2c_112x.h.
#define I2C_RECV_END 0x10 |
Definition at line 81 of file i2c_112x.h.
#define I2C_SEND_END 0x08 |
Definition at line 80 of file i2c_112x.h.
#define I2C_SETUP_STATUS_ARBF (1 << 8) |
Arbitration false
Definition at line 69 of file i2c_112x.h.
#define I2C_SETUP_STATUS_DONE (1 << 10) |
Status DONE
Definition at line 71 of file i2c_112x.h.
#define I2C_SETUP_STATUS_NOACKF (1 << 9) |
No ACK returned
Definition at line 70 of file i2c_112x.h.
#define I2C_STA_STO_RECV 0x20 |
I2C state handle return values.
Definition at line 82 of file i2c_112x.h.
#define I2C_STA_STO_RECV 0x20 |
I2C state handle return values.
Definition at line 82 of file i2c_112x.h.
#define RET_SLAVE_BUSY 0 |
Return value, when slave is busy
Definition at line 53 of file i2c_112x.h.
#define RET_SLAVE_IDLE 2 |
Return value, when slave enter idle mode
Definition at line 52 of file i2c_112x.h.
#define RET_SLAVE_RX 5 |
Return value, when 1 byte RX'd successfully
Definition at line 51 of file i2c_112x.h.
#define RET_SLAVE_TX 6 |
Return values for SLAVE handler.
Definition at line 50 of file i2c_112x.h.
typedef void(* I2C_EVENTHANDLER_T)(I2C_ID_T, I2C_EVENT_T) |
Event handler function type.
Definition at line 161 of file i2c_112x.h.
enum I2C_EVENT_T |
I2C master events.
Definition at line 149 of file i2c_112x.h.
enum I2C_ID_T |
I2C interface IDs.
Enumerator | |
---|---|
I2C0 |
ID I2C0 |
I2C_NUM_INTERFACE |
Number of I2C interfaces in the chip |
Definition at line 141 of file i2c_112x.h.
enum I2C_SLAVE_ID |
I2C Slave Identifiers.
Definition at line 98 of file i2c_112x.h.
enum I2C_STATUS_T |
I2C transfer status.
Definition at line 110 of file i2c_112x.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) |
Definition at line 374 of file i2c_112x.c.
void Chip_I2C_Disable | ( | I2C_ID_T | id | ) |
Disable I2C peripheral's operation.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 543 of file i2c_112x.c.
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 |
Definition at line 326 of file i2c_112x.c.
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 |
Definition at line 342 of file i2c_112x.c.
uint32_t Chip_I2C_GetClockRate | ( | I2C_ID_T | id | ) |
Get current clock rate for LPC_I2C peripheral.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 393 of file i2c_112x.c.
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) |
Definition at line 409 of file i2c_112x.c.
void Chip_I2C_Init | ( | I2C_ID_T | id | ) |
Initializes the LPC_I2C peripheral with specified parameter.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 362 of file i2c_112x.c.
int Chip_I2C_IsMasterActive | ( | I2C_ID_T | id | ) |
Checks if master xfer in progress.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 480 of file i2c_112x.c.
int Chip_I2C_IsStateChanged | ( | I2C_ID_T | id | ) |
I2C peripheral state change checking.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 549 of file i2c_112x.c.
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.
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 |
Definition at line 456 of file i2c_112x.c.
int Chip_I2C_MasterRead | ( | I2C_ID_T | id, |
uint8_t | slaveAddr, | ||
uint8_t * | buff, | ||
int | len | ||
) |
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 |
Definition at line 469 of file i2c_112x.c.
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.
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 |
Definition at line 443 of file i2c_112x.c.
void Chip_I2C_MasterStateHandler | ( | I2C_ID_T | id | ) |
I2C Master transfer state change handler.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 486 of file i2c_112x.c.
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 |
Definition at line 415 of file i2c_112x.c.
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) |
Definition at line 383 of file i2c_112x.c.
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) |
Definition at line 399 of file i2c_112x.c.
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) |
Definition at line 494 of file i2c_112x.c.
void Chip_I2C_SlaveStateHandler | ( | I2C_ID_T | id | ) |
I2C Slave event handler.
id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 517 of file i2c_112x.c.