I2C¶
4G LTE Module I2C Port Mapping¶
I2C Port 0¶
I2C Pin |
EC600U |
EC200U |
N58 |
N716 |
L610 |
EG915U |
|---|---|---|---|---|---|---|
SCL |
Pin 11 |
Pin 41 |
Pin 59 |
Pin 122 |
Pin 41 |
Pin 103 |
SDA |
Pin 12 |
Pin 42 |
Pin 58 |
Pin 121 |
Pin 42 |
Pin 114 |
I2C Port 1¶
I2C Pin |
EC600U |
EC200U |
N58 |
N716 |
L610 |
EG915U |
|---|---|---|---|---|---|---|
SCL |
Pin 57 |
Pin 141 |
Pin 82 |
Pin 71 |
Pin 141 |
Pin 40 |
SDA |
Pin 56 |
Pin 142 |
Pin 81 |
Pin 70 |
Pin 142 |
Pin 41 |
GSM/NB-IoT Module I2C Port Mapping¶
GSM (MT2503, MT6261) and NB-IoT (MT2625) chipset supported modules expose only one I2C port. Following is the pin mapping for SCL and SDA:
I2C Pin |
MC20U Pin
|
M56 Pin |
MC60 Pin
|
M66 Pin |
BC20 Pin |
SIM868 Pin |
|---|---|---|---|---|---|---|
SCL |
Pin 35 |
Pin 24 |
Pin 35 |
Pin 20 |
Pin 58 |
Pin 65 |
SDA |
Pin 36 |
Pin 23 |
Pin 36 |
Pin 21 |
Pin 63 |
Pin 64 |
API Reference¶
Header File¶
Source: include/hw/i2c.h
#include <hw/i2c.h>
Functions¶
-
int i2c_hw_init(int port, int speed_khz)¶
Initialize I2C hardware and setup pin-mux. Please check hardware guide for I2C pin details.
- Parameters
port – [in] I2C Port (i2cport_e)
speed_khz – [in] I2C Speed in Khz (must be < 400)
- Returns
0 on success, negative value on error
-
int i2c_hw_setspeed(int port, int speed_khz)¶
Set I2C master clock speed
- Parameters
port – [in] I2C Port (i2cport_e)
speed_khz – [in] I2C Speed in Khz (must be < 400)
- Returns
0 on success, negative value on error
-
int i2c_hw_write(int port, unsigned char address, const void *buffer, int len)¶
Master send data over I2C slave device Hardware FIFO only support upto 8 bytes at one time for transfer
- Parameters
port – [in] I2C Port (i2cport_e)
address – [in] 7-bit Slave address
buffer – [in] Pointer to buffer containing data
len – [in] Length of data to send (must be less than or equal to 8)
- Returns
Length of bytes written on success, negative value on error
-
int i2c_hw_read(int port, unsigned char address, void *buffer, int len)¶
Master read data from I2C slave device
- Parameters
port – [in] I2C Port (i2cport_e)
address – [in] 7-bit slave address
buffer – [out] Pointer to buffer to store data
len – [in] No. of bytes to read
- Returns
Length of data read from slave on success, negative value on error
-
int i2c_hw_writeread(int port, unsigned char address, const void *wrbuf, int wrlen, void *rdbuf, int rdlen)¶
Write and Read operation with repeated start. Operation is performed in two transactions separated by repeated start, Each transaction is limited to max fifo length of 8 bytes.
- Parameters
port – [in] I2C Port (i2cport_e)
address – [in] 7-bit slave address
wrbuf – [in] Pointer to buffer for write operation
wrlen – [in] Length of data in wrbuf
rdbuf – [out] Pointer to buffer for storing data
rdlen – [in] No. of bytes to read
- Returns
Length of data read from slave on success, negative value on error
Header File¶
Source: include/plat/def_i2c.h
#include <plat/def_i2c.h>
