![]() |
LPCOpen Platform for LPC18XX/43XX microcontrollers
18XX43XX
LPCOpen Platform for the NXP LPC18XX/43XX family of Microcontrollers
|
#include "chip.h"Go to the source code of this file.
Data Structures | |
| struct | i2c_interface |
| struct | i2c_slave_interface |
Macros | |
| #define | I2C_CON_FLAGS (I2C_CON_AA | I2C_CON_SI | I2C_CON_STO | I2C_CON_STA) |
| #define | LPC_I2Cx(id) ((i2c[id].ip)) |
| #define | SLAVE_ACTIVE(iic) (((iic)->flags & 0xFF00) != 0) |
Functions | |
| STATIC INLINE void | enableClk (I2C_ID_T id) |
| STATIC INLINE void | disableClk (I2C_ID_T id) |
| STATIC INLINE uint32_t | getClkRate (I2C_ID_T id) |
| STATIC INLINE void | startMasterXfer (LPC_I2C_T *pI2C) |
| STATIC INLINE void | startSlaverXfer (LPC_I2C_T *pI2C) |
| STATIC INLINE int | isI2CBusFree (LPC_I2C_T *pI2C) |
| STATIC INLINE int | getCurState (LPC_I2C_T *pI2C) |
| STATIC INLINE int | isMasterState (LPC_I2C_T *pI2C) |
| STATIC void | setSlaveAddr (LPC_I2C_T *pI2C, I2C_SLAVE_ID sid, uint8_t addr, uint8_t mask) |
| STATIC int | isSlaveAddrMatching (uint8_t addr1, uint8_t addr2, uint8_t mask) |
| STATIC I2C_SLAVE_ID | lookupSlaveIndex (LPC_I2C_T *pI2C, uint8_t slaveAddr) |
| int | handleMasterXferState (LPC_I2C_T *pI2C, I2C_XFER_T *xfer) |
| I2C_SLAVE_ID | getSlaveIndex (LPC_I2C_T *pI2C) |
| int | handleSlaveXferState (LPC_I2C_T *pI2C, I2C_XFER_T *xfer) |
| 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... | |
| void | Chip_I2C_Init (I2C_ID_T id) |
| Initializes the LPC_I2C peripheral with specified parameter. More... | |
| void | Chip_I2C_DeInit (I2C_ID_T id) |
| De-initializes the I2C peripheral registers to their default reset values. More... | |
| void | Chip_I2C_SetClockRate (I2C_ID_T id, uint32_t clockrate) |
| Set up clock rate for LPC_I2C peripheral. More... | |
| uint32_t | Chip_I2C_GetClockRate (I2C_ID_T id) |
| Get current 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... | |
| I2C_EVENTHANDLER_T | Chip_I2C_GetMasterEventHandler (I2C_ID_T id) |
| Get pointer to current function handling the events. More... | |
| int | Chip_I2C_MasterTransfer (I2C_ID_T id, I2C_XFER_T *xfer) |
| Transmit and Receive data in master mode. 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... | |
| 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_IsMasterActive (I2C_ID_T id) |
| Checks if master xfer in progress. More... | |
| void | Chip_I2C_MasterStateHandler (I2C_ID_T id) |
| I2C Master transfer state change handler. 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... | |
| void | Chip_I2C_Disable (I2C_ID_T id) |
| Disable I2C peripheral's operation. More... | |
| int | Chip_I2C_IsStateChanged (I2C_ID_T id) |
| I2C peripheral state change checking. More... | |
Variables | |
| static struct i2c_interface | i2c [I2C_NUM_INTERFACE] |
| static struct i2c_slave_interface | i2c_slave [I2C_NUM_INTERFACE][I2C_SLAVE_NUM_INTERFACE] |
| #define I2C_CON_FLAGS (I2C_CON_AA | I2C_CON_SI | I2C_CON_STO | I2C_CON_STA) |
Definition at line 39 of file i2c_18xx_43xx.c.
| #define LPC_I2Cx | ( | id | ) | ((i2c[id].ip)) |
Definition at line 40 of file i2c_18xx_43xx.c.
| #define SLAVE_ACTIVE | ( | iic | ) | (((iic)->flags & 0xFF00) != 0) |
Definition at line 41 of file i2c_18xx_43xx.c.
| 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 375 of file i2c_18xx_43xx.c.
| void Chip_I2C_Disable | ( | I2C_ID_T | id | ) |
Disable I2C peripheral's operation.
| id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 544 of file i2c_18xx_43xx.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 330 of file i2c_18xx_43xx.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 346 of file i2c_18xx_43xx.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 394 of file i2c_18xx_43xx.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 410 of file i2c_18xx_43xx.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 366 of file i2c_18xx_43xx.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 481 of file i2c_18xx_43xx.c.
| int Chip_I2C_IsStateChanged | ( | I2C_ID_T | id | ) |
I2C peripheral state change checking.
| id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 550 of file i2c_18xx_43xx.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 457 of file i2c_18xx_43xx.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 470 of file i2c_18xx_43xx.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 444 of file i2c_18xx_43xx.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 487 of file i2c_18xx_43xx.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 416 of file i2c_18xx_43xx.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 384 of file i2c_18xx_43xx.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 400 of file i2c_18xx_43xx.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 495 of file i2c_18xx_43xx.c.
| void Chip_I2C_SlaveStateHandler | ( | I2C_ID_T | id | ) |
I2C Slave event handler.
| id | : I2C peripheral ID (I2C0, I2C1 ... etc) |
Definition at line 518 of file i2c_18xx_43xx.c.
Definition at line 81 of file i2c_18xx_43xx.c.
Definition at line 76 of file i2c_18xx_43xx.c.
Definition at line 87 of file i2c_18xx_43xx.c.
Definition at line 119 of file i2c_18xx_43xx.c.
| I2C_SLAVE_ID getSlaveIndex | ( | LPC_I2C_T * | pI2C | ) |
Definition at line 248 of file i2c_18xx_43xx.c.
| int handleMasterXferState | ( | LPC_I2C_T * | pI2C, |
| I2C_XFER_T * | xfer | ||
| ) |
Definition at line 175 of file i2c_18xx_43xx.c.
| int handleSlaveXferState | ( | LPC_I2C_T * | pI2C, |
| I2C_XFER_T * | xfer | ||
| ) |
Definition at line 265 of file i2c_18xx_43xx.c.
Definition at line 113 of file i2c_18xx_43xx.c.
Definition at line 125 of file i2c_18xx_43xx.c.
| STATIC int isSlaveAddrMatching | ( | uint8_t | addr1, |
| uint8_t | addr2, | ||
| uint8_t | mask | ||
| ) |
Definition at line 145 of file i2c_18xx_43xx.c.
| STATIC I2C_SLAVE_ID lookupSlaveIndex | ( | LPC_I2C_T * | pI2C, |
| uint8_t | slaveAddr | ||
| ) |
Definition at line 152 of file i2c_18xx_43xx.c.
| STATIC void setSlaveAddr | ( | LPC_I2C_T * | pI2C, |
| I2C_SLAVE_ID | sid, | ||
| uint8_t | addr, | ||
| uint8_t | mask | ||
| ) |
Definition at line 131 of file i2c_18xx_43xx.c.
Definition at line 93 of file i2c_18xx_43xx.c.
Definition at line 103 of file i2c_18xx_43xx.c.
|
static |
Definition at line 61 of file i2c_18xx_43xx.c.
|
static |
Definition at line 66 of file i2c_18xx_43xx.c.
1.8.3.1