Fixup CODEC_MASTER usage

This commit is contained in:
xross
2018-01-17 14:06:49 +00:00
parent 0d98f1ad9a
commit 55a9f03719
7 changed files with 24 additions and 27 deletions

View File

@@ -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.
*

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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();

View File

@@ -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;