From 07a06df5731d7905ce72b5ebdf9ebd08b0f0e01a Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 16:09:32 +0000 Subject: [PATCH 01/17] Changelog update --- CHANGELOG.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 61400c6f..5c4256f4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,8 @@ sc_usb_audio Change Log ------ - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array currently does not support non-integer decimation factors) + - RESOLVED: UAC 1.0 descriptors now support multi-channel volume control (previously were + hard-coded as stereo) 6.14.0 ------ From 202c90f750f084dc56ccc08c5706ba758dbe3496 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 9 Dec 2015 16:21:22 +0000 Subject: [PATCH 02/17] 'Record release: 6.14.1beta0' --- xpd.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xpd.xml b/xpd.xml index 1922b7ce..25cdebda 100644 --- a/xpd.xml +++ b/xpd.xml @@ -96,7 +96,8 @@ - + + XM-004720-SM XMOS @@ -105,4 +106,4 @@ 1.0 - + \ No newline at end of file From dde563a63d516ed4ccd087c2c1232eb4d8be6948 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 9 Dec 2015 23:09:22 +0000 Subject: [PATCH 03/17] BCD_DEVICE_M: 14 -> 15 --- module_usb_audio/devicedefines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/devicedefines.h b/module_usb_audio/devicedefines.h index da3c8ac7..c43d30be 100644 --- a/module_usb_audio/devicedefines.h +++ b/module_usb_audio/devicedefines.h @@ -465,7 +465,7 @@ * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. */ #ifndef BCD_DEVICE_M -#define BCD_DEVICE_M 14 +#define BCD_DEVICE_M 15 #endif /** From ead2dffbc6bae240592d2681d8e3d7aa1c5da171 Mon Sep 17 00:00:00 2001 From: Sam Chesney Date: Thu, 10 Dec 2015 16:41:30 +0000 Subject: [PATCH 04/17] Prepare CHANGELOG for xmos_changelog_check test --- CHANGELOG.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5c4256f4..0cf4ec8e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -177,4 +177,7 @@ sc_usb_audio Change Log - CHANGE: Level meter buffer naming now resemble functionality +Legacy release history +---------------------- + Please see changelog in sw_usb_audio for changes prior to 6.8.0 release. From 6a76987b1795eb428a87cf9f493cb5b418284266 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 11 Dec 2015 17:30:07 +0000 Subject: [PATCH 05/17] Fixed up build issue due to lib_mic_array API change --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index 7a791eb0..b46fe96d 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -59,7 +59,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ while(1) { - frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio); + frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio, 2); unsafe { From bf75f409f7209ea834092bb4d2f96c43535b5ce0 Mon Sep 17 00:00:00 2001 From: Krishna Balan Date: Thu, 17 Dec 2015 17:17:52 +0000 Subject: [PATCH 06/17] Support for PDM and I2S to be on same tile; MCLK divider set to 4 to generate PDM clk --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index b46fe96d..67012df9 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -19,8 +19,12 @@ /* Hardware resources */ in port p_pdm_clk = PORT_PDM_CLK; in buffered port:32 p_pdm_mics = PORT_PDM_DATA; +#if AUDIO_IO_TILE != PDM_TILE in port p_mclk = PORT_PDM_MCLK; -clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_3; +#else +// Use 'p_mclk_in' shared by I2S +#endif +clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_4; /* User hooks */ unsafe void user_pdm_process(frame_audio * unsafe audio, int output[]); @@ -92,9 +96,18 @@ void pcm_pdm_mic(chanend c_pcm_out) { streaming chan c_4x_pdm_mic_0, c_4x_pdm_mic_1; streaming chan c_ds_output_0, c_ds_output_1; + /* TODO, always run mics at 3MHz */ - configure_clock_src_divide(pdmclk, p_mclk, 2); + /* Assuming MCLK is 24.576 MHz */ + #if AUDIO_IO_TILE != PDM_TILE + configure_clock_src_divide(pdmclk, p_mclk, 4); + #else + unsigned port_id, divide = 4; + asm("ldw %0, dp[p_mclk_in]":"=r"(port_id)); + asm("setclk res[%0], %1"::"r"(pdmclk), "r"(port_id)); + asm("setd res[%0], %1"::"r"(pdmclk), "r"(divide)); + #endif configure_port_clock_output(p_pdm_clk, pdmclk); configure_in_port(p_pdm_mics, pdmclk); start_clock(pdmclk); From dcc81c6dd7d1f1e385f0f3a7591ba4e664ce2a23 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 12 Jan 2016 12:10:06 +0000 Subject: [PATCH 07/17] Build issues resolved with latest lib_mic_array --- module_usb_audio/pdm_mics/mic_array_conf.h | 3 +-- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 31 ++++++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/module_usb_audio/pdm_mics/mic_array_conf.h b/module_usb_audio/pdm_mics/mic_array_conf.h index 35af7f29..8aca8c43 100644 --- a/module_usb_audio/pdm_mics/mic_array_conf.h +++ b/module_usb_audio/pdm_mics/mic_array_conf.h @@ -1,7 +1,6 @@ #ifndef MIC_ARRAY_CONF_H_ #define MIC_ARRAY_CONF_H_ -#define FRAME_SIZE_LOG2 0 - +#define MAX_FRAME_SIZE_LOG2 0 #endif /* MIC_ARRAY_CONF_H_ */ diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index b46fe96d..022ff0bc 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -16,6 +16,8 @@ #include "fir_decimator.h" #include "mic_array.h" +#define MAX_DECIMATION_FACTOR 12 + /* Hardware resources */ in port p_pdm_clk = PORT_PDM_CLK; in buffered port:32 p_pdm_mics = PORT_PDM_DATA; @@ -26,12 +28,12 @@ clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_3; unsafe void user_pdm_process(frame_audio * unsafe audio, int output[]); void user_pdm_init(); -int data_0[4*COEFS_PER_PHASE*MAX_DECIMATION_FACTOR] = {0}; -int data_1[4*COEFS_PER_PHASE*MAX_DECIMATION_FACTOR] = {0}; +int data_0[4*THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {0}; +int data_1[4*THIRD_STAGE_COEFS_PER_STAGE * MAX_DECIMATION_FACTOR] = {0}; frame_audio mic_audio[2]; -void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_1, chanend c_audio) +void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) { unsigned buffer = 1; // Buffer index memset(mic_audio, sizeof(frame_audio), 0); @@ -45,21 +47,22 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ c_audio :> samplerate; - unsigned decimationfactor = 48000/samplerate; + unsigned decimationfactor = 96000/samplerate; unsafe { - decimator_config_common dcc = {FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor], 0}; - decimator_config dc0 = {&dcc, data_0, {0, 0, 0, 0}}; - decimator_config dc1 = {&dcc, data_1, {0, 0, 0, 0}}; - decimator_configure(c_ds_output_0, c_ds_output_1, dc0, dc1); + int * unsafe fir_coefs[7] = {0, g_third_48kHz_fir, g_third_24kHz_fir, g_third_16kHz_fir, g_third_12kHz_fir, 0, g_third_8kHz_fir}; + + decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, INT_MAX>>4}; + decimator_config dc[2] = {{&dcc, data_0, {0, 0, 0, 0}, 4}, {&dcc, data_1, {0, 0, 0, 0}, 4}}; + decimator_configure(c_ds_output, 2, dc); } - decimator_init_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio, DECIMATOR_NO_FRAME_OVERLAP); + decimator_init_audio_frame(c_ds_output, 2, buffer, mic_audio, DECIMATOR_NO_FRAME_OVERLAP); while(1) { - frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output_0, c_ds_output_1, buffer, mic_audio, 2); + frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output, 2, buffer, mic_audio, 2); unsafe { @@ -91,7 +94,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ void pcm_pdm_mic(chanend c_pcm_out) { streaming chan c_4x_pdm_mic_0, c_4x_pdm_mic_1; - streaming chan c_ds_output_0, c_ds_output_1; + streaming chan c_ds_output[2]; /* TODO, always run mics at 3MHz */ configure_clock_src_divide(pdmclk, p_mclk, 2); @@ -102,9 +105,9 @@ void pcm_pdm_mic(chanend c_pcm_out) par { pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1); - decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output_0); - decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output_1); - pdm_process(c_ds_output_0, c_ds_output_1, c_pcm_out); + decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output[0]); + decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output[1]); + pdm_process(c_ds_output, c_pcm_out); } } From 4743f90747525c43fa5edd2cb4005c9f17192044 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 12 Jan 2016 13:43:22 +0000 Subject: [PATCH 08/17] Temporarily reverted Krishna's commit - was causing audio issues from Mics on array ref v1.0 --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index adf46a82..022ff0bc 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -21,12 +21,8 @@ /* Hardware resources */ in port p_pdm_clk = PORT_PDM_CLK; in buffered port:32 p_pdm_mics = PORT_PDM_DATA; -#if AUDIO_IO_TILE != PDM_TILE in port p_mclk = PORT_PDM_MCLK; -#else -// Use 'p_mclk_in' shared by I2S -#endif -clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_4; +clock pdmclk = on tile[PDM_TILE]: XS1_CLKBLK_3; /* User hooks */ unsafe void user_pdm_process(frame_audio * unsafe audio, int output[]); @@ -101,15 +97,7 @@ void pcm_pdm_mic(chanend c_pcm_out) streaming chan c_ds_output[2]; /* TODO, always run mics at 3MHz */ - /* Assuming MCLK is 24.576 MHz */ - #if AUDIO_IO_TILE != PDM_TILE - configure_clock_src_divide(pdmclk, p_mclk, 4); - #else - unsigned port_id, divide = 4; - asm("ldw %0, dp[p_mclk_in]":"=r"(port_id)); - asm("setclk res[%0], %1"::"r"(pdmclk), "r"(port_id)); - asm("setd res[%0], %1"::"r"(pdmclk), "r"(divide)); - #endif + configure_clock_src_divide(pdmclk, p_mclk, 2); configure_port_clock_output(p_pdm_clk, pdmclk); configure_in_port(p_pdm_mics, pdmclk); start_clock(pdmclk); From 96a11abb80d686621ea9c7d791585416b5e9fc19 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Fri, 15 Jan 2016 16:07:40 +0000 Subject: [PATCH 09/17] Updated filter coef naming for latest lib_mic_array --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index 022ff0bc..7b8f629b 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -51,9 +51,9 @@ void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) unsafe { - int * unsafe fir_coefs[7] = {0, g_third_48kHz_fir, g_third_24kHz_fir, g_third_16kHz_fir, g_third_12kHz_fir, 0, g_third_8kHz_fir}; + int * unsafe fir_coefs[7] = {0, g_third_stage_div_2_fir, g_third_stage_div_4_fir, g_third_stage_div_6_fir, g_third_stage_div_8_fir, 0, g_third_stage_div_12_fir}; - decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, INT_MAX>>4}; + decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0}; decimator_config dc[2] = {{&dcc, data_0, {0, 0, 0, 0}, 4}, {&dcc, data_1, {0, 0, 0, 0}, 4}}; decimator_configure(c_ds_output, 2, dc); } From cda325397edf19f89bed550a121879afd41e4110 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 18 Jan 2016 15:49:23 +0000 Subject: [PATCH 10/17] Required build fixes for latest lib_mic_array updates --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index 7b8f629b..0489ee32 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -53,16 +53,15 @@ void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) { int * unsafe fir_coefs[7] = {0, g_third_stage_div_2_fir, g_third_stage_div_4_fir, g_third_stage_div_6_fir, g_third_stage_div_8_fir, 0, g_third_stage_div_12_fir}; - decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0}; + decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0, DECIMATOR_NO_FRAME_OVERLAP, 2}; decimator_config dc[2] = {{&dcc, data_0, {0, 0, 0, 0}, 4}, {&dcc, data_1, {0, 0, 0, 0}, 4}}; decimator_configure(c_ds_output, 2, dc); - } - decimator_init_audio_frame(c_ds_output, 2, buffer, mic_audio, DECIMATOR_NO_FRAME_OVERLAP); + decimator_init_audio_frame(c_ds_output, 2, buffer, mic_audio, dcc); while(1) { - frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output, 2, buffer, mic_audio, 2); + frame_audio * unsafe current = decimator_get_next_audio_frame(c_ds_output, 2, buffer, mic_audio, dcc); unsafe { @@ -83,6 +82,7 @@ void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) break; } } + } } } } From 0b267e606af455a869bdf5a8a609060f971804f3 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 18 Jan 2016 15:52:13 +0000 Subject: [PATCH 11/17] Build warning fix with lib_mic_array integration --- module_usb_audio/pdm_mics/pcm_pdm_mic.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc index 0489ee32..94e65c71 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -51,7 +51,7 @@ void pdm_process(streaming chanend c_ds_output[2], chanend c_audio) unsafe { - int * unsafe fir_coefs[7] = {0, g_third_stage_div_2_fir, g_third_stage_div_4_fir, g_third_stage_div_6_fir, g_third_stage_div_8_fir, 0, g_third_stage_div_12_fir}; + const int * unsafe fir_coefs[7] = {0, g_third_stage_div_2_fir, g_third_stage_div_4_fir, g_third_stage_div_6_fir, g_third_stage_div_8_fir, 0, g_third_stage_div_12_fir}; decimator_config_common dcc = {MAX_FRAME_SIZE_LOG2, 1, 0, 0, decimationfactor, fir_coefs[decimationfactor/2], 0, 0, DECIMATOR_NO_FRAME_OVERLAP, 2}; decimator_config dc[2] = {{&dcc, data_0, {0, 0, 0, 0}, 4}, {&dcc, data_1, {0, 0, 0, 0}, 4}}; From 6a80cc85e287ecbf98eab1fcaa728167e9ce3d83 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Thu, 4 Feb 2016 12:00:36 +0000 Subject: [PATCH 12/17] Initialisation issue with DAC ports for TDM slave mode fixed --- module_usb_audio/audio.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index 6754b60a..e33166f7 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -421,7 +421,7 @@ static inline void InitPorts(unsigned divide) #pragma loop unroll for(int i = 0; i < I2S_WIRES_ADC; i++) { - asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp+31)); + asm("setpt res[%0], %1"::"r"(p_i2s_adc[i]),"r"(tmp-1)); } #endif #endif From 7353d4d0a404e44e891357a59950af0df65c61e4 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Thu, 4 Feb 2016 12:35:35 +0000 Subject: [PATCH 13/17] DAC data mis-alignment issue in TDM slave mode added to changelog. --- CHANGELOG.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0cf4ec8e..85366856 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ sc_usb_audio Change Log ======================= +6.15.1 +------ + - RESOLVED: DAC data mis-alignment issue in TDM slave mode + 6.15.0 ------ - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array From 75815a0da62895bb7744076b2ae7b9e014cb5b87 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Thu, 4 Feb 2016 12:39:18 +0000 Subject: [PATCH 14/17] Added the ability to offset DAC data from ADC data (useful if ADC and DAC do not agree on TDM formats as on the xCORE-200-MC-AUDIO board. --- CHANGELOG.rst | 3 +++ module_usb_audio/audio.xc | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 85366856..5a46b8fe 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,8 +3,11 @@ sc_usb_audio Change Log 6.15.1 ------ + - ADDED: Ability to offset DAC data from ADC data. Useful if ADC and DAC do not agree + on TDM formats as on the xCORE-200-MC-AUDIO board. See I2S_ADC_TO_DAC_SAMP_OFFSET - RESOLVED: DAC data mis-alignment issue in TDM slave mode + 6.15.0 ------ - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index e33166f7..ac1b3168 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -106,6 +106,12 @@ extern void device_reboot(void); #define MAX_DIVIDE (MAX_DIVIDE_48) #endif +/* Useful for correcting a difference in sample clock polarity between DAC and ADC */ +#ifndef I2S_ADC_TO_DAC_SAMP_OFFSET +#define I2S_ADC_TO_DAC_SAMP_OFFSET 0 +#endif + + #ifndef CODEC_MASTER static inline void doI2SClocks(unsigned divide) { @@ -656,7 +662,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, /* Output "even" channel to DAC (i.e. left) */ for(int i = 0; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME) { - p_i2s_dac[index++] <: bitrev(samplesOut[(frameCount)+i]); + p_i2s_dac[index++] <: bitrev(samplesOut[((frameCount+I2S_ADC_TO_DAC_SAMP_OFFSET)&(I2S_CHANS_PER_FRAME-1))+i]); } #endif @@ -761,7 +767,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, #pragma loop unroll for(int i = 1; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME) { - p_i2s_dac[index++] <: bitrev(samplesOut[frameCount+i]); + p_i2s_dac[index++] <: bitrev(samplesOut[(frameCount+i+I2S_ADC_TO_DAC_SAMP_OFFSET)&(I2S_CHANS_PER_FRAME-1)]); } #endif From 967ac894201befcef4a99ff701e50e42efd8b992 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 9 Feb 2016 19:12:04 +0000 Subject: [PATCH 15/17] Merge --- module_usb_audio/audio.xc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index ac1b3168..5e4a6c48 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -106,12 +106,6 @@ extern void device_reboot(void); #define MAX_DIVIDE (MAX_DIVIDE_48) #endif -/* Useful for correcting a difference in sample clock polarity between DAC and ADC */ -#ifndef I2S_ADC_TO_DAC_SAMP_OFFSET -#define I2S_ADC_TO_DAC_SAMP_OFFSET 0 -#endif - - #ifndef CODEC_MASTER static inline void doI2SClocks(unsigned divide) { @@ -662,7 +656,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, /* Output "even" channel to DAC (i.e. left) */ for(int i = 0; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME) { - p_i2s_dac[index++] <: bitrev(samplesOut[((frameCount+I2S_ADC_TO_DAC_SAMP_OFFSET)&(I2S_CHANS_PER_FRAME-1))+i]); + p_i2s_dac[index++] <: bitrev(samplesOut[frameCount +i]); } #endif @@ -767,7 +761,7 @@ unsigned static deliver(chanend c_out, chanend ?c_spd_out, #pragma loop unroll for(int i = 1; i < I2S_CHANS_DAC; i+=I2S_CHANS_PER_FRAME) { - p_i2s_dac[index++] <: bitrev(samplesOut[(frameCount+i+I2S_ADC_TO_DAC_SAMP_OFFSET)&(I2S_CHANS_PER_FRAME-1)]); + p_i2s_dac[index++] <: bitrev(samplesOut[frameCount + i]); } #endif From a07fe64c1d367315760a27d1c4e5f867715f53e5 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 10 Feb 2016 12:28:16 +0000 Subject: [PATCH 16/17] Removed I2S_ADC_DAC_OFFSET from changelog --- CHANGELOG.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5a46b8fe..684db173 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,8 +3,6 @@ sc_usb_audio Change Log 6.15.1 ------ - - ADDED: Ability to offset DAC data from ADC data. Useful if ADC and DAC do not agree - on TDM formats as on the xCORE-200-MC-AUDIO board. See I2S_ADC_TO_DAC_SAMP_OFFSET - RESOLVED: DAC data mis-alignment issue in TDM slave mode From 431c7f5db9e64aa65973a7d364727ff63c966a65 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 9 Feb 2016 19:06:19 +0000 Subject: [PATCH 17/17] comment typo only --- module_usb_audio/audio.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module_usb_audio/audio.xc b/module_usb_audio/audio.xc index 5e4a6c48..de905b83 100755 --- a/module_usb_audio/audio.xc +++ b/module_usb_audio/audio.xc @@ -407,7 +407,7 @@ static inline void InitPorts(unsigned divide) tmp += (I2S_CHANS_PER_FRAME * 32) - 32 + 1 ; /* 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 */ #if (I2S_CHANS_DAC != 0) #pragma loop unroll