forked from PAWPAW-Mirror/lib_xua
Standard I2S mode up and running again. Still needs more generalisation.
This commit is contained in:
@@ -27,12 +27,11 @@ static unsigned samplesOut[NUM_USB_CHAN_OUT];
|
||||
|
||||
/* Two buffers for ADC data to allow for DAC and ADC ports being offset */
|
||||
static unsigned samplesIn_0[NUM_USB_CHAN_IN];
|
||||
static unsigned samplesIn_1[NUM_USB_CHAN_IN];
|
||||
static unsigned samplesIn_1[I2S_CHANS_ADC];
|
||||
|
||||
#ifdef I2S_MODE_TDM
|
||||
#define I2S_CHANS_PER_FRAME 8
|
||||
#else
|
||||
#error
|
||||
#define I2S_CHANS_PER_FRAME 2
|
||||
#endif
|
||||
|
||||
@@ -575,9 +574,9 @@ chanend ?c_adc)
|
||||
#if (I2S_CHANS_ADC != 0)
|
||||
/* Input previous L sample into L in buffer */
|
||||
index = 0;
|
||||
#ifdef I2S_MODE_TDM
|
||||
/* First input (i.e. frameCoint == 0) we read last ADC channel of previous frame.. */
|
||||
unsigned buffIndex = frameCount ? !readBuffNo : readBuffNo;
|
||||
#ifdef I2S_MODE_TDM
|
||||
#pragma loop unroll
|
||||
/* First time around we get channel 7 of TDM8 */
|
||||
for(int i = 0; i < I2S_CHANS_ADC; i+=I2S_CHANS_PER_FRAME)
|
||||
@@ -592,12 +591,17 @@ chanend ?c_adc)
|
||||
}
|
||||
#else
|
||||
#pragma loop unroll
|
||||
for(int i = 0; i < I2S_CHANS_ADC; i += 2)
|
||||
for(int i = 0; i < I2S_CHANS_ADC; i += 2) // TODO I2S_CHANS_PER_FRAME
|
||||
{
|
||||
/* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */
|
||||
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++]));
|
||||
samplesIn[i] = bitrev(sample);
|
||||
samplesIn[i-1] = samplesInPrev[i];
|
||||
|
||||
if(buffIndex)
|
||||
samplesIn_1[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line.
|
||||
else
|
||||
samplesIn_0[((frameCount-1)&(I2S_CHANS_PER_FRAME-1))+i] = bitrev(sample); // channels 1, 3, 5.. on each line.
|
||||
// samplesIn_1[i] = bitrev(sample);
|
||||
// samplesIn[i-1] = samplesInPrev[i];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -686,7 +690,13 @@ chanend ?c_adc)
|
||||
{
|
||||
/* Manual IN instruction since compiler generates an extra setc per IN (bug #15256) */
|
||||
asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++]));
|
||||
samplesInPrev[i] = bitrev(sample);
|
||||
//samplesInPrev[i] = bitrev(sample);
|
||||
|
||||
if(readBuffNo)
|
||||
samplesIn_0[frameCount+i] = bitrev(sample);
|
||||
else
|
||||
samplesIn_1[frameCount+i] = bitrev(sample);
|
||||
//samplesIn_1[i] = bitrev(sample);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user