Skip to content

Commit

Permalink
[Dac63004] Fix buffer order in I2C commands (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Oct 6, 2023
1 parent 7895616 commit 302d9df
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions devices/Dac63004/Dac63004.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public void ConfigureChannelVoutGain(
Register registerAddress = DacVoutConfigFromChannel(channel);
var currentConfig = ReadFromRegister(registerAddress, 2);

currentConfig[1] &= (byte)gain;
// MSB 1st
currentConfig[0] &= (byte)gain;

WriteToRegister(registerAddress, currentConfig);
}
Expand Down Expand Up @@ -173,9 +174,9 @@ public void SetChannelDataValue(
// Data are in straight-binary format. MSB left-aligned.
var data = value << 4;

// split and fill buffer
buffer[1] = (byte)(data >> 8);
buffer[0] = (byte)(data & 0xFF);
// split and fill buffer (MSB 1st)
buffer[0] = (byte)(data >> 8);
buffer[1] = (byte)data;

WriteToRegister(registerAddress, buffer);
}
Expand Down

0 comments on commit 302d9df

Please sign in to comment.