From e9ffe0354486b22691c7d98dd33ad0fd78c8a534 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Tue, 6 Jul 2021 12:12:16 +0800 Subject: [PATCH] i2c: the user is now allowed to call i2c_master_write even for sending a single byte --- components/driver/i2c.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/driver/i2c.c b/components/driver/i2c.c index 32bae591b5..be02266a7a 100644 --- a/components/driver/i2c.c +++ b/components/driver/i2c.c @@ -1147,6 +1147,12 @@ esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, const uint8_t *data, siz I2C_CHECK((data != NULL), I2C_ADDR_ERROR_STR, ESP_ERR_INVALID_ARG); I2C_CHECK(cmd_handle != NULL, I2C_CMD_LINK_INIT_ERR_STR, ESP_ERR_INVALID_ARG); + if (data_len == 1) { + /* If data_len if 1, i2c_master_write_byte should have been called, + * correct this here. */ + return i2c_master_write_byte(cmd_handle, *data, ack_en); + } + i2c_cmd_t cmd = { .hw_cmd = { .ack_en = ack_en,