I2C

4G LTE Module I2C Port Mapping

I2C Port 0

I2C Pin

EC600U

EC200U

N58

N716

L610

SCL

Pin 11

Pin 41

Pin 59

Pin 122

Pin 41

SDA

Pin 12

Pin 42

Pin 58

Pin 121

Pin 42

I2C Port 1

I2C Pin

EC600U

EC200U

N58

N716

L610

SCL

Pin 57

Pin 141

Pin 82

Pin 71

Pin 141

SDA

Pin 56

Pin 142

Pin 81

Pin 70

Pin 142

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
S20U Pin

M56 Pin

MC60 Pin
MC20 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

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.

Return

0 on success, negative value on error

Parameters
  • port: [in] I2C Port (i2cport_e)

  • speed_khz: [in] I2C Speed in Khz (must be < 400)

int i2c_hw_setspeed(int port, int speed_khz)

Set I2C master clock speed

Return

0 on success, negative value on error

Parameters
  • port: [in] I2C Port (i2cport_e)

  • speed_khz: [in] I2C Speed in Khz (must be < 400)

int i2c_hw_write(int port, unsigned char address, const unsigned char *buffer, int len)

Master send data over I2C slave device Hardware FIFO only support upto 8 bytes at one time for transfer

Return

Length of bytes written on success, negative value on error

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)

int i2c_hw_read(int port, unsigned char address, unsigned char *buffer, int len)

Master read data from I2C slave device

Return

Length of data read from slave on success, negative value on error

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

int i2c_hw_writeread(int port, unsigned char address, const unsigned char *wrbuf, int wrlen, unsigned char *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.

Return

Length of data read from slave on success, negative value on error

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

int i2c_hw_free(int port)

De-Init I2C bus and release GPIO

Return

0 on success, negative value on error

Parameters

Header File

Enumerations

enum i2cport_e

I2C port list

Values:

enumerator I2C_PORT_0

I2C Port 0