diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index a6a03e58..1c4dbf47 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -438,10 +438,6 @@ #define CODEC_MASTER (0) #endif -#if defined(CODEC_MASTER) && (CODEC_MASTER == 0) -#undef CODEC_MASTER -#endif - /** * @brief Vendor String used by the device. This is also pre-pended to various strings used by the design. * diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index 73999e7f..f6df87b1 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -88,12 +88,12 @@ extern buffered in port:32 p_i2s_adc[I2S_WIRES_ADC]; #endif /* I2S LR/Bit clock I/O */ -#ifndef CODEC_MASTER -extern buffered out port:32 p_lrclk; -extern buffered out port:32 p_bclk; -#else +#if CODEC_MASTER extern buffered in port:32 p_lrclk; extern buffered in port:32 p_bclk; +#else +extern buffered out port:32 p_lrclk; +extern buffered out port:32 p_bclk; #endif unsigned dsdMode = DSD_MODE_OFF; @@ -341,7 +341,7 @@ static inline int DoDsdDopCheck(unsigned &dsdMode, int &dsdCount, unsigned curSa } -#ifndef CODEC_MASTER +#if !CODEC_MASTER static inline void InitPorts_master(unsigned divide) { unsigned tmp; @@ -399,7 +399,7 @@ static inline void InitPorts_master(unsigned divide) } #endif -#ifdef CODEC_MASTER +#if CODEC_MASTER static inline void InitPorts_slave(unsigned divide) { unsigned tmp; @@ -440,7 +440,7 @@ static inline void InitPorts_slave(unsigned divide) -#ifndef CODEC_MASTER +#if (CODEC_MASTER == 0) #pragma unsafe arrays unsigned static deliver_master(chanend ?c_out, chanend ?c_spd_out #ifdef ADAT_TX @@ -581,6 +581,7 @@ unsigned static deliver_master(chanend ?c_out, chanend ?c_spd_out asm volatile("in %0, res[%1]" : "=r"(sample) : "r"(p_i2s_adc[index++])); sample = bitrev(sample); 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) == audioToUsbRatioCounter) { @@ -809,10 +810,10 @@ unsigned static deliver_master(chanend ?c_out, chanend ?c_spd_out #pragma xta endpoint "deliver_return" return 0; } -#endif //ndef CODEC_MASTER +#endif -#ifdef CODEC_MASTER +#if (CODEC_MASTER == 1) /* I2S delivery thread */ #pragma unsafe arrays diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index ed1a0763..09a985c4 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -114,13 +114,12 @@ on tile[AUDIO_IO_TILE] : buffered in port:32 p_i2s_adc[I2S_WIRES_ADC] = #endif - -#ifndef CODEC_MASTER -on tile[AUDIO_IO_TILE] : buffered out port:32 p_lrclk = PORT_I2S_LRCLK; -on tile[AUDIO_IO_TILE] : buffered out port:32 p_bclk = PORT_I2S_BCLK; -#else +#if CODEC_MASTER on tile[AUDIO_IO_TILE] : buffered in port:32 p_lrclk = PORT_I2S_LRCLK; on tile[AUDIO_IO_TILE] : buffered in port:32 p_bclk = PORT_I2S_BCLK; +#else +on tile[AUDIO_IO_TILE] : buffered out port:32 p_lrclk = PORT_I2S_LRCLK; +on tile[AUDIO_IO_TILE] : buffered out port:32 p_bclk = PORT_I2S_BCLK; #endif /* Note, declared unsafe as sometimes we want to share this port diff --git a/lib_xua/src/core/ports/audioports.h b/lib_xua/src/core/ports/audioports.h index 1f970a85..66a0c400 100644 --- a/lib_xua/src/core/ports/audioports.h +++ b/lib_xua/src/core/ports/audioports.h @@ -18,7 +18,7 @@ void ConfigAudioPorts( #endif #if (I2S_CHANS_DAC != 0) || (I2S_CHANS_ADC != 0) -#ifndef CODEC_MASTER +#if (CODEC_MASTER == 0) buffered out port:32 ?p_lrclk, buffered out port:32 p_bclk, #else @@ -41,7 +41,7 @@ void ConfigAudioPorts( #endif #if (I2S_CHANS_DAC != 0) || (I2S_CHANS_ADC != 0) -#ifndef CODEC_MASTER +#if (CODEC_MASTER == 0) port p_lrclk, port p_bclk, #else @@ -66,7 +66,7 @@ void ConfigAudioPortsWrapper( #endif #if (I2S_CHANS_DAC != 0) || (I2S_CHANS_ADC != 0) -#ifndef CODEC_MASTER +#if (CODEC_MASTER == 0) buffered out port:32 ?p_lrclk, buffered out port:32 p_bclk, #else diff --git a/lib_xua/src/core/ports/audioports.xc b/lib_xua/src/core/ports/audioports.xc index 7b4c5a1a..914290d5 100644 --- a/lib_xua/src/core/ports/audioports.xc +++ b/lib_xua/src/core/ports/audioports.xc @@ -22,7 +22,7 @@ void ConfigAudioPorts( #endif #if (I2S_CHANS_DAC != 0) || (I2S_CHANS_ADC != 0) -#if !defined(CODEC_MASTER) +#if (CODEC_MASTER == 0) buffered out port:32 ?p_lrclk, buffered out port:32 p_bclk, #else @@ -32,7 +32,7 @@ void ConfigAudioPorts( #endif unsigned int divide, unsigned curSamFreq) { -#if !defined(CODEC_MASTER) +#if (CODEC_MASTER == 0) /* Note this call to stop_clock() will pause forever if the port clocking the clock-block is not low. * deliver() should return with this being the case */ stop_clock(clk_audio_bclk); diff --git a/tests/i2s_loopback/main.xc b/tests/i2s_loopback/main.xc index 73e91448..1b9c0fc2 100644 --- a/tests/i2s_loopback/main.xc +++ b/tests/i2s_loopback/main.xc @@ -69,7 +69,7 @@ on tile[AUDIO_IO_TILE] : buffered in port:32 p_i2s_adc[I2S_WIRES_ADC] = #endif -#if defined(CODEC_MASTER) && (CODEC_MASTER != 0) +#if CODEC_MASTER buffered in port:32 p_lrclk = PORT_I2S_LRCLK; buffered in port:32 p_bclk = PORT_I2S_BCLK; #else @@ -200,13 +200,14 @@ out port p_mclk_gen = on tile[AUDIO_IO_TILE] : XS1_PORT_1A; clock clk_audio_mclk_gen = on tile[AUDIO_IO_TILE] : XS1_CLKBLK_3; void master_mode_clk_setup(void); -#ifdef CODEC_MASTER +#if CODEC_MASTER out port p_bclk_gen = on tile[AUDIO_IO_TILE] : XS1_PORT_1B; clock clk_audio_bclk_gen = on tile[AUDIO_IO_TILE] : XS1_CLKBLK_4; out port p_lrclk_gen = on tile[AUDIO_IO_TILE] : XS1_PORT_1C; clock clk_audio_lrclk_gen = on tile[AUDIO_IO_TILE] : XS1_CLKBLK_5; void slave_mode_clk_setup(const unsigned samFreq, const unsigned chans_per_frame); #endif + #endif #if I2S_MODE_TDM @@ -233,7 +234,7 @@ int main(void) generator(c_checker, c_out); checker(c_checker, 0); #ifdef SIMULATION -#ifdef CODEC_MASTER +#if CODEC_MASTER slave_mode_clk_setup(DEFAULT_FREQ, (i2s_tdm_mode != 0) ? 8 : 2); #else master_mode_clk_setup(); diff --git a/tests/i2s_loopback/simulation.xc b/tests/i2s_loopback/simulation.xc index 2d03c0a3..0bfc5f1c 100644 --- a/tests/i2s_loopback/simulation.xc +++ b/tests/i2s_loopback/simulation.xc @@ -33,7 +33,7 @@ void master_mode_clk_setup(void) } -#ifdef CODEC_MASTER +#if CODEC_MASTER extern out port p_bclk_gen; extern clock clk_audio_bclk_gen; extern out port p_lrclk_gen;