LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
I2C example

Macros

#define I2CDEV_UDA1380_ADDR   (0x34 >> 1)
 
#define I2CDEV_STMPE811_ADDR   (0x82 >> 1)
 
#define I2CDEV_S_ADDR   (0x90 >> 1)
 
#define BUFFER_SIZE   0xFF
 
#define C_GLCD_H_SIZE   240
 
#define C_GLCD_V_SIZE   320
 

Functions

static void print_menu (void)
 
static void Buffer_Init (uint8_t *buffer, uint8_t type)
 
static void App_I2C_Polling_Master (void)
 
static void App_I2C_Interrupt_Master (void)
 
static void App_I2C_Polling_Slave (void)
 
static void App_I2C_Interrupt_Slave (void)
 
static void App_I2C_TouchScreen (void)
 
void I2C1_IRQHandler (void)
 I2C Interrupt Handler.
 
int main (void)
 Main program body.
 

Variables

static char menu []
 
static char menu1 [] = "\n\r \t - Press x to exit this mode!\n\r"
 
static char menu2 [] = "\n\rI2C demo terminated!"
 
static char menu3 [] = "\t - Press c to continue...\n\r"
 
static volatile bool complete
 
static volatile bool isMasterMode = true
 

Detailed Description

The I2C example shows how to use I2C interface for communicating between master and slave in POLLING/INTERRUPT mode.

To use the example, connect a serial cable to the board's RS232/UART port and start a terminal program to monitor the port. The terminal program on the host PC should be setup for 115K8N1.

After a welcome screen is displayed via UART, I2C0 and I2C1 are configured with 100KHz speed. This example supports five modes.

Build procedure: LPCOpen 18xx/43xx build instructions

Supported boards and board setup:

Submit bug reports for LPCOpen code here.

Macro Definition Documentation

#define BUFFER_SIZE   0xFF

Definition at line 91 of file i2c.c.

#define C_GLCD_H_SIZE   240

Definition at line 93 of file i2c.c.

#define C_GLCD_V_SIZE   320

Definition at line 94 of file i2c.c.

#define I2CDEV_S_ADDR   (0x90 >> 1)

Definition at line 88 of file i2c.c.

#define I2CDEV_STMPE811_ADDR   (0x82 >> 1)

Definition at line 85 of file i2c.c.

#define I2CDEV_UDA1380_ADDR   (0x34 >> 1)

Definition at line 84 of file i2c.c.

Function Documentation

static void App_I2C_Interrupt_Master ( void  )
static

Definition at line 250 of file i2c.c.

static void App_I2C_Interrupt_Slave ( void  )
static

Definition at line 449 of file i2c.c.

static void App_I2C_Polling_Master ( void  )
static

Definition at line 143 of file i2c.c.

static void App_I2C_Polling_Slave ( void  )
static

Definition at line 366 of file i2c.c.

static void App_I2C_TouchScreen ( void  )
static

Definition at line 545 of file i2c.c.

static void Buffer_Init ( uint8_t *  buffer,
uint8_t  type 
)
static

Definition at line 128 of file i2c.c.

void I2C1_IRQHandler ( void  )

I2C Interrupt Handler.

Returns
None

Definition at line 582 of file i2c.c.

int main ( void  )

Main program body.

Returns
int

Definition at line 604 of file i2c.c.

static void print_menu ( void  )
static

Definition at line 122 of file i2c.c.

Variable Documentation

volatile bool complete
static

Definition at line 110 of file i2c.c.

volatile bool isMasterMode = true
static

Definition at line 111 of file i2c.c.

char menu[]
static
Initial value:
=
"\n\rHello NXP Semiconductors \n\r"
"I2C demo \n\r"
"\n\rPress 1-5 to select I2C running mode or 'ESC' to terminate the demo:\n\r\n\r"
"\t 1 - I2C Polling Master\n\r"
"\t 2 - I2C Interrupt Master\n\r"
"\t 3 - I2C Polling Slave \n\r"
"\t 4 - I2C Interrupt Slave \n\r"
"\t 5 - I2C TouchScreen \n\r"
"\n\rNote: Master mode can only run combine with Slave mode and vice versa."

Definition at line 96 of file i2c.c.

char menu1[] = "\n\r \t - Press x to exit this mode!\n\r"
static

Definition at line 106 of file i2c.c.

char menu2[] = "\n\rI2C demo terminated!"
static

Definition at line 107 of file i2c.c.

char menu3[] = "\t - Press c to continue...\n\r"
static

Definition at line 108 of file i2c.c.