To try and track it down I put this code at the top of app_main() - the rest of my code is still in the build but it never gets a chance to execute, so I think it's pointing the finger at ESP-IDF?
Code: Select all
#include "driver/i2c.h"
void app_main(void)
{
static const char *TAG = "app_main";
#define I2C_EXT_SDA_GPIO 14
#define I2C_EXT_SCL_GPIO 21
#define I2C_EXT_SPEED 5000
#define EXTERNAL_I2C_CHANNEL I2C_NUM_0
#define CELL_ADC_ADDR 0x48
const i2c_config_t conf0 = {
.mode = I2C_MODE_MASTER,
.sda_io_num = I2C_EXT_SDA_GPIO,
.scl_io_num = I2C_EXT_SCL_GPIO,
.sda_pullup_en = GPIO_PULLUP_DISABLE,
.scl_pullup_en = GPIO_PULLUP_DISABLE,
.master.clk_speed = I2C_EXT_SPEED,
.clk_flags = 0,
};
i2c_param_config(EXTERNAL_I2C_CHANNEL, &conf0);
i2c_driver_install(EXTERNAL_I2C_CHANNEL, conf0.mode, 0, 0, 0);
while (1) {
uint8_t buf[3];
buf[0] = 1;
buf[1] = 0XCC;
buf[2] = 0x5A;
esp_err_t res =
i2c_master_write_to_device(I2C_NUM_0, CELL_ADC_ADDR, buf, 3, 10);
vTaskDelay(1);
}
In other tests I noticed that the number of correct Tx seems to depend on the amount of bytes in the buffer passed to i2c_master_*()
I'm using ESP32-s3-wroom and ESP IDF v5.1.2 - I could update if it'll help but feels like it's unlikely this could have gone unnoticed and Google didn't help so thought I'd ask first...
Thanks!