My app is occasionally experiencing GMEs. The backtrace suggests the problem is in my use of the I2C system. Is there a way to tell whether the call to i2c_cmd_link_create() is successful? I didn't see anything in the docs about this.
Thanks...
Code: Select all
m_i2c_cmd = i2c_cmd_link_create();
//ESP_LOGI(TAG, "i2cReadReg(): m_i2c_cmd is %x.", (unsigned) m_i2c_cmd);
rc = (i2c_master_start(m_i2c_cmd));
rc |= (i2c_master_write_byte(m_i2c_cmd, addrWrite, true));
rc |= (i2c_master_write_byte(m_i2c_cmd, regAddr, true));
rc |= (i2c_master_start(m_i2c_cmd));
rc |= (i2c_master_write_byte(m_i2c_cmd, addrRead, true));
rc |= (i2c_master_read(m_i2c_cmd, (uint8_t *) data, len, I2C_MASTER_LAST_NACK));
rc |= (i2c_master_stop(m_i2c_cmd));
rc |= (i2c_master_cmd_begin(I2C_PORT_NBR, m_i2c_cmd, I2C_WAITTIME_TICKS));
if (rc == ESP_OK)
{
//ESP_LOGI(TAG, "readReg(): device address 0x%02x, register 0x%02x data read as 0x%x.", devAddr, regAddr, *data);
}
else
{
ESP_LOGE(TAG, "readReg(): error \"%s\" on device 0x%x, register 0x%x.",
esp_err_to_name(rc),
devAddr,
regAddr);
}
i2c_cmd_link_delete(m_i2c_cmd);