From 47e5629acd6e2264252c8dcc747deefd6ae3ca90 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 12:09:45 +0000 Subject: [PATCH 01/16] Removed multiplication by decimation factor (lib_mic_array fixed) --- 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 cf2821ce..7a791eb0 100644 --- a/module_usb_audio/pdm_mics/pcm_pdm_mic.xc +++ b/module_usb_audio/pdm_mics/pcm_pdm_mic.xc @@ -72,7 +72,7 @@ void pdm_process(streaming chanend c_ds_output_0, streaming chanend c_ds_output_ { for(int i = 0; i < NUM_PDM_MICS; i++) { - c_audio <: output[i]*decimationfactor; + c_audio <: output[i]; } } else From 2ae99f11e6da3e246ffaa0fe9bc7d9a4adeebdc7 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 15:17:25 +0000 Subject: [PATCH 02/16] Removed 32kHz support when PDM mics enabled (lib_mic_array supports integer decimation factors only) --- module_usb_audio/endpoint0/audiorequests.xc | 6 +++++- module_usb_audio/endpoint0/descriptors.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/module_usb_audio/endpoint0/audiorequests.xc b/module_usb_audio/endpoint0/audiorequests.xc index 591d36fb..a5f727cb 100644 --- a/module_usb_audio/endpoint0/audiorequests.xc +++ b/module_usb_audio/endpoint0/audiorequests.xc @@ -874,7 +874,11 @@ int AudioClassRequests_2(XUD_ep ep0_out, XUD_ep ep0_in, USB_SetupPacket_t &sp, c } #endif /* Special case for some low sample rates */ - unsigned lowSampleRateList[] = {8000, 11025, 12000, 16000, 32000}; + unsigned lowSampleRateList[] = {8000, 11025, 12000, 16000, +#if (NUM_PDM_MICS == 0) + 32000 +#endif + }; for (int k = 0; k < sizeof(lowSampleRateList)/sizeof(unsigned); k++) { diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index c8d02437..189e1a12 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -2227,9 +2227,11 @@ const unsigned num_freqs_a1 = MAX(3, (0 #if(MIN_FREQ <= 16000) && (MAX_FREQ_FS >= 16000) +1 #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) +1 #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) +1 #endif @@ -2455,9 +2457,11 @@ unsigned char cfgDesc_Audio1[] = CHARIFY_SR(16000), /* sampleFreq - 16KHz */ #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) CHARIFY_SR(32000), /* sampleFreq - 32KHz */ #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) 0x44, 0xAC, 0x00, /* sampleFreq - 44.1Khz */ @@ -2583,9 +2587,11 @@ unsigned char cfgDesc_Audio1[] = CHARIFY_SR(16000), /* sampleFreq - 32KHz */ #endif +#if (NUM_PDM_MICS == 0) #if(MIN_FREQ <= 32000) && (MAX_FREQ_FS >= 32000) CHARIFY_SR(32000), /* sampleFreq - 32KHz */ #endif +#endif #if (MIN_FREQ <= 44100) && (MAX_FREQ_FS >= 44100) 0x44, 0xAC, 0x00, /* sampleFreq - 44.1Khz */ From 07147aa294ba06455a37a9ba5cefc3eed12d96ba Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 15:29:31 +0000 Subject: [PATCH 03/16] Changelog --- CHANGELOG.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7891f62e..7bf515c8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,11 @@ sc_usb_audio Change Log ======================= +HEAD +---- + - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array + currently does not support non-integer decimation factors) + 6.14.0 ------ - ADDED: Support for for master-clock/sample-rate divides that are not a power of 2 From 0991de95dcf5e2c853da5b979e6325334e18ea3c Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 15:34:31 +0000 Subject: [PATCH 04/16] Changelog --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7bf515c8..69c2f5c7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,8 @@ sc_usb_audio Change Log ======================= -HEAD ----- +6.14.1 +------ - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array currently does not support non-integer decimation factors) From 32a171fa44e55c6237839a9e7f917ab79ef06ff2 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 15:37:34 +0000 Subject: [PATCH 05/16] Master branch version number bump --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 69c2f5c7..61400c6f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,7 +1,7 @@ sc_usb_audio Change Log ======================= -6.14.1 +6.15.0 ------ - CHANGE: Removed 32kHz sample-rate support when PDM microphones enabled (lib_mic_array currently does not support non-integer decimation factors) From cc886a643cab02952b1ec6eb14a6cb1bfa7bf202 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 16:05:44 +0000 Subject: [PATCH 06/16] UAC1.0 descriptors now support multi-channel volume control (previously were hard-coded as stereo) --- module_usb_audio/endpoint0/descriptors.h | 57 ++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/module_usb_audio/endpoint0/descriptors.h b/module_usb_audio/endpoint0/descriptors.h index 189e1a12..08f865b0 100644 --- a/module_usb_audio/endpoint0/descriptors.h +++ b/module_usb_audio/endpoint0/descriptors.h @@ -2246,7 +2246,7 @@ const unsigned num_freqs_a1 = MAX(3, (0 #endif )); -#define AC_TOTAL_LENGTH (AC_LENGTH + (INPUT_INTERFACES_A1 * (19 + num_freqs_a1 * 3)) + (OUTPUT_INTERFACES_A1 * (19 + (num_freqs_a1 *3)))) +#define AC_TOTAL_LENGTH (AC_LENGTH + (INPUT_INTERFACES_A1 * (17 + NUM_USB_CHAN_IN_FS + num_freqs_a1 * 3)) + (OUTPUT_INTERFACES_A1 * (17 + NUM_USB_CHAN_OUT_FS + (num_freqs_a1 *3)))) #define STREAMING_INTERFACES (INPUT_INTERFACES_A1 + OUTPUT_INTERFACES_A1) /* Number of interfaces for Audio 1.0 (+1 for control ) */ @@ -2322,15 +2322,41 @@ unsigned char cfgDesc_Audio1[] = 11, /* iTerminal */ /* CS_Interface class specific AC interface feature unit descriptor - mute & volume for dac */ - 0x0A, + (8 + NUM_USB_CHAN_OUT_FS), UAC_CS_DESCTYPE_INTERFACE, UAC_CS_AC_INTERFACE_SUBTYPE_FEATURE_UNIT, /* 2 bDescriptorSubType: FEATURE_UNIT */ 0x0A, /* unitID */ 0x01, /* sourceID - ID of the unit/terminal to which this feature unit is connected */ 0x01, /* controlSize - 1 */ + 0x00, /* bmaControls(0) */ +#if (NUM_USB_CHAN_OUT_FS > 0) 0x03, /* bmaControls(1) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 1) 0x03, /* bmaControls(2) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 2) + 0x03, /* bmaControls(3) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 3) + 0x03, /* bmaControls(4) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 4) + 0x03, /* bmaControls(5) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 5) + 0x03, /* bmaControls(6) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 6) + 0x03, /* bmaControls(7) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 7) + 0x03, /* bmaControls(8) */ +#endif +#if (NUM_USB_CHAN_OUT_FS > 8) +#error NUM_USB_CHAN_OUT_FS > 8 currently supported +#endif 0x00, /* String table index */ /* CS_Interface Output Terminal Descriptor - Analogue out to speaker */ @@ -2368,15 +2394,40 @@ unsigned char cfgDesc_Audio1[] = 0x00, /* Unused */ /* CS_Interface class specific AC interface feature unit descriptor - mute & volume for adc */ - 0x0A, + (8 + NUM_USB_CHAN_IN_FS), UAC_CS_DESCTYPE_INTERFACE, UAC_CS_AC_INTERFACE_SUBTYPE_FEATURE_UNIT, /* 2 bDescriptorSubType: FEATURE_UNIT */ 0x0B, /* unitID */ 0x02, /* sourceID - ID of the unit/terminal to which this feature unit is connected */ 0x01, /* controlSize - 1 */ 0x00, /* bmaControls(0) */ +#if (NUM_USB_CHAN_IN_FS > 0) 0x03, /* bmaControls(1) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 1) 0x03, /* bmaControls(2) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 2) + 0x03, /* bmaControls(3) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 3) + 0x03, /* bmaControls(4) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 4) + 0x03, /* bmaControls(5) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 5) + 0x03, /* bmaControls(6) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 6) + 0x03, /* bmaControls(7) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 7) + 0x03, /* bmaControls(8) */ +#endif +#if (NUM_USB_CHAN_IN_FS > 8) +#error NUM_USB_CHAN_IN_FS > 8 currently supported +#endif 0x00, /* String table index */ #endif From 07a06df5731d7905ce72b5ebdf9ebd08b0f0e01a Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 8 Dec 2015 16:09:32 +0000 Subject: [PATCH 07/16] 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 dde563a63d516ed4ccd087c2c1232eb4d8be6948 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 9 Dec 2015 23:09:22 +0000 Subject: [PATCH 08/16] 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 09/16] 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 10/16] 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 11/16] 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 12/16] 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 13/16] 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 14/16] 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 15/16] 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 16/16] 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}};