void SGTL5000_init(void){
write(CHIP_ANA_POWER_ADD, 0x0622); // VDDD is externally driven with 1.8V+
// LINEREG_D_POWERUP=1
write(CHIP_LINREG_CTRL_ADD, 0x006C); // VDDA & VDDIO both over 3.1V
write(CHIP_REF_CTRL_ADD, 0x01FE); // VAG=1.575, normal ramp, -50% bias current
//---------------- Route LINEIN\ADC\I2S_OUT---------------------
// write(CHIP_ANA_CTRL_ADD, 0x0116); // enable zero cross detectors, LINEIN input
write (CHIP_ANA_CTRL_ADD, CHIP_ANA_CTRL_ADD | (1<<2));
write(CHIP_SSS_CTRL_ADD, 0x0000); // ADC to I2S_OUT, DAP_SELECT=0
write(CHIP_DIG_POWER_ADD, 0x0053); // power up ADC and I2S_OUT, DAP_POWERUP=1
// I2S_IN=1
write(CHIP_CLK_CTRL_ADD, 0x0004); // 256*Fs, 44.1 kHz
write(CHIP_I2S_CTRL_ADD, 0x0130); // Slave Mode, 16bit, I2S format, 32FS
//---------------- Enable DAP block ---------------------
// NOTE : DAP will be in a pass-through mode if none of DAP
// sub-blocks are enabled
DAP_CONTROL.data = read(DAP_CONTROL_ADD);
DAP_CONTROL.DAP_EN = 0;
write (DAP_CONTROL_ADD,DAP_CONTROL.data); // bit 0
//---------------- Input Volume Control---------------------
// Configure ADC left and right analog volume to desired default.
// Example shows volume of 0dB
write(CHIP_ANA_ADC_CTRL_ADD, 0x0000);
}