Inter-Integrated Circuit communication API
Available signals and pins:
picoCIAA | Signal |
P8_5 | I2C1_SCL |
P8_8 | I2C1_SDA |
P8_3 | I2C0_SCL |
P8_6 | I2C0_SDA |
P8_7 | I2C2_SCL |
P2_13 | I2C2_SDA |
- Note
- use I2C1 as default because it has external pull-ups available
Available I2C ports
Enumerator |
---|
I2C0 |
I2C0 on pins P8_3 (SCL) and P8_6 (SDA)
|
I2C1 |
I2C1 on pins P8_5 (SCL) and P8_8 (SDA) with external pull-ups
|
I2C2 |
I2C2 on pins P8_7 (SCL) and P2_13 (SDA)
|
initialize I2C port
- Parameters
-
int32_t picoI2CTransfer |
( |
picoI2CPort |
p, |
|
|
uint8_t |
slave_addr, |
|
|
uint8_t * |
txbuf, |
|
|
uint16_t |
txlen, |
|
|
uint8_t * |
rxbuf, |
|
|
uint16_t |
rxlen |
|
) |
| |
transmit and receive data to/from I2C port
- Parameters
-
p | port number, can be I2C0, I2C1 or I2C2. |
slave_addr | slave ID |
txbuf | transmit data buffer |
txlen | transmit data buffer length in bytes |
rxbuf | receive data buffer |
rxlen | receive data buffer length in bytes |
- Returns
- 0 on success, other value in case of I2C error