关于ESP32做主机写从机时的I2C问题
Posted: Wed Sep 13, 2023 12:52 pm
idf版本:V5.0
开发板:esp-32
问题描述:
在使用ESP32做主机写从机时,当从机地址是正确的时候能够正常写入,但是当从机地址不对时函数还是能够返回ESP_OK,我看函数描述这时不应该返回ESP_FAIL吗?
例如下面函数将SHT30_SENSOR_ADDR改成0x45还是能返回ESP_OK
开发板:esp-32
问题描述:
在使用ESP32做主机写从机时,当从机地址是正确的时候能够正常写入,但是当从机地址不对时
Code: Select all
i2c_master_cmd_begin()
例如下面函数将SHT30_SENSOR_ADDR改成0x45还是能返回ESP_OK
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (SHT30_SENSOR_ADDR << 1) | WRITE_BIT, ACK_EN); // Write Address 0x44
i2c_master_write_byte(cmd, MSB, ACK_EN);
i2c_master_write_byte(cmd, LSB, ACK_EN);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
return ret;