Example description
This example shows how to configure I2C as master or slave device using ROM-based APIs.
This demo supports both 7-bit and 10-bit slave addressing. After setting up successfully, all transmit/receive functions will be called step by step.
If error occurs, this example will hang up. When all steps run successfully, the demo will end and blue LED will be shown.
Special connection requirements
User needs 2 boards connected through P0.10 (SDA), P0.11 (SCL) and a common GND (need two pull-up resistors for I2C bus because P0.10 and P0.11 are special I2C open-drain pins).
Build procedures:
LPC8xx example quickstart for IAR EWARM
LPC8xx example quickstart for Keil uVision4
LPC8xx example quickstart for Code Red Xpresso
Supported boards and board setup:
NXP Xpresso LPC812 board
Submitting LPCOpen issues:
Community support for LPCOpen
| #define BUFFER_SIZE (0xFF) |
Max buffer length
Definition at line 76 of file i2c.c.
| #define I2C_BITRATE (1000000) |
1Mbps I2C bit-rate
Definition at line 74 of file i2c.c.
| #define I2C_MASTER_MODE 1 |
I2C mode: 1 - Master Mode, 0 - Slave Mode
Definition at line 66 of file i2c.c.
| #define I2C_ROM_MEM_SIZE (0x100UL) |
Memory size for I2C ROM
Definition at line 72 of file i2c.c.
| #define I2C_SLAVE_ADDR_10BIT (0x2CA) |
10-bit slave address
Definition at line 70 of file i2c.c.
| #define I2C_SLAVE_ADDR_7BIT (0x90) |
7-bit slave address
Definition at line 68 of file i2c.c.
| static void App_I2C_Master_10bitAddressTest |
( |
void |
| ) |
|
|
static |
| static void App_I2C_Master_Interrupt |
( |
void |
| ) |
|
|
static |
| static void App_I2C_Master_Polling |
( |
void |
| ) |
|
|
static |
| static void Buffer_Compare |
( |
uint8_t * |
buffer1, |
|
|
uint8_t * |
buffer2, |
|
|
uint32_t |
StartPos, |
|
|
uint32_t |
StopPos |
|
) |
| |
|
static |
| static void Buffer_Init |
( |
uint8_t * |
buffer, |
|
|
uint32_t |
buf_len, |
|
|
uint8_t |
type |
|
) |
| |
|
static |
Definition at line 99 of file i2c.c.
Set up hardware for lpc8xx I2C example.
- Returns
- Nothing
Definition at line 496 of file i2c.c.
| void I2C_IRQHandler |
( |
void |
| ) |
|
I2C Interrupt Service Routine.
- Returns
- Nothing
Definition at line 486 of file i2c.c.
Main routine for I2C example.
Main program body.
- Returns
- Function should not exit.
defined(CHIP_LPC175X_6X)
Definition at line 530 of file i2c.c.
| static void spin_on_error |
( |
void |
| ) |
|
|
static |
Definition at line 87 of file i2c.c.
Definition at line 80 of file i2c.c.
Definition at line 78 of file i2c.c.
Definition at line 79 of file i2c.c.
| volatile bool isRxCompleted = false |
Definition at line 84 of file i2c.c.
| volatile bool isTxCompleted = false |
Definition at line 83 of file i2c.c.
| volatile bool isTxRxCompleted = false |
Definition at line 85 of file i2c.c.
Definition at line 81 of file i2c.c.
Definition at line 82 of file i2c.c.
Definition at line 88 of file i2c.c.