I am using ESP-IDF v5.4.0 and the driver/i2c_slave.h library for I2C communication. I need to disable the I2C slave driver's response capabilities to prevent it from sending any ACK/NACK signals. Is there a configuration flag or a recommended method to stop the I2C slave from transmitting any data or responding on the bus?
esp_err_t i2c_slave_listener_init(void) {
esp_err_t ret;
gpio_config_t io_conf = {
.intr_type = GPIO_INTR_ANYEDGE,
.mode = GPIO_MODE_INPUT,
.pin_bit_mask = (1ULL << I2C_SLAVE_SDA_IO) | (1ULL << I2C_SLAVE_SCL_IO),
.pull_up_en = GPIO_PULLUP_DISABLE,
.pull_down_en = GPIO_PULLDOWN_DISABLE,
};
gpio_config(&io_conf);
i2c_slave_config_t slave_config = {
.i2c_port = I2C_NUM_0,
.sda_io_num = I2C_SLAVE_SDA_IO,
.scl_io_num = I2C_SLAVE_SCL_IO,
.slave_addr = I2C_SLAVE_ADDR,
.addr_bit_len = I2C_ADDR_BIT_7,
.send_buf_depth = 32,
.clk_source = I2C_CLK_SRC_DEFAULT,
.intr_priority = 0,
.flags.allow_pd = 1,
.flags.force_read = 1,
#if SOC_I2C_SLAVE_SUPPORT_BROADCAST
.flags.broadcast_en = 0,
#endif
};
ret = i2c_new_slave_device(&slave_config, &i2c_slave_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "I2C slave driver install failed: %s", esp_err_to_name(ret));
return ret;
}
const i2c_slave_event_callbacks_t cbs = {
.on_recv_done = i2c_slave_rx_done_callback,
};
ret = i2c_slave_register_event_callbacks(i2c_slave_handle, &cbs, rx_buffer);
if (ret == ESP_OK) {
ESP_LOGI(TAG, "I2C slave event callbacks registered successfully.");
} else {
ESP_LOGE(TAG, "Failed to register I2C slave event callbacks: %s", esp_err_to_name(ret));
}
if (ret != ESP_OK) {
ESP_LOGE(TAG, "I2C slave register callback failed: %s", esp_err_to_name(ret));
return ret;
}
return ESP_OK;
}
How to disable the I2C slave driver's response capabilities to prevent it from sending any ACK/NACK signals?
-
- Posts: 1954
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: How to disable the I2C slave driver's response capabilities to prevent it from sending any ACK/NACK signals?
First set up and initialize the I2C driver, then
Code: Select all
gpio_set_direction(I2C_SLAVE_SDA_IO, GPIO_MODE_INPUT);
Re: How to disable the I2C slave driver's response capabilities to prevent it from sending any ACK/NACK signals?
Hi, Thanks for the reply.
Yes, this I am doing it in gpio_init() function, function is in another .c file.
"gpio_set_direction(I2C_SLAVE_SDA_IO, GPIO_MODE_INPUT);"
I am trying to sniff the packet exchange between two devices. so I have connected my ESP32 board with same SDA / SCL pins, and just want to passively listen the packets and do not want to send any ack.
but when i am running this command, I just checked with logic analyser, it seems ESP32 is also responding something, because i see some difference in signals.
my doubt is this implementation I have made for I2C, I think it is sending some Ack/Nack signals, which i dont want my ESP32 to send, I just want him to read the conversation only.
Yes, this I am doing it in gpio_init() function, function is in another .c file.
"gpio_set_direction(I2C_SLAVE_SDA_IO, GPIO_MODE_INPUT);"
I am trying to sniff the packet exchange between two devices. so I have connected my ESP32 board with same SDA / SCL pins, and just want to passively listen the packets and do not want to send any ack.
but when i am running this command, I just checked with logic analyser, it seems ESP32 is also responding something, because i see some difference in signals.
my doubt is this implementation I have made for I2C, I think it is sending some Ack/Nack signals, which i dont want my ESP32 to send, I just want him to read the conversation only.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 56 guests