## I2C Function Documentation

### Sys_I2C_GPIOConfig

void Sys_I2C_GPIOConfig(const I2C_Type * i2c, uint32_t config, uint32_t scl, uint32_t sda)

Configure two GPIOs for the specified I2C interface.

Location: i2c.h:68

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance
in | config | GPIO pin configuration for the I2C pads
in | scl | GPIO to use as the I2C transmit pad; use an integer
in | sda | GPIO to use as the I2C receive pad; use an integer

Example Code for Sys_I2C_GPIOConfig
// Configure GPIO3 and GPIO4 as SCL and SDA, enable 1 kOhm pull-up resistors, // and disable low-pass filter for I2C interface Sys_I2C_GPIOConfig(I2C, (GPIO_LPF_DISABLE | GPIO_1K_PULL_UP), GPIO3, GPIO4);

### Sys_I2C_Config

void Sys_I2C_Config(I2C_Type * i2c, uint32_t config)

Apply I2C Master mode related configuration.

Location: i2c.h:110

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance
in | config | I2C configurations for master mode; use I2C_[CONNECT | DISCONNECT]_IN_STANDBY, I2C_TX_DMA_[ENABLE | DISABLE] I2C_RX_DMA_[ENABLE | DISABLE] I2C_TX_INT_[ENABLE | DISABLE] I2C_RX_INT_[ENABLE | DISABLE] I2C_BUS_ERROR_INT_[ENABLE | DISABLE] I2C_OVERRUN_INT_[ENABLE | DISABLE] I2C_STOP_INT_[ENABLE | DISABLE] I2C_AUTO_ACK_[ENABLE | DISABLE] I2C_MASTER_PRESCALE_*, I2C_SLAVE_PRESCALE_*, a slave address constant shifted to I2C_CTRL0_SLAVE_ADDRESS_Pos, I2C_SLAVE_[ENABLE | DISABLE]

Example Code for Sys_I2C_Config
// Apply I2C Master mode related configuration for I2C interface // Set up prescaler, auto acknowledge, interrupt, and slave enable Sys_I2C_Config(I2C, (I2C_SLAVE_PRESCALE_4 | I2C_AUTO_ACK_ENABLE | I2C_RX_INT_ENABLE | I2C_TX_INT_ENABLE | I2C_STOP_INT_ENABLE | I2C_OVERRUN_INT_ENABLE | I2C_BUS_ERROR_INT_ENABLE | I2C_SLAVE_ENABLE | (64 << I2C_CFG_SLAVE_ADDRESS_Pos)));

### Sys_I2C_StartRead

void Sys_I2C_StartRead(I2C_Type * i2c, uint32_t addr)

Send slave address on the bus with a read request.

Location: i2c.h:122

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance
in | addr | I2C address to use for write transaction

Example Code for Sys_I2C_StartRead
// Send slave address 64 on the I2C bus with a read request Sys_I2C_StartRead(I2C, 64);

### Sys_I2C_StartWrite

void Sys_I2C_StartWrite(I2C_Type * i2c, uint32_t addr)

Send slave address on the bus with a write request.

Location: i2c.h:136

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | I2C instance number
in | addr | I2C address to use for write transaction

Example Code for Sys_I2C_StartWrite
// Send slave address 64 on the I2C bus with a write request Sys_I2C_StartWrite(I2C, 64);

### Sys_I2C_ACK

void Sys_I2C_ACK(I2C_Type * i2c)

Issue a ACK on the I2C interface.

Location: i2c.h:148

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance

Example Code for Sys_I2C_ACK
// Issue a ACK on the I2C interface Sys_I2C_ACK(I2C);

### Sys_I2C_NACK

void Sys_I2C_NACK(I2C_Type * i2c)

Issue a NACK on the I2C interface.

Location: i2c.h:159

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance

Example Code for Sys_I2C_NACK
// Issue a NACK on the I2C interface Sys_I2C_NACK(I2C);

### Sys_I2C_LastData

void Sys_I2C_LastData(I2C_Type * i2c)

Indicate that the current data is the last byte.

Location: i2c.h:170

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance

Example Code for Sys_I2C_LastData
//Indicate that the current data is the last byte Sys_I2C_LastData(I2C);

### Sys_I2C_Reset

void Sys_I2C_Reset(I2C_Type * i2c)

Reset the I2C interface.

Location: i2c.h:181

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance

Example Code for Sys_I2C_Reset
// Reset the I2C interface Sys_I2C_Reset(I2C);

### Sys_I2C_NackAndStop

void Sys_I2C_NackAndStop(I2C_Type * i2c)

Issue a NACK followed by a Stop condition on I2C bus.

Location: i2c.h:192

Parameters

Direction | Name | Description
--- | --- | ---
in | i2c | Pointer to the I2C instance

Example Code for Sys_I2C_NackAndStop
// Issue a NACK followed by a Stop condition on I2C bus Sys_I2C_NackAndStop(I2C);