From 162594348665782a4eb4ad55239a165d823121b9 Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Fri, 17 Nov 2023 11:02:16 +0800 Subject: [PATCH] change(i2c): Add check for scl frequency for master_bus_add_device Closes https://github.com/espressif/esp-idf/issues/12598 --- components/driver/i2c/i2c_master.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/driver/i2c/i2c_master.c b/components/driver/i2c/i2c_master.c index 2fa24a020a..398cefe7e8 100644 --- a/components/driver/i2c/i2c_master.c +++ b/components/driver/i2c/i2c_master.c @@ -871,6 +871,8 @@ esp_err_t i2c_master_bus_add_device(i2c_master_bus_handle_t bus_handle, const i2 { esp_err_t ret = ESP_OK; ESP_RETURN_ON_FALSE((bus_handle != NULL), ESP_ERR_INVALID_ARG, TAG, "this bus is not initialized, please call `i2c_new_master_bus`"); + ESP_RETURN_ON_FALSE(dev_config, ESP_ERR_INVALID_ARG, TAG, "invalid argument"); + ESP_RETURN_ON_FALSE(dev_config->scl_speed_hz > 0, ESP_ERR_INVALID_ARG, TAG, "invalid scl frequency"); if(bus_handle->base->bus_mode != I2C_BUS_MODE_MASTER) { ESP_LOGE(TAG, "This is not master bus!"); return ESP_ERR_INVALID_ARG;