When in sync mode Pll ref pin driving is now via interface to allow flexibility of port/tile

This commit is contained in:
xross
2022-06-21 19:29:07 +01:00
parent ff42c23a6d
commit e6a8527631
6 changed files with 58 additions and 24 deletions

View File

@@ -6,6 +6,7 @@
#if __XC__ #if __XC__
#include "xua.h" #include "xua.h"
#include "clocking.h"
/** USB Audio Buffering Core. /** USB Audio Buffering Core.
* *
@@ -50,7 +51,7 @@ void XUA_Buffer(
#endif #endif
, chanend c_aud , chanend c_aud
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, out port p_sync , client interface sync_if i_sync
#endif #endif
); );
@@ -80,7 +81,7 @@ void XUA_Buffer_Ep(chanend c_aud_out,
, chanend c_buff_ctrl , chanend c_buff_ctrl
#endif #endif
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, out port p_sync , client interface sync_if i_sync
#endif #endif
); );
@@ -94,7 +95,5 @@ void XUA_Buffer_Decouple(chanend c_audio_out
, chanend c_buff_ctrl , chanend c_buff_ctrl
#endif #endif
); );
#endif #endif
#endif #endif

View File

@@ -11,8 +11,6 @@
#include "xua_conf.h" #include "xua_conf.h"
#endif #endif
/* Default tile arrangement */ /* Default tile arrangement */
/** /**
@@ -57,6 +55,13 @@
#define PDM_TILE AUDIO_IO_TILE #define PDM_TILE AUDIO_IO_TILE
#endif #endif
/**
* @brief Location (tile) of reference signal to CS2100. Default: AUDIO_IO_TILE
*/
#ifndef PLL_REF_TILE
#define PLL_REF_TILE AUDIO_IO_TILE
#endif
/** /**
* @brief Disable USB functionalty just leaving AudioHub * @brief Disable USB functionalty just leaving AudioHub
*/ */

View File

@@ -115,7 +115,7 @@ void XUA_Buffer(
#endif #endif
, chanend c_aud , chanend c_aud
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, out port p_sync , client interface sync_if i_sync
#endif #endif
) )
{ {
@@ -150,7 +150,7 @@ void XUA_Buffer(
, c_buff_ctrl , c_buff_ctrl
#endif #endif
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, p_sync , i_sync
#endif #endif
); );
@@ -200,7 +200,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
, chanend c_buff_ctrl , chanend c_buff_ctrl
#endif #endif
#if XUA_SYNCMODE == XUA_SYNCMODE_SYNC #if XUA_SYNCMODE == XUA_SYNCMODE_SYNC
, out port p_sync , client interface sync_if i_sync
#endif #endif
) )
{ {
@@ -510,7 +510,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
/* SOF notification from XUD_Manager() */ /* SOF notification from XUD_Manager() */
case inuint_byref(c_sof, u_tmp): case inuint_byref(c_sof, u_tmp):
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
/* This really could (shoud) be done in decouple. However, for a quick demo this is okay /* This really could (should) be done in decouple. However, for a quick demo this is okay
* Decouple expects a 16:16 number in fixed point stored in the global g_speed */ * Decouple expects a 16:16 number in fixed point stored in the global g_speed */
unsigned usbSpeed; unsigned usbSpeed;
@@ -528,8 +528,8 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
sofCount += 1000; sofCount += 1000;
if (sofCount == framesPerSec) if (sofCount == framesPerSec)
{ {
p_sync <: syncPinVal; /* Port is accessed via interface to allow flexibilty with location */
syncPinVal = ~syncPinVal; i_sync.toggle();
sofCount = 0; sofCount = 0;
} }
#else #else

View File

@@ -7,6 +7,7 @@
#include "xua.h" #include "xua.h"
#include "xua_commands.h" #include "xua_commands.h"
#include "clocking.h"
#if (SPDIF_RX) #if (SPDIF_RX)
#include "spdif.h" #include "spdif.h"
@@ -38,6 +39,24 @@ static int clockValid[NUM_CLOCKS]; /* Store current val
static int clockInt[NUM_CLOCKS]; /* Interupt flag for clocks */ static int clockInt[NUM_CLOCKS]; /* Interupt flag for clocks */
static int clockId[NUM_CLOCKS]; static int clockId[NUM_CLOCKS];
[[combinable]]
void PllRefPinTask(server interface sync_if i_sync, out port p_sync)
{
static unsigned pinVal= 0;
p_sync <: pinVal;
while(1)
{
select
{
case i_sync.toggle():
pinVal = ~pinVal;
p_sync <: pinVal;
break;
}
}
}
#if (SPDIF_RX) || (ADAT_RX) #if (SPDIF_RX) || (ADAT_RX)
static int abs(int x) static int abs(int x)

View File

@@ -1,4 +1,4 @@
// Copyright 2011-2021 XMOS LIMITED. // Copyright 2011-2022 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1. // This Software is subject to the terms of the XMOS Public Licence: Version 1.
#ifndef _CLOCKING_H_ #ifndef _CLOCKING_H_
@@ -16,5 +16,13 @@
interrupts interrupts
*/ */
void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, out port p, chanend c_audio, chanend c_clk_ctl, chanend c_clk_int); void clockGen (streaming chanend ?c_spdif_rx, chanend ?c_adat_rx, out port p, chanend c_audio, chanend c_clk_ctl, chanend c_clk_int);
interface sync_if
{
void toggle();
};
[[combinable]]
void PllRefPinTask(server interface sync_if i_sync, out port p_sync);
#endif #endif

View File

@@ -154,14 +154,9 @@ on stdcore[XUD_TILE] : buffered in port:32 p_adat_rx = PORT_ADAT_IN;
on tile[XUD_TILE] : buffered in port:4 p_spdif_rx = PORT_SPDIF_IN; on tile[XUD_TILE] : buffered in port:4 p_spdif_rx = PORT_SPDIF_IN;
#endif #endif
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (SPDIF_RX) || (ADAT_RX) || (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
/* Reference to external clock multiplier */ /* Reference to external clock multiplier */
on tile[XUD_TILE] : out port p_pll_clk = PORT_PLL_REF; on tile[PLL_REF_TILE] : out port p_pll_ref = PORT_PLL_REF;
#endif
#if (SPDIF_RX) || (ADAT_RX)
/* Reference to external clock multiplier */
on tile[AUDIO_IO_TILE] : out port p_pll_clk = PORT_PLL_REF;
#endif #endif
#ifdef MIDI #ifdef MIDI
@@ -294,7 +289,7 @@ void usb_audio_core(chanend c_mix_out
, chanend ?c_clk_ctl , chanend ?c_clk_ctl
, client interface i_dfu ?dfuInterface , client interface i_dfu ?dfuInterface
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, out port p_sync , client interface sync_if i_sync
#endif #endif
VENDOR_REQUESTS_PARAMS_DEC_ VENDOR_REQUESTS_PARAMS_DEC_
) )
@@ -378,7 +373,7 @@ VENDOR_REQUESTS_PARAMS_DEC_
#endif #endif
, c_mix_out , c_mix_out
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, p_sync , i_sync
#endif #endif
); );
//: //:
@@ -510,7 +505,7 @@ void usb_audio_io(chanend ?c_aud_in,
{ {
thread_speed(); thread_speed();
clockGen(c_spdif_rx, c_adat_rx, p_pll_clk, c_dig_rx, c_clk_ctl, c_clk_int); clockGen(c_spdif_rx, c_adat_rx, p_pll_ref, c_dig_rx, c_clk_ctl, c_clk_int);
} }
#endif #endif
@@ -589,12 +584,20 @@ int main()
#endif #endif
#endif #endif
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
interface sync_if i_sync;
#endif
USER_MAIN_DECLARATIONS USER_MAIN_DECLARATIONS
par par
{ {
USER_MAIN_CORES USER_MAIN_CORES
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
on tile[PLL_REF_TILE]: PllRefPinTask(i_sync, p_pll_ref);
#endif
on tile[XUD_TILE]: on tile[XUD_TILE]:
par par
{ {
@@ -621,7 +624,7 @@ int main()
#endif #endif
, c_clk_int, c_clk_ctl, dfuInterface , c_clk_int, c_clk_ctl, dfuInterface
#if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC) #if (XUA_SYNCMODE == XUA_SYNCMODE_SYNC)
, p_pll_clk , i_sync
#endif #endif
VENDOR_REQUESTS_PARAMS_ VENDOR_REQUESTS_PARAMS_