Fix to I2C read so last byte is with a NACK
@@ -200,8 +200,13 @@ HRESULT Library_win_dev_i2c_native_Windows_Devices_I2c_I2cDevice::NativeTransmit
{
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (slaveAddress << 1) | I2C_MASTER_READ, 1);
- i2cStatus = i2c_master_read(cmd, &readData[0], readSize, I2C_MASTER_ACK );
- if (i2cStatus != ESP_OK) ESP_LOGE( TAG, "i2c_master_read error:%d", i2cStatus );
+ if (readSize > 1)
+ {
+ // Additional read bytes with ACK
+ i2c_master_read(cmd, &readData[0], readSize - 1, I2C_MASTER_ACK);
+ }
+ // Last read byte with NACK
+ i2c_master_read_byte(cmd, &readData[readSize - 1], I2C_MASTER_NACK);
}
i2c_master_stop(cmd);
