25#define DEFAULT_I2C_MASTER_NUM          1 
   26#define DEFAULT_I2C_MASTER_SCL_IO_NUM   19 
   27#define DEFAULT_I2C_MASTER_SDA_IO_NUM   18 
   28#define DEFAULT_I2C_MASTER_DEV_ADDR     0x23 
   29#define DEFAULT_I2C_MASTER_FREQ         400*1000 
   31#define DEFAULT_I2C_SLAVE_NUM          0 
   32#define DEFAULT_I2C_SLAVE_SCL_IO_NUM   5 
   33#define DEFAULT_I2C_SLAVE_SDA_IO_NUM   4 
   34#define DEFAULT_I2C_SLAVE_DEV_ADDR     0x23 
   35#define DEFAULT_I2C_SLAVE_FREQ         400*1000 
   80    uint8_t msg[] = 
"hello";
 
   81    uint8_t recv[
sizeof(msg)] = {0};
 
xf_err_t xf_hal_i2c_set_gpio(xf_i2c_num_t i2c_num, xf_gpio_num_t scl_num, xf_gpio_num_t sda_num)
i2c 设置 gpio。
 
xf_err_t xf_hal_i2c_set_address(xf_i2c_num_t i2c_num, uint16_t address)
i2c 设置 i2c 从机地址。
 
xf_err_t xf_hal_i2c_init(xf_i2c_num_t i2c_num, xf_hal_i2c_hosts_t hosts, uint32_t speed)
i2c 初始化函数。使用 i2c 之前必须要进行初始化。
 
int xf_hal_i2c_write(xf_i2c_num_t i2c_num, const uint8_t *buffer, uint32_t size, uint32_t timeout_ms)
i2c 写入数据。
 
int xf_hal_i2c_read(xf_i2c_num_t i2c_num, uint8_t *buffer, uint32_t size, uint32_t timeout_ms)
i2c 读取数据。
 
xf_err_t xf_hal_i2c_enable(xf_i2c_num_t i2c_num)
i2c 启用函数。i2c 配置好功能后,可以调用 i2c 启用函数进行激活。
 
@ XF_HAL_I2C_HOSTS_MASTER
 
static void i2c_master_init(void)
 
#define DEFAULT_I2C_SLAVE_NUM
 
#define DEFAULT_I2C_MASTER_DEV_ADDR
 
#define DEFAULT_I2C_SLAVE_SCL_IO_NUM
 
#define DEFAULT_I2C_MASTER_FREQ
 
#define DEFAULT_I2C_MASTER_NUM
 
static void i2c_echo(void)
 
#define DEFAULT_I2C_SLAVE_FREQ
 
static void i2c_slave_init(void)
 
#define DEFAULT_I2C_MASTER_SCL_IO_NUM
 
#define DEFAULT_I2C_SLAVE_SDA_IO_NUM
 
#define DEFAULT_I2C_SLAVE_DEV_ADDR
 
#define DEFAULT_I2C_MASTER_SDA_IO_NUM
 
#define XF_LOGI(tag, format,...)