#define I2C_STA323 0x1A
#include <Wire.h>
void setup(){
Serial.begin(9600);
pinMode(2,OUTPUT); // RESET
digitalWrite(2,HIGH);delay(10); // RESET
init_sta();
Serial.println(wireRead(I2C_STA323,0x2D),BIN);
//Status indicator register 0x2D
}
void loop(){
}
void init_sta(){
wireWrite(I2C_STA323,0x00,0b00101011);
//[2:0][MCS2 MCS1 MCS0]=011
//[4:3][IR1 IR0]=01(96K)
//[5][TWRB]=1(TEMP_ERR АВТОВКЛЮЧ.ПОСЛЕ ПЕРЕГРЕВА-АКТИВНА)
//[6][TWAB]=0(ОГРАНИЧ ВЫХ МОЩНОСТИ ПРИ ПЕРЕГРЕВЕ-АКТИВНА)0X37 - УКАЗАТЬ УРОВ. ОГР. МОЩН.
//[7][FDRB]=0(ЗАЩИТА.ОТКЛ.ПИТАНИЯ ПРИ НЕИСПРАВНОСТИ-АКТИВНА)
wireWrite(I2C_STA323,0x00,0b10100000);
//[3:0][SAI]=0000(I2S 64*fs 16 to 24 bit)
//[4][SAIFB]=0(MSB) MSB/LSB-first
//[5][DSCKE]=1(АКТИВНА ТАКТОВАЯ ЗАДЕРЖКА)
//[7:6][C1IM C2IM]=10(СОПАСТОНОВЛЕНИЕ КАНАЛОВ)DEF
wireWrite(I2C_STA323,0x02,0b01000010);
//[1:0][OM0 OM1]=10(Selects configuration of DDX® output)DEF
//[6:2][CSZ]=10000(DDX® compensating pulse)DEF
//[7][RESERVED]
wireWrite(I2C_STA323,0x03,0b01000000);
//[0][HPB]=0(High-pass filter bypass) DEF
//[1][DEMP]=0(De-emphasis)OFF
//[2][DSPB]=0(DSP bypass)АКТИВНА-РЕГ.ТЕМБРА АКТИВНЫ
//[3][PSL]=0(Postscale link)DEF
//[4][BQL]=0(Biquad coefficient link)DEF
//[5][DCR]=0(Dynamic range compression)DEF
//[6][ZDE]=1(Zero-detect mute enable)DEF
//[7][MME]=0 DEF
wireWrite(I2C_STA323,0x04,0b11000000);//def
//[0][MPCV]=0(Max power correction variable)DEF
//[1][MPC]=1(Max power correction)DEF
//[2][RES]=0 DEF
//[3][AME]=0(AM mode enable)DEF
//[4][PWMS]=0(PWM speed mode)DEF
//[5][RES]=0 DEF
//[6][ZCE]=1(Zero-crossing volume enable)DEF
//[7][SVE]=1(Soft volume update enable)DEF
wireWrite(I2C_STA323,0x05,0b01011100);
//[1:0][OCFG]=00(Output configuration selection)DEF
//[2][IDE]=1(Invalid input detect mute enable)DEF
//[3][BCLE]=1(Binary output mode clock loss detection)DEF
//[4][LDTE]=1(LRCK double trigger protection)DEF
//[5][ECLE]=0(Auto EAPD on clock loss)DEF
//[6][PWDN]=1(IC power down)DEF
//[7][EAPD]=1(ВНЕШНЕЕ ПИТАНИЕ УСИЛИТЕЛЯ)АКТИВНО
wireWrite(I2C_STA323,0x06,0b00000001);// DEF
//Master mute register
wireWrite(I2C_STA323,0x07,0);// 0 dB
//Master volume register BYTE 0...0xFE = 0 dB...-127 | 0xFF = MUTE
wireWrite(I2C_STA323,0x08,100);
//Channel 1 volume BYTE 0...0xEC = +48...-80 dB 0xFF = MUTE
wireWrite(I2C_STA323,0x09,100);
//Channel 2 volume BYTE 0...0xEC = +48...-80 dB 0xFF = MUTE
wireWrite(I2C_STA323,0x0A,255);
//Channel 3 MUTE
wireWrite(I2C_STA323,0x0B,0b00000001);//DEF
//[7][AMPS]=0(automode auto pre scale)//DEF
//[6][RESERVED]
//[5:4][AMGC]=00(Auto mode gain compression/limiters)DEF
//[3:2][AMV]=00(Automode volume)DEF
//[1:0][AMEQ]=01( Automode EQ)Preset EQ – PEQ bits
wireWrite(I2C_STA323,0x0C,0b00000000);
//[0][amame]=0 DEF
//[3:1][AMAM]=000(AM interference frequency switching)DEF
//[7:4][XO]=0000(Кроссовер для управления басами)byte 0000...0001...1111 = DEF...80Hz...360Hz
wireWrite(I2C_STA323,0x0D,0b00000000);
//[4:0][PEQ]=00000(Preset EQ selection)
//[7:5][RESERVED]
wireWrite(I2C_STA323,0x0E,0b00000000);
wireWrite(I2C_STA323,0x0F,0b01000000);
wireWrite(I2C_STA323,0x10,0b10000000);
wireWrite(I2C_STA323,0x11,0);// тембр ВЧ НЧ
wireWrite(I2C_STA323,0x12,0b01101010);
//(Limiter 1 attack/release rate)DEF
wireWrite(I2C_STA323,0x13,0b01101001);
//(Limiter 1 attack/release threshold )DEF
wireWrite(I2C_STA323,0x14,0b01101010);
//(Limiter 2 attack/release rate)DEF
wireWrite(I2C_STA323,0x15,0b01101001);
//(Limiter 2 attack/release threshold)DEF
wireWrite(I2C_STA323,0x16,0);
//(Coefficient address register)DEF
wireWrite(I2C_STA323,0x17,0);
wireWrite(I2C_STA323,0x18,0);
wireWrite(I2C_STA323,0x19,0);
wireWrite(I2C_STA323,0x1A,0);
wireWrite(I2C_STA323,0x1B,0);
wireWrite(I2C_STA323,0x1C,0);
//(Coefficient b2 data register bits)DEF
wireWrite(I2C_STA323,0x1D,0);
wireWrite(I2C_STA323,0x1E,0);
wireWrite(I2C_STA323,0x1F,0);
//(Coefficient a1 data register bits)DEF
wireWrite(I2C_STA323,0x20,0);
wireWrite(I2C_STA323,0x21,0);
wireWrite(I2C_STA323,0x22,0);
//(Coefficient a2 data register bits)DEF
wireWrite(I2C_STA323,0x23,0);
wireWrite(I2C_STA323,0x24,0);
wireWrite(I2C_STA323,0x25,0);
//(Coefficient b0 data register bits)DEF
wireWrite(I2C_STA323,0x26,0b0000);
wireWrite(I2C_STA323,0x27,0b00101101);//DEF
wireWrite(I2C_STA323,0x28,0b11000000);//DEF
//Variable max power correction
wireWrite(I2C_STA323,0x2B,0b00000000);//DEF
wireWrite(I2C_STA323,0x2C,0b00001100);//DEF
//Fault detect recovery
}
byte wireRead(byte addr, byte reg){ // I2C
Wire.beginTransmission(addr);
Wire.write (reg);
Wire.endTransmission();
Wire.requestFrom(addr,1);
while(Wire.available()<1);
byte value = Wire.read();
return value;
}
void wireWrite(byte addr, byte reg, byte data){
Wire.beginTransmission(addr);
Wire.write (reg);
Wire.write (data);
Wire.endTransmission();
}