RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches

Overview

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.

#include "i2c/i2c.h"
#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.
Definition i2c.c:83
I2C driver API definitions.
I2C instance. Holds the software registers and hardware pointer.
Definition i2c.h:290
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

Topics

 API Functions
 Function definitions for I2C driver.
 Data Structures
 Structs used by the driver.
 Data Types
 Enums used by the driver.
 Register Definitions
 Register bitmasks and offsets.