#include <Wire.h>
…
Wire.begin()
…
void startDac1(){ // Set registers not requiring display info
bitSet(reg10,0); // Set bit zero for reg 10: Mute DACs
writeSabreReg(0x0A,reg10); // Mute DACs. Earliest we can mute the DACs to avoid full vol
setSabreVolume(currAttnu); // Reg 0 to Reg 7 Set volume registers with startup volume level
writeSabreReg(0x0D,0x00); // DAC in-phase
writeSabreReg(0x13,0x00); // DACB anti-phase
writeSabreReg(0x25,0x00); // Use built in filter for stage 1 and stage 2
writeSabreReg(0x0E,reg14); // Reg 14: BuffII input map, trueDiff, normal IIR and Fast rolloff
// Reg 14: except BuffII input map setting, the others will be
// redefined.
/*
The code below may provide some mitigation to the white noise during silence
#ifdef USE80MHZ
writeSabreReg(0x10,0x08); // Reg 16: Turn automute loopback -only to mitigate 352.8KHz noise
writeSabreReg(0x09,0x10); // Reg 9: Set automute time 4x less than default (value is in denom.)
#endif USE80MHZ
*/
#ifdef DUALMONO // DAC registers default to stereo. Set to MONO L/R for dual MONO
bitSet(reg17L,0); // Set for MONO left channel. Right ch variable is already set for MONO
writeSabreLeftReg(0x11,reg17L);
writeSabreRightReg(0x11,reg17R);
#endif DUALMONO
#ifdef TPAPHASE
/* The outputs on each side of each MONO board will be in opposite phase. In order to do this
the phase of the odd dacs are out of phase with the even dacs. Further, buffalo is configured
such that (In dual mono mode) the channel on the DAC which is opposite of the selected channel
carries the same analog signal but in anti-phase (odd dacs are the left channel;
even dacs are the right channel)
See
http://hifiduino.wordpress.com/sabre32/ for further explaination
*/
writeSabreLeftReg(0x0D,0x22); // MONO LEFT DACx: odd dacs=in-phase; even dacs=anti-phase
// writeSabreLeftReg(0x13,0x00); // MONO LEFT DACBx: all dacs anti-phase with respect to DACx
writeSabreRightReg(0x0D,0x11); // MONO RIGHT DACx: odd dacs=anti-phase; even dacs=in-phase
// writeSabreRightReg(0x13,0x00); // MONO RIGHT DACBx: all dacs anti-phase with respect to DACx
#endif TPAPHASE
}
….
void writeSabreReg(byte regAddr, byte regVal)
{
Wire.beginTransmission(0x48); //Hard coded to the the Sabre/Buffalo device address
Wire.write(regAddr); // Specifying the address of register
Wire.write(regVal); // Writing the value into the register
Wire.endTransmission();
#ifdef DUALMONO
Wire.beginTransmission(0x49); //Hard coded to the the other Sabre/Buffalo device address
Wire.write(regAddr); // Specifying the address of register
Wire.write(regVal); // Writing the value into the register
Wire.endTransmission();
#endif DUALMONO
}
…
// Because of register 17 sets MONO/8-channel, different values are written into different chips
void writeSabreLeftReg(byte regAddr, byte regVal)
{
Wire.beginTransmission(0x48); // Hard coded to the the Sabre/Buffalo device address for stereo
// or mono left. For stereo same as writeSabreReg()
Wire.write(regAddr); // Specifying the address of register
Wire.write(regVal); // Writing the value into the register
Wire.endTransmission();
}
#ifdef DUALMONO
void writeSabreRightReg(byte regAddr, byte regVal)
{
Wire.beginTransmission(0x49); //Hard coded to the the Sabre/Buffalo device address
Wire.write(regAddr); // Specifying the address of register
Wire.write(regVal); // Writing the value into the register
Wire.endTransmission();
}
#endif DUALMONO