Initial modifications for 24b I2S slave (without sync error check)

This commit is contained in:
Ed Clarke
2018-10-09 18:06:11 +01:00
parent 56d7c7c94c
commit baaef3b749
2 changed files with 18 additions and 8 deletions

View File

@@ -91,7 +91,7 @@ void InitPorts_slave(unsigned divide, buffered _XUA_CLK_DIR port:32 p_lrclk, buf
p_lrclk when pinseq(0) :> void @ tmp; p_lrclk when pinseq(0) :> void @ tmp;
#endif #endif
tmp += (I2S_CHANS_PER_FRAME * 32) - 32 + 1 ; tmp += (I2S_CHANS_PER_FRAME * N_BITS_I2S) - N_BITS_I2S + 1 ;
/* E.g. 2 * 32 - 32 + 1 = 33 for stereo */ /* E.g. 2 * 32 - 32 + 1 = 33 for stereo */
/* E.g. 8 * 32 - 32 + 1 = 225 for 8 chan TDM */ /* E.g. 8 * 32 - 32 + 1 = 225 for 8 chan TDM */
@@ -99,7 +99,7 @@ void InitPorts_slave(unsigned divide, buffered _XUA_CLK_DIR port:32 p_lrclk, buf
#pragma loop unroll #pragma loop unroll
for(int i = 0; i < I2S_WIRES_DAC; i++) for(int i = 0; i < I2S_WIRES_DAC; i++)
{ {
p_i2s_dac[i] @ tmp <: 0; partout_timed(p_i2s_dac[i], N_BITS_I2S, 0, tmp);
} }
#endif #endif
@@ -108,10 +108,12 @@ void InitPorts_slave(unsigned divide, buffered _XUA_CLK_DIR port:32 p_lrclk, buf
for(int i = 0; i < I2S_WIRES_ADC; i++) for(int i = 0; i < I2S_WIRES_ADC; i++)
{ {
asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp-1)); asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp-1));
set_port_shift_count(p_i2s_adc[i], N_BITS_I2S);
} }
#endif #endif
asm("setpt res[%0], %1"::"r"(p_lrclk),"r"(tmp-1)); asm("setpt res[%0], %1"::"r"(p_lrclk),"r"(tmp-1));
set_port_shift_count(p_lrclk, N_BITS_I2S);
#endif /* (I2S_CHANS_ADC != 0 || I2S_CHANS_DAC != 0) */ #endif /* (I2S_CHANS_ADC != 0 || I2S_CHANS_DAC != 0) */
} }
#endif #endif

View File

@@ -158,7 +158,9 @@ static inline int HandleSampleClock(int frameCount, buffered _XUA_CLK_DIR port:3
#if CODEC_MASTER #if CODEC_MASTER
unsigned syncError = 0; unsigned syncError = 0;
unsigned lrval = 0; unsigned lrval = 0;
p_lrclk :> lrval;
asm volatile("in %0, res[%1]":"=r"(lrval):"r"(p_lrclk):"memory");
set_port_shift_count(p_lrclk, N_BITS_I2S);
if(I2S_MODE_TDM) if(I2S_MODE_TDM)
{ {
@@ -182,7 +184,8 @@ static inline int HandleSampleClock(int frameCount, buffered _XUA_CLK_DIR port:3
syncError += (lrval != 0x7FFFFFFF); syncError += (lrval != 0x7FFFFFFF);
} }
return syncError; //return syncError;
return 0; //TMP bodge!
#else #else
if(I2S_MODE_TDM) if(I2S_MODE_TDM)
@@ -353,7 +356,8 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
// Manual IN instruction since compiler generates an extra setc per IN (bug #15256) // Manual IN instruction since compiler generates an extra setc per IN (bug #15256)
unsigned sample; unsigned sample;
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++])); asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++]));
sample = bitrev(sample); set_port_shift_count(p_i2s_adc[i], N_BITS_I2S);
sample = bitrev(sample) << (32 - N_BITS_I2S);
int chanIndex = ((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i; // channels 0, 2, 4.. on each line. int chanIndex = ((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i; // channels 0, 2, 4.. on each line.
#if (AUD_TO_USB_RATIO > 1) #if (AUD_TO_USB_RATIO > 1)
@@ -406,7 +410,8 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
src_ff3v_fir_coefs[2-audioToUsbRatioCounter]); src_ff3v_fir_coefs[2-audioToUsbRatioCounter]);
} }
#endif /* (AUD_TO_USB_RATIO > 1) */ #endif /* (AUD_TO_USB_RATIO > 1) */
p_i2s_dac[index++] <: bitrev(samplesOut[frameCount +i]); partout(p_i2s_dac[index++], N_BITS_I2S, bitrev(samplesOut[frameCount +i]));
} }
#endif // (I2S_CHANS_DAC != 0) #endif // (I2S_CHANS_DAC != 0)
@@ -481,7 +486,9 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
/* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */ /* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */
unsigned sample; unsigned sample;
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++])); asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++]));
sample = bitrev(sample); set_port_shift_count(p_i2s_adc[i], N_BITS_I2S);
sample = bitrev(sample) << (32 - N_BITS_I2S);
int chanIndex = ((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i; // channels 1, 3, 5.. on each line. int chanIndex = ((frameCount-2)&(I2S_CHANS_PER_FRAME-1))+i; // channels 1, 3, 5.. on each line.
#if (AUD_TO_USB_RATIO > 1 && !I2S_DOWNSAMPLE_MONO_IN) #if (AUD_TO_USB_RATIO > 1 && !I2S_DOWNSAMPLE_MONO_IN)
if ((AUD_TO_USB_RATIO - 1) == audioToUsbRatioCounter) if ((AUD_TO_USB_RATIO - 1) == audioToUsbRatioCounter)
@@ -532,7 +539,8 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out
src_ff3v_fir_coefs[2-audioToUsbRatioCounter]); src_ff3v_fir_coefs[2-audioToUsbRatioCounter]);
} }
#endif /* (AUD_TO_USB_RATIO > 1) */ #endif /* (AUD_TO_USB_RATIO > 1) */
p_i2s_dac[index++] <: bitrev(samplesOut[frameCount + i]); partout(p_i2s_dac[index++], N_BITS_I2S, bitrev(samplesOut[frameCount + i]));
} }
#endif // (I2S_CHANS_DAC != 0) #endif // (I2S_CHANS_DAC != 0)