Code: Select all
i2c_master_bus_config_t master_cfg={
.i2c_port = I2C_NUM_0,
.scl_io_num = MASTER_I2C_SCL,
.sda_io_num = MASTER_I2C_SDA,
.glitch_ignore_cnt = 0,
.clk_source = I2C_CLK_SRC_DEFAULT
};
i2c_master_bus_handle_t bus_handle;
ESP_ERROR_CHECK(i2c_new_master_bus(&master_cfg,&bus_handle));
//ESP_ERROR_CHECK(i2c_master_probe(bus_handle, 0x21, -1));
ESP_LOGD(TAG,"I2C master probe");
//config device slave
i2c_device_config_t device_cfg={
.device_address = 0x21,
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
.scl_speed_hz = MASTER_I2C_CLOCK
};
i2c_master_dev_handle_t dev_handle;
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle,&device_cfg,&dev_handle));
Code: Select all
ESP_ERROR_CHECK(i2c_master_transmit_receive(dev_handle, PID, sizeof(PID), sizeof(data), 1, -1));
the esp32 reboot again and again......
the PID and data are uint8_t variables
why?
why the master transmite recibe is not working if the master probe detect the slave?
Regards
Gastón