i2c_base.cpp File Reference
#include <string.h>
#include "i2c_base.hpp"
#include "lpc_sys.h"
Include dependency graph for i2c_base.cpp:

Macros

#define I2C_SET_READ_MODE(addr)   (addr |= 1)
 Set the LSB to indicate read-mode. More...
 
#define I2C_SET_WRITE_MODE(addr)   (addr &= 0xFE)
 Reset the LSB to indicate write-mode. More...
 
#define I2C_READ_MODE(addr)   (addr & 1)
 Read address is ODD. More...
 
#define I2C_WRITE_ADDR(addr)   (addr & 0xFE)
 Write address is EVEN. More...
 
#define I2C_READ_ADDR(addr)   (addr | 1)
 Read address is ODD. More...
 
#define clearSIFlag()   mpI2CRegs->I2CONCLR = (1<<3)
 
#define setSTARTFlag()   mpI2CRegs->I2CONSET = (1<<5)
 
#define clearSTARTFlag()   mpI2CRegs->I2CONCLR = (1<<5)
 
#define setAckFlag()   mpI2CRegs->I2CONSET = (1<<2)
 
#define setNackFlag()   mpI2CRegs->I2CONCLR = (1<<2)
 
#define setStop()
 

Macro Definition Documentation

#define clearSIFlag ( )    mpI2CRegs->I2CONCLR = (1<<3)
#define clearSTARTFlag ( )    mpI2CRegs->I2CONCLR = (1<<5)
#define I2C_READ_ADDR (   addr)    (addr | 1)

Read address is ODD.

#define I2C_READ_MODE (   addr)    (addr & 1)

Read address is ODD.

#define I2C_SET_READ_MODE (   addr)    (addr |= 1)

Set the LSB to indicate read-mode.

Instead of using a dedicated variable for read vs. write, we just use the LSB of the user address to indicate read or write mode.

#define I2C_SET_WRITE_MODE (   addr)    (addr &= 0xFE)

Reset the LSB to indicate write-mode.

#define I2C_WRITE_ADDR (   addr)    (addr & 0xFE)

Write address is EVEN.

#define setAckFlag ( )    mpI2CRegs->I2CONSET = (1<<2)
#define setNackFlag ( )    mpI2CRegs->I2CONCLR = (1<<2)
#define setSTARTFlag ( )    mpI2CRegs->I2CONSET = (1<<5)
#define setStop ( )
Value:
mpI2CRegs->I2CONSET = (1<<4); \
while((mpI2CRegs->I2CONSET&(1<<4))); \
if(I2C_READ_MODE(mTransaction.slaveAddr)) \
state = readComplete; \
else \
state = writeComplete;
#define clearSTARTFlag()
#define I2C_READ_MODE(addr)
Read address is ODD.
Definition: i2c_base.cpp:32
#define clearSIFlag()