Example description
This example shows how to use I2C as master or slave and communicate between Master and Slave with polling/interrupt mode. (Interrupt mode is default)
After setting up connection, run the example in both the boards. At regular intervals both the boards will send data as master and receive data from master hence blinking the LED at regular intervals (Both boards will act as master as well as slave).
If you have UART connected define DEBUG_ENABLE in sys_config.h, and can interactively use the example to access I2C data for more information see LPC18xx/43xx I2C example
Special connection requirements
- User needs 2 boards and must setup the following connection between them
- Connect PIO0_5(SDA) of both the boards with a wire
- Connect PIO0_4(SCL) of both boards with a wire
- Connect J6-PIN1(GND) of both boards with a wire
- Pull up SDA & SCL using two 10K resistors between SDA,SCL and J6-PIN28(3v3)
Build procedures:
LPC11xx example quickstart for Code Red Xpresso
LPC11xx example quickstart for Keil uVision4
LPC11xx example quickstart for IAR EWARM
Supported boards and board setup:
NXP Xpresso LPC11U14 board
NXP Xpresso LPC11C24 board
Submitting LPCOpen issues:
Community support for LPCOpen
Definition at line 75 of file i2c.c.
Definition at line 77 of file i2c.c.
Definition at line 78 of file i2c.c.
| #define I2C_SLAVE_EEPROM_ADDR 0x5A |
| #define I2C_SLAVE_EEPROM_SIZE 64 |
Definition at line 99 of file i2c.c.
| #define I2C_SLAVE_IOX_ADDR 0x5B |
| #define SPEED_100KHZ 100000 |
Definition at line 80 of file i2c.c.
| #define SPEED_400KHZ 400000 |
Definition at line 81 of file i2c.c.
| static int con_get_input |
( |
const char * |
str | ) |
|
|
static |
| static void con_print_data |
( |
const uint8_t * |
dat, |
|
|
int |
sz |
|
) |
| |
|
static |
| static void i2c_app_init |
( |
I2C_ID_T |
id, |
|
|
int |
speed |
|
) |
| |
|
static |
| static void i2c_eeprom_init |
( |
I2C_ID_T |
id | ) |
|
|
static |
| static void i2c_eeprom_update_state |
( |
I2C_XFER_T * |
xfer, |
|
|
uint8_t * |
buff, |
|
|
int |
sz |
|
) |
| |
|
static |
| void i2c_iox_update_regs |
( |
int |
ops | ) |
|
| void I2C_IRQHandler |
( |
void |
| ) |
|
I2C Interrupt Handler.
- Returns
- None
Definition at line 419 of file i2c.c.
| static int i2c_menu |
( |
void |
| ) |
|
|
static |
| static void i2c_probe_slaves |
( |
I2C_ID_T |
i2c | ) |
|
|
static |
| static void i2c_rw_input |
( |
I2C_XFER_T * |
xfer, |
|
|
int |
ops |
|
) |
| |
|
static |
| static void i2c_set_mode |
( |
I2C_ID_T |
id, |
|
|
int |
polling |
|
) |
| |
|
static |
| static void i2c_state_handling |
( |
I2C_ID_T |
id | ) |
|
|
static |
Main program body.
- Returns
- int
defined(CHIP_LPC175X_6X)
Definition at line 428 of file i2c.c.
| void SysTick_Handler |
( |
void |
| ) |
|
SysTick Interrupt Handler.
SysTick 1mS tick handler.
- Returns
- Nothing
- Note
- Systick interrupt handler updates the button status
Definition at line 409 of file i2c.c.
Definition at line 96 of file i2c.c.
Definition at line 95 of file i2c.c.