From a5922ce3eade014bc57e823607f92aebe9f3f376 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 6 Jun 2023 19:13:25 +0100 Subject: [PATCH] Fixed issue with when XUA_I2S_N_BITS !=32 and CODEC_MASTER == 1 --- lib_xua/src/core/audiohub/audiohub_initport.xc | 4 ++-- tests/test_i2s_loopback/main.xc | 1 - tests/test_i2s_loopback/simulation.xc | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_xua/src/core/audiohub/audiohub_initport.xc b/lib_xua/src/core/audiohub/audiohub_initport.xc index 1636e069..61ab6324 100644 --- a/lib_xua/src/core/audiohub/audiohub_initport.xc +++ b/lib_xua/src/core/audiohub/audiohub_initport.xc @@ -107,7 +107,7 @@ void InitPorts_slave(buffered _XUA_CLK_DIR port:32 p_lrclk, buffered _XUA_CLK_DI p_lrclk when pinseq(0) :> void @ tmp; #endif - tmp += (I2S_CHANS_PER_FRAME * XUA_I2S_N_BITS) - XUA_I2S_N_BITS + 1 ; + tmp += ((I2S_CHANS_PER_FRAME * XUA_I2S_N_BITS) - XUA_I2S_N_BITS + 1) ; /* E.g. 2 * 32 - 32 + 1 = 33 for stereo */ /* E.g. 8 * 32 - 32 + 1 = 225 for 8 chan TDM */ @@ -118,7 +118,7 @@ void InitPorts_slave(buffered _XUA_CLK_DIR port:32 p_lrclk, buffered _XUA_CLK_DI if(XUA_I2S_N_BITS == 32) p_i2s_dac[i] @ tmp <: 0; else - partout_timed(p_i2s_dac[i], XUA_I2S_N_BITS, 0, tmp-1); + partout_timed(p_i2s_dac[i], XUA_I2S_N_BITS, 0, tmp); } #endif diff --git a/tests/test_i2s_loopback/main.xc b/tests/test_i2s_loopback/main.xc index b0043f27..de36129f 100644 --- a/tests/test_i2s_loopback/main.xc +++ b/tests/test_i2s_loopback/main.xc @@ -9,7 +9,6 @@ #define DEBUG_UNIT MAIN #include "debug_print.h" - /* Port declarations. Note, the defines come from the xn file */ #if I2S_WIRES_DAC > 0 on tile[AUDIO_IO_TILE] : buffered out port:32 p_i2s_dac[I2S_WIRES_DAC] = diff --git a/tests/test_i2s_loopback/simulation.xc b/tests/test_i2s_loopback/simulation.xc index 44513a04..42ee472f 100644 --- a/tests/test_i2s_loopback/simulation.xc +++ b/tests/test_i2s_loopback/simulation.xc @@ -41,7 +41,7 @@ extern out port p_lrclk_gen; extern clock clk_audio_lrclk_gen; void slave_mode_clk_setup(const unsigned samFreq, const unsigned chans_per_frame){ - const unsigned data_bits = 32; + const unsigned data_bits = XUA_I2S_N_BITS; const unsigned mclk_freq = 24576000; const unsigned mclk_bclk_ratio = mclk_freq / (chans_per_frame * samFreq * data_bits);