Adding route() made me review dap_enable() more closely and it wasn't doing what I intended to do before, it was ignoring I2S coming back from Teensy, DAP was sourced from ADC as was I2S_DOUT and DAC was sourced from DAP; Teensy received valid data from ADC but data from Teensy was just discarded if user selected it.dds
return val1; | return val1; | ||||
} | } | ||||
unsigned short AudioControlSGTL5000::route(uint8_t i2s_out, uint8_t dac, uint8_t dap, uint8_t dap_mix) | |||||
{ | |||||
i2s_out&=3; | |||||
dac&=3; | |||||
dap&=3; | |||||
dap_mix&=3; | |||||
if((i2s_out==SGTL_AUDIO_PROCESSOR)||(dac==SGTL_AUDIO_PROCESSOR)) modify(DAP_CONTROL,1,1); // enable DAP | |||||
return modify(CHIP_SSS_CTRL,(dap_mix<<8)|(dap<<6)|(dac<<4)|i2s_out,(3<<8)|(3<<6)|(3<<4)|3); | |||||
} | |||||
bool AudioControlSGTL5000::volumeInteger(unsigned int n) | bool AudioControlSGTL5000::volumeInteger(unsigned int n) | ||||
{ | { | ||||
if (n == 0) { | if (n == 0) { | ||||
unsigned short AudioControlSGTL5000::dap_enable(uint8_t n) | unsigned short AudioControlSGTL5000::dap_enable(uint8_t n) | ||||
{ | { | ||||
if(n) n=1; | if(n) n=1; | ||||
unsigned char DAC=1+(2*n); // I2S_IN if n==0 else DAP | |||||
unsigned char i2s_sel=3*n; // ADC if n==0 else DAP | |||||
modify(DAP_CONTROL,n,1); | modify(DAP_CONTROL,n,1); | ||||
return modify(CHIP_SSS_CTRL,(0<<6)|(DAC<<4),(3<<6)|(3<<4)); | |||||
return route(i2s_sel,SGTL_I2S_TEENSY,SGTL_ADC); | |||||
} | } | ||||
unsigned short AudioControlSGTL5000::dap_enable(void) | unsigned short AudioControlSGTL5000::dap_enable(void) |
#include "AudioControl.h" | #include "AudioControl.h" | ||||
#define SGTL_ADC 0 | |||||
#define SGTL_I2S_TEENSY 1 | |||||
#define SGTL_AUDIO_PROCESSOR 3 | |||||
class AudioControlSGTL5000 : public AudioControl | class AudioControlSGTL5000 : public AudioControl | ||||
{ | { | ||||
public: | public: | ||||
//bool inputLinein(void) { return write(0x0024, ana_ctrl | (1<<2)); } | //bool inputLinein(void) { return write(0x0024, ana_ctrl | (1<<2)); } | ||||
//bool inputMic(void) { return write(0x002A, 0x0172) && write(0x0024, ana_ctrl & ~(1<<2)); } | //bool inputMic(void) { return write(0x002A, 0x0172) && write(0x0024, ana_ctrl & ~(1<<2)); } | ||||
unsigned short route(uint8_t i2s_out, uint8_t dac, uint8_t dap, uint8_t dap_mix); | |||||
unsigned short route(uint8_t i2s_out, uint8_t dac, uint8_t dap) { route(i2s_out,dac,dap,0); } | |||||
bool volume(float left, float right); | bool volume(float left, float right); | ||||
unsigned short micGain(unsigned int n) { return modify(0x002A, n&3, 3); } | unsigned short micGain(unsigned int n) { return modify(0x002A, n&3, 3); } | ||||
unsigned short lo_lvl(uint8_t n); | unsigned short lo_lvl(uint8_t n); |