Code: Select all
int i2c_master_port = i2c_num;
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = gpio_sda;
conf.sda_pullup_en = 0;
conf.scl_io_num = gpio_scl;
conf.scl_pullup_en = 0;
ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &conf));
ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, conf.mode,
I2C_RX_BUF_DISABLE, I2C_TX_BUF_DISABLE, 0));
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, periph_address << 1 | WRITE_BIT, ACK_CHECK_EN);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);