Inter-Integrated Circuit (I2C) driver.
This module provides functions to configure and control I2C input/output and interrupt behavior.
Usage & Initialization
This is an example show how to instantiate I2C Driver with i2c_instance_t.
#define I2C_SLAVE_ADDR 0x50>>1
#define I2C_FREQ 100000
#define I2C_CTRL_HZ SYSTEM_CLINT_HZ
#define I2C_CTRL (i2c_hwreg_t *)SYSTEM_I2C_0_IO_CTRL
.hwreg = I2C_CTRL,
.slaveAddress = I2C_SLAVE_ADDR,
.samplingClockDivider = 3,
.timeout = I2C_CTRL_HZ/1000,
.tsuDat = I2C_CTRL_HZ/(I2C_FREQ*5),
.tLow = I2C_CTRL_HZ/(I2C_FREQ*2),
.tHigh = I2C_CTRL_HZ/(I2C_FREQ*2),
.tBuf = I2C_CTRL_HZ/(I2C_FREQ),
},
};
void i2c_applyConfig(i2c_instance_t *inst)
Apply the software configuration to the hardware.
I2C driver API definitions.
I2C instance. Holds the software registers and hardware pointer.
- See also
- Example I2C Master Demo - Learn how to use the driver in Master mode
-
Example I2C Slave Demo - Learn how to use the driver in Slave mode
-
Example I2C EEPROM Demo - Learn how to use the driver with an EEPROM