From 0049e6381b142a8aea226e631bd24c882f755571 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Sat, 21 Aug 2021 23:50:09 +0300 Subject: [PATCH] Fix multiple byte writes. --- source/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/io.c b/source/io.c index d2abd45..cf06e90 100644 --- a/source/io.c +++ b/source/io.c @@ -34,11 +34,11 @@ esp_err_t ds3231_io_write(i2c_port_t port, uint8_t addr, const void *data, size_ if ((cmd = i2c_cmd_link_create())) { - for (int i = 0; i < sz; ++ i) + for (int i = 0; i < sz; ++i) { i2c_master_start(cmd); i2c_master_write_byte(cmd, DS3231_ADDR | I2C_MASTER_WRITE, true); - i2c_master_write_byte(cmd, addr, true); + i2c_master_write_byte(cmd, addr + i, true); i2c_master_write_byte(cmd, ((uint8_t*)data)[i], true); } i2c_master_stop(cmd);