Skip to content

Commit f08743e

Browse files
schaeferpmespressif-bot
authored andcommitted
Added const for pointer in master_write method, so that a const array can be passed to this fcn.
Signed-off-by: wubowen <[email protected]> Merges espressif/esp-idf#5307 explicitly convert a const ptr to non-const because we actually don't modify it.
1 parent dafe5df commit f08743e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

components/driver/i2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle)
899899
return i2c_cmd_link_append(cmd_handle, &cmd);
900900
}
901901

902-
esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, uint8_t *data, size_t data_len, bool ack_en)
902+
esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, const uint8_t *data, size_t data_len, bool ack_en)
903903
{
904904
I2C_CHECK((data != NULL), I2C_ADDR_ERROR_STR, ESP_ERR_INVALID_ARG);
905905
I2C_CHECK(cmd_handle != NULL, I2C_CMD_LINK_INIT_ERR_STR, ESP_ERR_INVALID_ARG);
@@ -916,7 +916,7 @@ esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, uint8_t *data, size_t da
916916
cmd.hw_cmd.ack_val = 0;
917917
cmd.hw_cmd.op_code = I2C_CMD_WRITE;
918918
cmd.hw_cmd.byte_num = len_tmp;
919-
cmd.data = data + data_offset;
919+
cmd.data = (uint8_t*) data + data_offset;
920920
ret = i2c_cmd_link_append(cmd_handle, &cmd);
921921
data_offset += len_tmp;
922922
if (ret != ESP_OK) {

components/driver/include/driver/i2c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ esp_err_t i2c_master_write_byte(i2c_cmd_handle_t cmd_handle, uint8_t data, bool
225225
* - ESP_OK Success
226226
* - ESP_ERR_INVALID_ARG Parameter error
227227
*/
228-
esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, uint8_t *data, size_t data_len, bool ack_en);
228+
esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, const uint8_t *data, size_t data_len, bool ack_en);
229229

230230
/**
231231
* @brief Queue command for I2C master to read one byte from I2C bus

0 commit comments

Comments
 (0)