Skip to content

Commit 9299078

Browse files
rblakesleygfwilliams
authored andcommitted
Fixed bug where I2C.readReg() was locking up the I2C bus by not sending STOP signal after reading
1 parent 0940640 commit 9299078

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/jswrap_spi_i2c.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,7 @@ I2C.readReg = function(address, reg, quantity) {
767767
JsVar *jswrap_i2c_readReg(JsVar *parent, int address, int reg, int nBytes) {
768768
if (!jsvIsObject(parent)) return 0;
769769
IOEventFlags device = jsiGetDeviceFromClass(parent);
770-
bool sendStop = false;
771770
unsigned char i2cReg = (unsigned char)reg;
772-
_jswrap_i2c_writeTo(parent, device, address, sendStop, 1, &i2cReg);
773-
return _jswrap_i2c_readFrom(parent, device, address, sendStop, nBytes);
771+
_jswrap_i2c_writeTo(parent, device, address, false /* Don't send STOP */, 1, &i2cReg);
772+
return _jswrap_i2c_readFrom(parent, device, address, true /* Send STOP after reading */, nBytes);
774773
}

0 commit comments

Comments
 (0)