|
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 |
|
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.
- Before running one of the first four modes, user must have 2 boards connected through I2C1 pins (make sure 2 boards share a common GND pin); after that, run slave mode on one board and then run master mode on another board.
- If choosing master mode (press '1' for polling master or '2' for interrupt master), three phases are generated: transmit an array of bytes (press '1'); receive an array of bytes and verify (press '2'); transmit, generate a repeat start condition and receive an array of bytes from slave (press '3').
- If choosing slave mode (press '3' for polling slave or '4' for interrupt slave), user can press '1' to generate three following phases: receive an array of bytes and verify; transmit an array of bytes; receive, wait for repeat start condition from master and transmit an array of bytes.
- The last mode (I2C TouchScreen - press '5' - only for Keil MCB boards): configures I2C0 as polling master to communicate with STMPE811 and show the coordinates on terminal when touching the screen.
Build procedure: LPCOpen 18xx/43xx build instructions
Supported boards and board setup:
- Hitex LPC1850EVA-A4-2 and LPC4350EVA-A4-2 boards (using UART0)
- PE.13 : I2C1_SDA (X20 pin 5)
- PE.15 : I2C1_SCL (X20 pin 3)
- Keil MCB1857 and MCB4357 boards (using UART3)
- PE.13 : I2C1_SDA
- PE.15 : I2C1_SCL
- NGX Xplorer 1830 and 4330 boards (no UART - users should modify the code to test this example)
- P2.3 : I2C1_SDA
- P2.4 : I2C1_SCL
Submit bug reports for LPCOpen code here.
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.
static void App_I2C_Interrupt_Master |
( |
void |
| ) |
|
|
static |
static void App_I2C_Interrupt_Slave |
( |
void |
| ) |
|
|
static |
static void App_I2C_Polling_Master |
( |
void |
| ) |
|
|
static |
static void App_I2C_Polling_Slave |
( |
void |
| ) |
|
|
static |
static void App_I2C_TouchScreen |
( |
void |
| ) |
|
|
static |
static void Buffer_Init |
( |
uint8_t * |
buffer, |
|
|
uint8_t |
type |
|
) |
| |
|
static |
void I2C1_IRQHandler |
( |
void |
| ) |
|
I2C Interrupt Handler.
- Returns
- None
Definition at line 582 of file i2c.c.
Main program body.
- Returns
- int
Definition at line 604 of file i2c.c.
static void print_menu |
( |
void |
| ) |
|
|
static |
volatile bool isMasterMode = true |
|
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 |
char menu2[] = "\n\rI2C demo terminated!" |
|
static |
char menu3[] = "\t - Press c to continue...\n\r" |
|
static |