Skip to content

Commit

Permalink
[wpilibj] Fix ADIS16470 Gyro (#7434)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse authored Nov 26, 2024
1 parent b7eb9fb commit fe28fa1
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ public boolean isConnected() {
return m_connected;
}

private static int toUShort(int upper, int lower) {
return ((upper & 0xFF) << 8) + (lower & 0xFF);
}

private static int toShort(int upper, int lower) {
return (short) (((upper & 0xFF) << 8) + (lower & 0xFF));
}
Expand Down Expand Up @@ -609,7 +613,7 @@ private int readRegister(int reg) {
m_spi.write(buf, 2);
m_spi.read(false, buf, 2);

return (buf[0] << 8) & buf[1];
return toUShort(buf[0], buf[1]);
}

private void writeRegister(int reg, int val) {
Expand Down

0 comments on commit fe28fa1

Please sign in to comment.