Skip to content

Commit

Permalink
writeReadRegisterWord. Update for Pigpio compatibility �[200~Process …
Browse files Browse the repository at this point in the history
…call. SMBus 2.0 5.5.6

S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A]
   S Addr Rd [A] [DataLow] A [DataHigh] NA P
  • Loading branch information
taartspi committed Mar 12, 2024
1 parent 9d698be commit c63e681
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,16 @@ public int readRegister(byte[] register, byte[] buffer, int offset, int length)
*/
@Override
public int writeReadRegisterWord(int register, int word) {
return this.i2CBus.execute(this, file -> {
writeRegisterWord(register, word);
return readRegisterWord(register);
});
byte reg[] = new byte[3];
reg[0] = (byte) (register & 0xff);
reg[1] = (byte) (word & 0xff);
reg[2] = (byte) ((word >> 8) & 0xff);
byte buff[] = new byte[2];

int rCode = this.readRegister(reg, buff, 0, buff.length);
word = (buff[1] << 8) | buff[0];
return word;

}

@Override
Expand Down

0 comments on commit c63e681

Please sign in to comment.