From b86fb30b1d282b2f772f1e20df56ec49223af716 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Wed, 14 Dec 2016 23:31:28 +0200 Subject: [PATCH] cleanup read commands --- cores/esp32/esp32-hal-i2c.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index a6cd5b58..a501f40e 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -269,15 +269,10 @@ i2c_err_t i2cRead(i2c_t * i2c, uint16_t address, bool addr_10bit, uint8_t * data if(willRead){ i2cSetCmd(i2c, cmdIdx++, I2C_CMD_READ, willRead, false, false, false); - if((len - willRead) > 1) { - i2cSetCmd(i2c, cmdIdx++, I2C_CMD_END, 0, false, false, false); - } else { - willRead++; - i2cSetCmd(i2c, cmdIdx++, I2C_CMD_READ, 1, true, false, false); - if(sendStop) { - i2cSetCmd(i2c, cmdIdx++, I2C_CMD_STOP, 0, false, false, false); - } - } + } + + if((len - willRead) > 1) { + i2cSetCmd(i2c, cmdIdx++, I2C_CMD_END, 0, false, false, false); } else { willRead++; i2cSetCmd(i2c, cmdIdx++, I2C_CMD_READ, 1, true, false, false);