Skip to content

Commit

Permalink
update ic2 call names
Browse files Browse the repository at this point in the history
  • Loading branch information
gemu2015 committed Sep 9, 2024
1 parent a6deb1d commit f944b9e
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 116 deletions.
12 changes: 6 additions & 6 deletions lib/libesp32/berry/generate/be_const_bytes.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* extern binary arrays */
extern const binstance_arg3 be_const_instance_;
extern const binstance_arg3 be_const_instance_0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010002FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000020003000F0011FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000050007000A000B000D000E0017FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00070008000F400B400CFFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200080009FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010007FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_00030004FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000010007FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_000000050007000A000B000C000D000E000F0017FFF8FFF9FFFAFFFBFFFCFFFD;
extern const binstance_arg3 be_const_instance_0000000100070008000F4001400AFFF8FFF9FFFAFFFBFFFCFFFD;
12 changes: 6 additions & 6 deletions lib/libesp32/berry/generate/be_const_bytes_def.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* binary arrays */
be_define_const_bytes_empty();
be_define_const_bytes(0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030005000A000F00110012FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x05, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010002000300040005FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010002FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000020003000F0011FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x0F, 0x00, 0x11, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000050007000A000B000D000E0017FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x17, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00070008000F400B400CFFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0F, 0x40, 0x0B, 0x40, 0x0C, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200080009FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0x00, 0x09, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010007FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(FFF8FFF9FFFAFFFBFFFCFFFD, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00000001000200030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(00030004FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x03, 0x00, 0x04, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020003000400050006000700080009000A000F001100120013FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0F, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100020008FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x08, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000010007FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(000000050007000A000B000C000D000E000F0017FFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x05, 0x00, 0x07, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x17, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
be_define_const_bytes(0000000100070008000F4001400AFFF8FFF9FFFAFFFBFFFCFFFD, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0F, 0x40, 0x01, 0x40, 0x0A, 0xFF, 0xF8, 0xFF, 0xF9, 0xFF, 0xFA, 0xFF, 0xFB, 0xFF, 0xFC, 0xFF, 0xFD);
8 changes: 4 additions & 4 deletions tasmota/Plugins/CCS811.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ MODULE_PART void CCS811_read(uint8_t reg, uint8_t *buf, uint8_t num) {

uint8_t read_now = min((uint8_t)32, (uint8_t)(num - pos));
beginTransmission(ccs.i2c_addr);
write(reg + pos);
I2cWrite(reg + pos);
endTransmission(false);
requestFrom(ccs.i2c_addr, read_now);

for (int i=0; i<read_now; i++) {
buf[pos] = read();
buf[pos] = I2cRead();
pos++;
}
}
Expand All @@ -342,7 +342,7 @@ MODULE_PART void CCS811_read(uint8_t reg, uint8_t *buf, uint8_t num) {
MODULE_PART void CCS811_write(uint8_t reg, uint8_t *buf, uint8_t num) {
SETREGS
beginTransmission(ccs.i2c_addr);
write(reg);
writen(buf, num);
I2cWrite(reg);
I2cWriten(buf, num);
endTransmission(false);
}
48 changes: 24 additions & 24 deletions tasmota/Plugins/VL53L0X_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,30 +297,30 @@ bool VL53L0X_init(bool io_2v8) {
void VL53L0X_writeReg(uint8_t reg, uint8_t value) {
SETREGS
beginTransmission(address);
write(reg);
write(value);
I2cWrite(reg);
I2cWrite(value);
last_status = endTransmission(true);
}

// Write a 16-bit register
void VL53L0X_writeReg16Bit(uint8_t reg, uint16_t value) {
SETREGS
beginTransmission(address);
write(reg);
write((value >> 8) & 0xFF); // value high byte
write(value & 0xFF); // value low byte
I2cWrite(reg);
I2cWrite((value >> 8) & 0xFF); // value high byte
I2cWrite(value & 0xFF); // value low byte
last_status = endTransmission(true);
}

// Write a 32-bit register
void VL53L0X_writeReg32Bit(uint8_t reg, uint32_t value) {
SETREGS
beginTransmission(address);
write(reg);
write((value >> 24) & 0xFF); // value highest byte
write((value >> 16) & 0xFF);
write((value >> 8) & 0xFF);
write(value & 0xFF); // value lowest byte
I2cWrite(reg);
I2cWrite((value >> 24) & 0xFF); // value highest byte
I2cWrite((value >> 16) & 0xFF);
I2cWrite((value >> 8) & 0xFF);
I2cWrite(value & 0xFF); // value lowest byte
last_status = endTransmission(true);
}

Expand All @@ -330,11 +330,11 @@ uint8_t VL53L0X_readReg(uint8_t reg) {
uint8_t value;

beginTransmission(address);
write(reg);
I2cWrite(reg);
last_status = endTransmission(true);

requestFrom(address, (uint8_t)1);
value = read();
value = I2cRead();

return value;
}
Expand All @@ -345,12 +345,12 @@ uint16_t VL53L0X_readReg16Bit(uint8_t reg) {
uint16_t value;

beginTransmission(address);
write(reg);
I2cWrite(reg);
last_status = endTransmission(true);

requestFrom(address, (uint8_t)2);
value = (uint16_t)read() << 8; // value high byte
value |= read(); // value low byte
value = (uint16_t)I2cRead() << 8; // value high byte
value |= I2cRead(); // value low byte

return value;
}
Expand All @@ -361,14 +361,14 @@ uint32_t VL53L0X_readReg32Bit(uint8_t reg) {
uint32_t value;

beginTransmission(address);
write(reg);
I2cWrite(reg);
last_status = endTransmission(true);

requestFrom(address, (uint8_t)4);
value = (uint32_t)read() << 24; // value highest byte
value |= (uint32_t)read() << 16;
value |= (uint16_t)read() << 8;
value |= read(); // value lowest byte
value = (uint32_t)I2cRead() << 24; // value highest byte
value |= (uint32_t)I2cRead() << 16;
value |= (uint16_t)I2cRead() << 8;
value |= I2cRead(); // value lowest byte

return value;
}
Expand All @@ -378,10 +378,10 @@ uint32_t VL53L0X_readReg32Bit(uint8_t reg) {
void VL53L0X_writeMulti(uint8_t reg, uint8_t const* src, uint8_t count) {
SETREGS
beginTransmission(address);
write(reg);
I2cWrite(reg);

while (count-- > 0) {
write(*(src++));
I2cWrite(*(src++));
}

last_status = endTransmission(true);
Expand All @@ -392,13 +392,13 @@ void VL53L0X_writeMulti(uint8_t reg, uint8_t const* src, uint8_t count) {
void VL53L0X_readMulti(uint8_t reg, uint8_t* dst, uint8_t count) {
SETREGS
beginTransmission(address);
write(reg);
I2cWrite(reg);
last_status = endTransmission(true);

requestFrom(address, count);

while (count-- > 0) {
*(dst++) = read();
*(dst++) = I2cRead();
}
}

Expand Down
4 changes: 3 additions & 1 deletion tasmota/Plugins/module_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ typedef struct {

#define beginTransmission(ADDR) jbeginTransmission(mem->xWire, ADDR)
#define I2cWrite(CMD) jwrite(mem->xWire, CMD)
#define I2cWriten(BUF,LEN) jwriten(mem->xWire,BUF,LEN)

#define endTransmission(BUS) jendTransmission(mem->xWire, BUS)
#define requestFrom(ADDR,NUM) jrequestFrom(mem->xWire, ADDR, NUM)
#define I2cRead() jread(mem->xWire)
Expand Down Expand Up @@ -896,7 +898,7 @@ typedef struct {

#define I2C_beginTransmission beginTransmission
#define I2C_endTransmission endTransmission
#define I2C_write write
#define I2C_write I2cWrite
#define I2C_SETWIRE SETWIRE

#define CharToFloat jCharToFloat
Expand Down
32 changes: 16 additions & 16 deletions tasmota/Plugins/xsns_08_htu21.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ uint8_t HtuReadDeviceId() {
uint8_t checksum = 0;

beginTransmission(HTU21_ADDR);
write(HTU21_SERIAL2_READ1);
write(HTU21_SERIAL2_READ2);
I2cWrite(HTU21_SERIAL2_READ1);
I2cWrite(HTU21_SERIAL2_READ2);
endTransmission(0);

requestFrom(HTU21_ADDR, 3);
deviceID = read() << 8;
deviceID |= read();
checksum = read();
deviceID = I2cRead() << 8;
deviceID |= I2cRead();
checksum = I2cRead();
if (HtuCheckCrc8(deviceID) == checksum) {
deviceID = deviceID >> 8;
} else {
Expand All @@ -149,7 +149,7 @@ void HtuSetResolution(uint8_t resolution) {
void HtuReset() {
SETREGS
beginTransmission(HTU21_ADDR);
write(HTU21_RESET);
I2cWrite(HTU21_RESET);
endTransmission(0);
delay(15); // Reset takes 15ms
}
Expand Down Expand Up @@ -189,17 +189,17 @@ bool HTU_Read() {
}

beginTransmission(HTU21_ADDR);
write(HTU21_READTEMP);
I2cWrite(HTU21_READTEMP);
if (endTransmission(0) != 0) {
return false;
} // In case of error
delay(Htu.jdelay_temp); // Sensor time at max resolution

requestFrom(HTU21_ADDR, 3);
if (3 == available()) {
sensorval = read() << 8; // MSB
sensorval |= read(); // LSB
checksum = read();
if (3 == I2cAvailable()) {
sensorval = I2cRead() << 8; // MSB
sensorval |= I2cRead(); // LSB
checksum = I2cRead();
}
if (HtuCheckCrc8(sensorval) != checksum) {
return false;
Expand All @@ -209,17 +209,17 @@ bool HTU_Read() {
Htu.temperature = ConvertTemp(jfscale(sensorval, 0.002681, 46.85));

beginTransmission(HTU21_ADDR);
write(HTU21_READHUM);
I2cWrite(HTU21_READHUM);
if (endTransmission(0) != 0) {
return false;
} // In case of error
delay(Htu.jdelay_humidity); // Sensor time at max resolution

requestFrom(HTU21_ADDR, 3);
if (3 <= available()) {
sensorval = read() << 8; // MSB
sensorval |= read(); // LSB
checksum = read();
if (3 <= I2cAvailable()) {
sensorval = I2cRead() << 8; // MSB
sensorval |= I2cRead(); // LSB
checksum = I2cRead();
}
if (HtuCheckCrc8(sensorval) != checksum) {
return false;
Expand Down
12 changes: 6 additions & 6 deletions tasmota/Plugins/xsns_09_bmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,18 @@ uint32_t BME_Read(uint8_t reg, int8_t num) {
SETREGS

beginTransmission(i2c_addr);
write(reg);
I2cWrite(reg);
endTransmission(false);
requestFrom(i2c_addr, abs(num));
uint32_t result = 0;
if (num > 0) {
for (uint16_t cnt = 0; cnt < num; cnt++) {
result <<= 8;
result |= read();
result |= I2cRead();
}
} else {
result = read();
result |= read() << 8;
result = I2cRead();
result |= I2cRead() << 8;
}
return result;
}
Expand All @@ -261,8 +261,8 @@ uint32_t BME_Write(uint8_t reg, int8_t val) {
SETREGS

beginTransmission(i2c_addr);
write(reg);
write(val);
I2cWrite(reg);
I2cWrite(val);
return endTransmission(true);
}

Expand Down
14 changes: 7 additions & 7 deletions tasmota/Plugins/xsns_14_sht3x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ bool Sht3xRead(float &t, float &h, uint8_t sht3x_address) {

beginTransmission(sht3x_address);
if (SHTC3_ADDR == sht3x_address) {
write(0x35); // Wake from
write(0x17); // sleep
I2cWrite(0x35); // Wake from
I2cWrite(0x17); // sleep
endTransmission(true);
beginTransmission(sht3x_address);
write(0x78); // Disable clock stretching ( I don't think that wire library support clock stretching )
write(0x66); // High resolution
I2cWrite(0x78); // Disable clock stretching ( I don't think that wire library support clock stretching )
I2cWrite(0x66); // High resolution
} else {
write(0x2C); // Enable clock stretching
write(0x06); // High repeatability
I2cWrite(0x2C); // Enable clock stretching
I2cWrite(0x06); // High repeatability
}
if (endTransmission(true) != 0) { // Stop I2C transmission
AddLog(LOG_LEVEL_INFO, PSTR("i2c error"));
Expand All @@ -96,7 +96,7 @@ bool Sht3xRead(float &t, float &h, uint8_t sht3x_address) {
delay(30); // Timing verified with logic analyzer (10 is to short)
requestFrom(sht3x_address, 6); // Request 6 bytes of data
for (uint32_t i = 0; i < 6; i++) {
data[i] = read(); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
data[i] = I2cRead(); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc
};

t = fdiv(tofloat(((data[0] << 8) | data[1]) * 175), FLTC(0));
Expand Down
4 changes: 2 additions & 2 deletions tasmota/Plugins/xsns_21_sgp30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ bool readWordFromCommand(uint8_t command[], uint8_t commandLength, uint16_t dela
SETREGS
beginTransmission(SGP30_ADDRESS);
for (uint8_t i = 0; i < commandLength; i++) {
write(command[i]);
I2cWrite(command[i]);
}
endTransmission(false);

Expand All @@ -211,7 +211,7 @@ bool readWordFromCommand(uint8_t command[], uint8_t commandLength, uint16_t dela
}
uint8_t replybuffer[replylen];
for (uint8_t i = 0; i < replylen; i++) {
replybuffer[i] = read();
replybuffer[i] = I2cRead();
}

for (uint8_t i = 0; i < readlen; i++) {
Expand Down
Loading

0 comments on commit f944b9e

Please sign in to comment.