如标题描述,可以通过i2c读到数据,但是i2c_master_cmd_begin()函数会返回ESP_ERR_TIMEOUT问题,其中等待时间不管改成多大都没有用。
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (slave_device_address<<1)|I2C_MASTER_WRITE, ACK_CHECK_EN );
i2c_master_write_byte(cmd, read_address, ACK_CHECK_EN);
i2c_master_start(cmd);
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (slave_device_address<<1)|I2C_MASTER_READ, ACK_CHECK_EN);
i2c_master_read(cmd, data_rd, data_length, I2C_MASTER_ACK);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 1000/portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
return ret;