diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d75483d9..d4347720 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,9 +8,10 @@ lib_xua Change Log * ADDED: Application note AN00247: Using lib_xua with lib_spdif (transmit) * CHANGE: I2S hardware resources no longer used globally and must be passed to XUA_AudioHub() - * CHANGE: NO_USB define renamed to XUA_USB_EN * CHANGE: XUA_AudioHub() no longer pars S/PDIF transmitter task * CHANGE: Moved to lib_spdif (from module_spdif_tx & module_spdif_rx) + * CHANGE: Define NUM_PDM_MICS renamed to XUA_NUM_PDM_MICS + * CHANGE: Define NO_USB renamed to XUA_USB_EN 0.1.2 ----- diff --git a/examples/AN00248_xua_example_pdm_mics/src/xua_conf.h b/examples/AN00248_xua_example_pdm_mics/src/xua_conf.h index 371ff2e3..8cdf256e 100644 --- a/examples/AN00248_xua_example_pdm_mics/src/xua_conf.h +++ b/examples/AN00248_xua_example_pdm_mics/src/xua_conf.h @@ -14,7 +14,7 @@ #define EXCLUDE_USB_AUDIO_MAIN -#define NUM_PDM_MICS 8 +#define XUA_NUM_PDM_MICS 8 #define VENDOR_STR "XMOS" #define VENDOR_ID 0x20B1 #define PRODUCT_STR_A2 "XUA PDM Example" diff --git a/lib_xua/api/xua_audiohub.h b/lib_xua/api/xua_audiohub.h index 3aab1923..db7e8d94 100644 --- a/lib_xua/api/xua_audiohub.h +++ b/lib_xua/api/xua_audiohub.h @@ -52,7 +52,7 @@ void XUA_AudioHub(chanend ?c_aud, #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , server interface i_dfu ?dfuInterface #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) , chanend c_pdm_in #endif ); diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 45020920..969336a5 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -278,15 +278,15 @@ /** * @brief Number of PDM microphones in the design. Default: None */ -#ifndef NUM_PDM_MICS -#define NUM_PDM_MICS (0) +#ifndef XUA_NUM_PDM_MICS +#define XUA_NUM_PDM_MICS (0) #endif /** * @brief PDM Microphone first channel index, defines which channels microphones will be input on. * Note, indexed from 0. * - * Default: 0 (i.e. channels [0:NUM_PDM_MICS-1]) + * Default: 0 (i.e. channels [0:XUA_NUM_PDM_MICS-1]) * */ #ifndef PDM_MIC_INDEX #define PDM_MIC_INDEX (0) diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index 00e4c819..b851e532 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -29,7 +29,7 @@ #endif #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) #include "xua_pdm_mic.h" #endif @@ -45,7 +45,7 @@ static unsigned samplesOut[MAX(NUM_USB_CHAN_OUT, I2S_CHANS_DAC)]; /* Two buffers for ADC data to allow for DAC and ADC I2S ports being offset */ -#define IN_CHAN_COUNT (I2S_CHANS_ADC + NUM_PDM_MICS + (8*ADAT_RX) + (2*SPDIF_RX)) +#define IN_CHAN_COUNT (I2S_CHANS_ADC + XUA_NUM_PDM_MICS + (8*ADAT_RX) + (2*SPDIF_RX)) static unsigned samplesIn[2][MAX(NUM_USB_CHAN_IN, IN_CHAN_COUNT)]; @@ -215,7 +215,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out #if( (SPDIF_RX==1) || (ADAT_RX == 1)) , chanend c_dig_rx #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) , chanend c_pdm_pcm #endif , buffered _XUA_CLK_DIR port:32 ?p_lrclk, @@ -254,7 +254,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out #endif unsigned audioToUsbRatioCounter = 0; -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) unsigned audioToMicsRatioCounter = 0; #endif @@ -276,18 +276,18 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out #endif /* (AUD_TO_USB_RATIO > 1) */ -#if ((DEBUG_MIC_ARRAY == 1) && (NUM_PDM_MICS > 0)) +#if ((DEBUG_MIC_ARRAY == 1) && (XUA_NUM_PDM_MICS > 0)) /* Get initial samples from PDM->PCM converter to avoid stalling the decimators */ c_pdm_pcm <: 1; master { #pragma loop unroll - for(int i = PDM_MIC_INDEX; i < (NUM_PDM_MICS + PDM_MIC_INDEX); i++) + for(int i = PDM_MIC_INDEX; i < (XUA_NUM_PDM_MICS + PDM_MIC_INDEX); i++) { c_pdm_pcm :> samplesIn[readBuffNo][i]; } } -#endif // ((DEBUG_MIC_ARRAY == 1) && (NUM_PDM_MICS > 0)) +#endif // ((DEBUG_MIC_ARRAY == 1) && (XUA_NUM_PDM_MICS > 0)) UserBufferManagementInit(); @@ -448,7 +448,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */ #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) if ((AUD_TO_MICS_RATIO - 1) == audioToMicsRatioCounter) { /* Get samples from PDM->PCM converter */ @@ -456,7 +456,7 @@ unsigned static AudioHub_MainLoop(chanend ?c_out, chanend ?c_spd_out master { #pragma loop unroll - for(int i = PDM_MIC_INDEX; i < (NUM_PDM_MICS + PDM_MIC_INDEX); i++) + for(int i = PDM_MIC_INDEX; i < (XUA_NUM_PDM_MICS + PDM_MIC_INDEX); i++) { c_pdm_pcm :> samplesIn[readBuffNo][i]; } @@ -672,7 +672,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , server interface i_dfu ?dfuInterface #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) , chanend c_pdm_in #endif ) @@ -873,7 +873,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, outuint(c_spdif_out, mClk); #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) /* Send decimation factor to PDM task(s) */ c_pdm_in <: curSamFreq / AUD_TO_MICS_RATIO; #endif @@ -906,7 +906,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, #if (ADAT_RX == 1) || (SPDIF_RX == 1) , c_dig_rx #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) , c_pdm_in #endif , p_lrclk, p_bclk, p_i2s_dac, p_i2s_adc); @@ -959,7 +959,7 @@ void XUA_AudioHub(chanend ?c_aud, clock ?clk_audio_mclk, clock ?clk_audio_bclk, #endif /* XUA_USB_EN */ -#if NUM_PDM_MICS > 0 +#if XUA_NUM_PDM_MICS > 0 c_pdm_in <: 0; #endif diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index 5eee75f1..922fa5e2 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -46,7 +46,7 @@ #include "clocking.h" -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) #include "xua_pdm_mic.h" #endif @@ -169,7 +169,7 @@ on tile[MIDI_TILE] : buffered in port:1 p_midi_rx = PORT_MIDI_IN; #endif /*** Clock blocks ***/ -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) clock clk_pdm = on tile[PDM_TILE]: XS1_CLKBLK_1; #endif @@ -185,7 +185,7 @@ on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX; on tile[XUD_TILE] : clock clk_spd_rx = CLKBLK_SPDIF_RX; #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) in port p_pdm_clk = PORT_PDM_CLK; in buffered port:32 p_pdm_mics = PORT_PDM_DATA; @@ -458,7 +458,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , server interface i_dfu ?dfuInterface #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) #if (PDM_TILE == AUDIO_IO_TILE) , streaming chanend c_ds_output[2] #endif @@ -476,7 +476,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, #define c_dig_rx null #endif -#if (NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE) +#if (XUA_NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE) /* Configure clocks ports - sharing mclk port with I2S */ xua_pdm_mic_config(p_mclk_in); #endif @@ -523,13 +523,13 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , dfuInterface #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) , c_pdm_pcm #endif ); } -#if (NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE) +#if (XUA_NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE) xua_pdm_mic(c_ds_output); #endif @@ -613,7 +613,7 @@ int main() #define dfuInterface null #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) chan c_pdm_pcm; streaming chan c_ds_output[2]; #ifdef MIC_PROCESSING_USE_INTERFACE @@ -671,7 +671,7 @@ int main() #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , dfuInterface #endif -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) #if (PDM_TILE == AUDIO_IO_TILE) , c_ds_output[2] #endif @@ -749,7 +749,7 @@ int main() #endif #ifndef PDM_RECORD -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) #if (PDM_TILE != AUDIO_IO_TILE) /* PDM Mics running on a separate to AudioHub */ on stdcore[PDM_TILE]: @@ -764,7 +764,7 @@ int main() #else on stdcore[PDM_TILE].core[0]: xua_pdm_buffer(c_ds_output, c_pdm_pcm); #endif /*MIC_PROCESSING_USE_INTERFACE*/ -#endif /*NUM_PDM_MICS > 0*/ +#endif /*XUA_NUM_PDM_MICS > 0*/ #endif /*PDM_RECORD*/ diff --git a/lib_xua/src/core/pdm_mics/mic_array_conf.h b/lib_xua/src/core/pdm_mics/mic_array_conf.h index 7f61b82d..7f105514 100644 --- a/lib_xua/src/core/pdm_mics/mic_array_conf.h +++ b/lib_xua/src/core/pdm_mics/mic_array_conf.h @@ -9,7 +9,7 @@ #endif #ifndef MIC_ARRAY_NUM_MICS -#define MIC_ARRAY_NUM_MICS (NUM_PDM_MICS) +#define MIC_ARRAY_NUM_MICS (XUA_NUM_PDM_MICS) #endif #endif /* MIC_ARRAY_CONF_H_ */ diff --git a/lib_xua/src/core/pdm_mics/pdm_mic.xc b/lib_xua/src/core/pdm_mics/pdm_mic.xc index 37821d7a..a14c1c9c 100644 --- a/lib_xua/src/core/pdm_mics/pdm_mic.xc +++ b/lib_xua/src/core/pdm_mics/pdm_mic.xc @@ -2,7 +2,7 @@ #include "xua.h" -#if (NUM_PDM_MICS > 0) +#if (XUA_NUM_PDM_MICS > 0) /* This file includes an example integration of lib_array_mic into USB Audio */ @@ -47,7 +47,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio) { unsigned buffer; unsigned samplerate; - int output[MIC_BUFFER_DEPTH][NUM_PDM_MICS]; + int output[MIC_BUFFER_DEPTH][XUA_NUM_PDM_MICS]; #ifdef MIC_PROCESSING_USE_INTERFACE i_mic_process.init(); @@ -55,7 +55,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio) user_pdm_init(); #endif -#if NUM_PDM_MICS > 4 +#if XUA_NUM_PDM_MICS > 4 unsigned decimatorCount = 2; #else unsigned decimatorCount = 1; @@ -152,7 +152,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio) { /* We store an additional buffer so we can reply immediately */ #pragma loop unroll - for(int i = 0; i < NUM_PDM_MICS; i++) + for(int i = 0; i < XUA_NUM_PDM_MICS; i++) { c_audio <: output[micBufferRead][i]; } @@ -172,7 +172,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio) #endif /* Buffer up next mic data */ #pragma loop unroll - for(int i = 0; i < NUM_PDM_MICS; i++) + for(int i = 0; i < XUA_NUM_PDM_MICS; i++) { output[micBufferWrite][i] = current->data[i][0]; } @@ -203,7 +203,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio) user_pdm_process(current); #endif #pragma loop unroll - for(int i = 0; i < NUM_PDM_MICS; i++) + for(int i = 0; i < XUA_NUM_PDM_MICS; i++) { output[micBufferWrite][i] = current->data[i][0]; } @@ -241,7 +241,7 @@ void xua_pdm_mic_config(in port p_pdm_mclk) void xua_pdm_mic(streaming chanend c_ds_output[2]) { streaming chan c_4x_pdm_mic_0; -#if (NUM_PDM_MICS > 4) +#if (XUA_NUM_PDM_MICS > 4) streaming chan c_4x_pdm_mic_1; #else #define c_4x_pdm_mic_1 null @@ -251,7 +251,7 @@ void xua_pdm_mic(streaming chanend c_ds_output[2]) { mic_array_pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1); mic_array_decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output[0], MIC_ARRAY_NO_INTERNAL_CHANS); -#if (NUM_PDM_MICS > 4) +#if (XUA_NUM_PDM_MICS > 4) mic_array_decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output[1], MIC_ARRAY_NO_INTERNAL_CHANS); #endif } diff --git a/lib_xua/src/core/pdm_mics/pdm_mic_user.c b/lib_xua/src/core/pdm_mics/pdm_mic_user.c index 33409e23..f7a35f78 100644 --- a/lib_xua/src/core/pdm_mics/pdm_mic_user.c +++ b/lib_xua/src/core/pdm_mics/pdm_mic_user.c @@ -2,7 +2,7 @@ #include "xua.h" -#if (NUM_PDM_MICS > 0) && !defined(MIC_PROCESSING_USE_INTERFACE) +#if (XUA_NUM_PDM_MICS > 0) && !defined(MIC_PROCESSING_USE_INTERFACE) #include "mic_array_frame.h"