From 4f0520e12e602cdeb47c7a5690372e529b7a7218 Mon Sep 17 00:00:00 2001 From: xross Date: Fri, 10 Nov 2017 11:18:47 +0000 Subject: [PATCH 1/9] Added basic doc files --- lib_xua/doc/rst/index.rst | 17 +++++++++++++++++ lib_xua/doc/rst/xdoc.conf | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 lib_xua/doc/rst/index.rst create mode 100644 lib_xua/doc/rst/xdoc.conf diff --git a/lib_xua/doc/rst/index.rst b/lib_xua/doc/rst/index.rst new file mode 100644 index 00000000..92c1579e --- /dev/null +++ b/lib_xua/doc/rst/index.rst @@ -0,0 +1,17 @@ + +.. include:: ../../../README.rst + + +XMOS USB Audio +============== + +This document details the XMOS USB Audio Library. This library +enables the development of USB Audio devices on the XMOS xCORE architecture. + +This document describes the structure of the library, its basic use +and resources required. + +This document assumes familiarity with the XMOS xCORE architecture, the +Universal Serial Bus 2.0 Specification (and related specifications), +the XMOS tool chain and XC language. + diff --git a/lib_xua/doc/rst/xdoc.conf b/lib_xua/doc/rst/xdoc.conf new file mode 100644 index 00000000..2cef5f56 --- /dev/null +++ b/lib_xua/doc/rst/xdoc.conf @@ -0,0 +1,2 @@ +XMOSNEWSTYLE = 1 +DOXYGEN_DIRS=../../api \ No newline at end of file From e2f84f77dbfbdff790c7edd0ef381473a38d07b7 Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Wed, 6 Dec 2017 15:40:05 +0000 Subject: [PATCH 2/9] - removed DFU and XUA_DFU flags and unified all the flags using XUA_DFU_EN --- lib_xua/api/xua_conf_default.h | 8 ++++---- lib_xua/src/core/audiohub/xua_audiohub.xc | 2 +- lib_xua/src/core/endpoint0/descriptor_defs.h | 2 +- lib_xua/src/core/endpoint0/xua_endpoint0.c | 18 ++++++++++-------- lib_xua/src/core/flashlib_user.c | 2 +- lib_xua/src/core/main.xc | 4 ++-- lib_xua/src/core/xua_ep0_descriptors.h | 14 +++++++------- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 52a26abd..729ada18 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -412,10 +412,10 @@ * * Default: 1 (Enabled) */ -#if !defined(DFU) -#define DFU (1) -#elif defined(DFU) && (DFU == 0) -#undef DFU +#if !defined(XUA_DFU_EN) +#define XUA_DFU_EN (1) +#elif defined(XUA_DFU_EN) && (XUA_DFU_EN == 0) +#undef XUA_DFU_EN #endif /** diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index aec97f95..cd514f15 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -1379,7 +1379,7 @@ chanend c_dig_rx, curSamRes_DAC = inuint(c_mix_out); } -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) /* Currently no more audio will happen after this point */ if ((curSamFreq / AUD_TO_USB_RATIO) == AUDIO_STOP_FOR_DFU) { diff --git a/lib_xua/src/core/endpoint0/descriptor_defs.h b/lib_xua/src/core/endpoint0/descriptor_defs.h index cdf6f0da..3bc64f4d 100644 --- a/lib_xua/src/core/endpoint0/descriptor_defs.h +++ b/lib_xua/src/core/endpoint0/descriptor_defs.h @@ -44,7 +44,7 @@ enum USBInterfaceNumber #if defined(USB_CONTROL_DESCS) && (USB_CONTROL_DESCS != 0) INTERFACE_NUMBER_MISC_CONTROL, #endif -#if defined(DFU) && (DFU != 0) +#if defined(XUA_DFU_EN) && (XUA_DFU_EN != 0) INTERFACE_NUMBER_DFU, #endif #if defined(IAP) && (IAP != 0) diff --git a/lib_xua/src/core/endpoint0/xua_endpoint0.c b/lib_xua/src/core/endpoint0/xua_endpoint0.c index acdacaf6..61a6f3ae 100755 --- a/lib_xua/src/core/endpoint0/xua_endpoint0.c +++ b/lib_xua/src/core/endpoint0/xua_endpoint0.c @@ -11,6 +11,7 @@ #ifndef NO_USB #include "xud_device.h" /* Standard descriptor requests */ +#include "dfu_types.h" #include "usbaudio20.h" /* Defines from USB Audio 2.0 spec */ #include "xua_ep0_descriptors.h" /* This devices descriptors */ #include "commands.h" @@ -52,8 +53,8 @@ #warning DFU_PID not defined, Using PID_AUDIO_2. This is probably fine! #endif -#if (XUA_DFU == 1) -#include "dfu.h" +#if (XUA_DFU_EN == 1) +#include "xua_dfu.h" #define DFU_IF_NUM INPUT_INTERFACES + OUTPUT_INTERFACES + MIDI_INTERFACES + 1 extern void device_reboot(chanend); #endif @@ -281,7 +282,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, VendorAudioRequestsInit(c_audioControl, c_mix_ctl, c_clk_ctl); #endif -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) /* Check if device has started in DFU mode */ if (DFUReportResetState(null)) { @@ -547,7 +548,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, //unsigned request = (sp.bmRequestType.Recipient ) | (sp.bmRequestType.Type << 5); /* TODO Check on return value retval = */ -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) unsigned DFU_IF = INTERFACE_NUMBER_DFU; /* DFU interface number changes based on which mode we are currently running in */ @@ -587,7 +588,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, * - Audio endpoint request (Audio 1.0 Sampling freq requests are sent to the endpoint) */ if(((interfaceNum == 0) || (interfaceNum == 1) || (interfaceNum == 2)) -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) && !DFU_mode_active #endif ) @@ -639,7 +640,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, if(result == XUD_RES_ERR) { -#ifdef DFU +#if (XUA_DFU_EN == 1) if (!DFU_mode_active) { #endif @@ -750,8 +751,9 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, cfgDesc_Null, sizeof(cfgDesc_Null), (char**)&g_strTable, sizeof(g_strTable)/sizeof(char *), &sp, g_curUsbSpeed); #endif +#if (XUA_DFU_EN == 1) } -#if (XUA_DFU == 1) + else { /* Running in DFU mode - always return same descs for DFU whether HS or FS */ @@ -776,7 +778,7 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl, g_curStreamAlt_Out = 0; g_curStreamAlt_In = 0; -#if (XUA_DFU == 1) +#if (XUA_DFU_EN == 1) if (DFUReportResetState(null)) { if (!DFU_mode_active) diff --git a/lib_xua/src/core/flashlib_user.c b/lib_xua/src/core/flashlib_user.c index e5bed8a1..8db8e08f 100644 --- a/lib_xua/src/core/flashlib_user.c +++ b/lib_xua/src/core/flashlib_user.c @@ -1,5 +1,5 @@ #include "xua.h" -#if (XUD_DFU == 1) +#if (XUA_DFU_EN == 1) #include "uac_hwresources.h" #include #include diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index c3a3d7fd..a69bc01d 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -558,7 +558,7 @@ int main() #define c_clk_ctl null #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) interface i_dfu dfuInterface; #else #define dfuInterface null @@ -583,7 +583,7 @@ int main() { #if (XUD_TILE == 0) /* Check if USB is on the flash tile (tile 0) */ -#ifdef DFU +#if (XUA_DFU_EN == 1) [[distribute]] DFUHandler(dfuInterface, null); #endif diff --git a/lib_xua/src/core/xua_ep0_descriptors.h b/lib_xua/src/core/xua_ep0_descriptors.h index 67adf398..e6b71645 100644 --- a/lib_xua/src/core/xua_ep0_descriptors.h +++ b/lib_xua/src/core/xua_ep0_descriptors.h @@ -60,7 +60,7 @@ typedef struct STR_TABLE_ENTRY(adatClockSourceStr); /* iClockSource for external S/PDIF clock */ #endif #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) STR_TABLE_ENTRY(dfuStr); /* iInterface for DFU interface */ #endif #ifdef USB_CONTROL_DESCS @@ -333,7 +333,7 @@ StringDescTable_t g_strTable = .adatClockSourceStr = APPEND_VENDOR_STR(ADAT Clock), #endif #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) .dfuStr = APPEND_VENDOR_STR(DFU), #endif #ifdef USB_CONTROL_DESCS @@ -517,7 +517,7 @@ unsigned char devQualDesc_Null[] = #define MIDI_LENGTH (0) #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) #define DFU_LENGTH (18) #else #define DFU_LENGTH (0) @@ -739,7 +739,7 @@ typedef struct unsigned char configDesc_Midi[MIDI_LENGTH]; #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) /* DFU descriptors currently handled as a single block */ unsigned char configDesc_DFU[DFU_LENGTH]; #endif @@ -1978,7 +1978,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= }, #endif -#ifdef DFU +#if (XUA_DFU_EN == 1) /* Standard DFU class Interface descriptor */ {0x09, /* 0 bLength : Size of this descriptor, in bytes. (field size 1 bytes) */ 0x04, /* 1 bDescriptorType : INTERFACE descriptor. (field size 1 bytes) */ @@ -2268,7 +2268,7 @@ const unsigned num_freqs_a1 = MAX(3, (0 #define NUM_CONTROL_USB_INTERFACES 0 #endif -#if (DFU == 1) && (FORCE_UAC1_DFU == 1) +#if (XUA_DFU_EN == 1) && (FORCE_UAC1_DFU == 1) #define DFU_INTERFACE_BYTES 18 #define DFU_INTERFACES_A1 1 #else @@ -2741,7 +2741,7 @@ unsigned char cfgDesc_Audio1[] = 0x00, 0x00, /* Unused */ #endif -#if (DFU == 1) && (FORCE_UAC1_DFU == 1) +#if (XUA_DFU_EN == 1) && (FORCE_UAC1_DFU == 1) /* NOTE: By default we turn off DFU in UAC1.0 mode for a better user experiance in Windows */ From e3f89956ad4dc58a9a0f095b2995abfdfd821a35 Mon Sep 17 00:00:00 2001 From: Larry Snizek Date: Mon, 11 Dec 2017 15:53:39 +0000 Subject: [PATCH 3/9] Use a define for USB class of control interface (from sc_usb_audio vf_spk_1.1.2 branch) --- lib_xua/src/core/xua_ep0_descriptors.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_xua/src/core/xua_ep0_descriptors.h b/lib_xua/src/core/xua_ep0_descriptors.h index e6b71645..f619902f 100644 --- a/lib_xua/src/core/xua_ep0_descriptors.h +++ b/lib_xua/src/core/xua_ep0_descriptors.h @@ -1985,7 +1985,7 @@ USB_Config_Descriptor_Audio2_t cfgDesc_Audio2= INTERFACE_NUMBER_DFU, /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ - 0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ + 0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */ 0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */ @@ -2751,7 +2751,7 @@ unsigned char cfgDesc_Audio1[] = (OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + NUM_CONTROL_USB_INTERFACES + 1), /* 2 bInterfaceNumber : Index of this interface. (field size 1 bytes) */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ - 0xFE, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ + 0xFE, /* 5 bInterfaceClass : DFU. (Application Specific) (field size 1 bytes) */ 0x01, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0x01, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ offsetof(StringDescTable_t, dfuStr)/sizeof(char *), /* 8 iInterface */ @@ -2775,7 +2775,7 @@ unsigned char cfgDesc_Audio1[] = (OUTPUT_INTERFACES_A1 + INPUT_INTERFACES_A1 + 1), /* 2 bInterfaceNumber */ 0x00, /* 3 bAlternateSetting : Index of this setting. (field size 1 bytes) */ 0x00, /* 4 bNumEndpoints : 0 endpoints. (field size 1 bytes) */ - 0xFF, /* 5 bInterfaceClass : DFU. (field size 1 bytes) */ + USB_CLASS_VENDOR_SPECIFIC, /* 5 bInterfaceClass : Vendor specific. (field size 1 bytes) */ 0xFF, /* 6 bInterfaceSubclass : (field size 1 bytes) */ 0xFF, /* 7 bInterfaceProtocol : Unused. (field size 1 bytes) */ offsetof(StringDescTable_t, ctrlStr)/sizeof(char *), /* 8 iInterface */ From 96f55476b2bcb04e690876601100427321587100 Mon Sep 17 00:00:00 2001 From: Larry Snizek Date: Mon, 11 Dec 2017 15:55:07 +0000 Subject: [PATCH 4/9] Extra comment --- lib_xua/src/core/pdm_mics/pdm_mic.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_xua/src/core/pdm_mics/pdm_mic.xc b/lib_xua/src/core/pdm_mics/pdm_mic.xc index 1b55b333..9b7c56c0 100644 --- a/lib_xua/src/core/pdm_mics/pdm_mic.xc +++ b/lib_xua/src/core/pdm_mics/pdm_mic.xc @@ -69,7 +69,7 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio) mic_array_frame_time_domain * unsafe current; mic_array_decimator_config_t dc[2]; - /* Get initial sample-rate and compute decimation factor */ + /* Get initial sample-rate to run this thread at and compute decimation factor */ c_audio :> samplerate; unsigned decimationfactor = 96000/samplerate; From 2f9a89d7164ec4d28c4395d4c407784b2aff4f36 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Wed, 3 Jan 2018 16:09:11 +0000 Subject: [PATCH 5/9] Fixed BCD_DEVICE_N def --- lib_xua/api/xua_conf_default.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 729ada18..1d5103ca 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -521,21 +521,21 @@ * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. */ #ifndef BCD_DEVICE_J -#define BCD_DEVICE_J 1 +#define BCD_DEVICE_J (1) #endif /** * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. */ #ifndef BCD_DEVICE_M -#define BCD_DEVICE_M 0 +#define BCD_DEVICE_M (0) #endif /** * @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number. */ #ifndef BCD_DEVICE_N -#define BCD_DEVICE_N +#define BCD_DEVICE_N (0) #endif /** From e322010cf1cfbb5ab5b3c70956d976bfd0a8bda2 Mon Sep 17 00:00:00 2001 From: xross Date: Thu, 4 Jan 2018 09:54:04 +0000 Subject: [PATCH 6/9] SPDIF_TX and XUA_DFU_EN changes for build --- lib_xua/api/xua_audiohub.h | 2 +- lib_xua/api/xua_conf_default.h | 9 ++------ lib_xua/src/core/audiohub/xua_audiohub.xc | 28 +++++++++++------------ lib_xua/src/core/main.xc | 16 ++++++------- 4 files changed, 25 insertions(+), 30 deletions(-) diff --git a/lib_xua/api/xua_audiohub.h b/lib_xua/api/xua_audiohub.h index f3f512ae..cb2c2498 100644 --- a/lib_xua/api/xua_audiohub.h +++ b/lib_xua/api/xua_audiohub.h @@ -22,7 +22,7 @@ * CODEC configuration functions. */ void XUA_AudioHub(chanend ?c_aud -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) , chanend c_spdif_tx #endif #if(defined(SPDIF_RX) || defined(ADAT_RX)) diff --git a/lib_xua/api/xua_conf_default.h b/lib_xua/api/xua_conf_default.h index 1d5103ca..e6745f95 100644 --- a/lib_xua/api/xua_conf_default.h +++ b/lib_xua/api/xua_conf_default.h @@ -299,13 +299,8 @@ /** * @brief Enables SPDIF Tx. Default: 0 (Disabled) */ -#ifndef SPDIF_TX -#define SPDIF_TX (0) -#endif - -/* Tidy up old SPDIF usage */ -#if defined(SPDIF_TX) && (SPDIF_TX == 0) -#undef SPDIF_TX +#ifndef XUA_SPDIF_TX_EN +#define XUA_SPDIF_TX_EN (0) #endif /** diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index cd514f15..08922844 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -1,6 +1,6 @@ /** - * @file audio.xc - * @brief XMOS L1/L2 USB 2,0 Audio Reference Design. Audio Functions. + * @file xua_audiohub.xc + * @brief XMOS USB 2.0 Audio Reference Design. Audio Functions. * @author Ross Owen, XMOS Semiconductor Ltd * * This thread handles I2S and pars an additional SPDIF Tx thread. It forwards samples to the SPDIF Tx thread. @@ -19,7 +19,7 @@ #include "audioports.h" #include "audiohw.h" #include "mic_array_conf.h" -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN) #include "SpdifTransmit.h" #endif #ifdef ADAT_TX @@ -103,7 +103,7 @@ unsigned dsdMode = DSD_MODE_OFF; extern unsafe port p_mclk_in; extern in port p_mclk_in2; -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN) extern buffered out port:32 p_spdif_tx; #endif @@ -816,7 +816,7 @@ unsigned static deliver(chanend ?c_out, chanend ?c_spd_out /* Request digital data (with prefill) */ outuint(c_dig_rx, 0); #endif -#if defined(SPDIF_TX) && (NUM_USB_CHAN_OUT > 0) +#if (XUA_SPDIF_TX_EN) && (NUM_USB_CHAN_OUT > 0) outuint(c_spd_out, samplesOut[SPDIF_TX_INDEX]); /* Forward sample to S/PDIF Tx thread */ unsigned sample = samplesOut[SPDIF_TX_INDEX + 1]; outuint(c_spd_out, sample); /* Forward sample to S/PDIF Tx thread */ @@ -1023,7 +1023,7 @@ unsigned static deliver(chanend ?c_out, chanend ?c_spd_out return 0; } -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) void SpdifTxWrapper(chanend c_spdif_tx) { unsigned portId; @@ -1102,7 +1102,7 @@ static void dummy_deliver(chanend ?c_out, unsigned &command) } void XUA_AudioHub(chanend ?c_mix_out -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) chanend c_spdif_out, #endif #if (defined(ADAT_RX) || defined(SPDIF_RX)) @@ -1116,7 +1116,7 @@ chanend c_dig_rx, #endif ) { -#if defined (SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE) chan c_spdif_out; #endif #ifdef ADAT_TX @@ -1155,12 +1155,12 @@ chanend c_dig_rx, configure_clock_src(clk_mst_spd, p_mclk_in); configure_out_port_no_ready(p_adat_tx, clk_mst_spd, 0); set_clock_fall_delay(clk_mst_spd, 7); -#ifndef SPDIF_TX +#if (XUA_SPDIF_TX_EN == 0) start_clock(clk_mst_spd); #endif #endif /* Configure ADAT/SPDIF tx ports */ -#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE) SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, p_mclk_in); #endif @@ -1307,7 +1307,7 @@ chanend c_dig_rx, par { -#if defined(SPDIF_TX) && (SPDIF_TX_TILE == AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE) { set_thread_fast_mode_on(); SpdifTransmit(p_spdif_tx, c_spdif_out); @@ -1321,7 +1321,7 @@ chanend c_dig_rx, } #endif { -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN) /* Communicate master clock and sample freq to S/PDIF thread */ outuint(c_spdif_out, curSamFreq); outuint(c_spdif_out, mClk); @@ -1346,7 +1346,7 @@ chanend c_dig_rx, outuint(c_adat_out, adatSmuxMode); #endif command = deliver(c_mix_out -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN) , c_spdif_out #else , null @@ -1412,7 +1412,7 @@ chanend c_dig_rx, #endif /* NO_USB */ -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN) /* Notify S/PDIF task of impending new freq... */ outct(c_spdif_out, XS1_CT_END); #endif diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index a69bc01d..d2e01db6 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -1,5 +1,5 @@ -#include "xua.h" /* Device specific defines */ +#include "xua.h" /* Device specific defines */ #ifndef EXCLUDE_USB_AUDIO_MAIN /** @@ -137,7 +137,7 @@ unsafe on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT; #endif -#ifdef SPDIF_TX +#if (XUA_SPDIF_TX_EN == 1) on tile[SPDIF_TX_TILE] : buffered out port:32 p_spdif_tx = PORT_SPDIF_OUT; #endif @@ -423,7 +423,7 @@ VENDOR_REQUESTS_PARAMS_DEC_ #endif /* NO_USB */ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) chanend c_spdif_tx, #endif #ifdef MIXER @@ -433,7 +433,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, chanend ?c_adat_rx, chanend ?c_clk_ctl, chanend ?c_clk_int -#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) +#if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , server interface i_dfu ?dfuInterface #endif #if (NUM_PDM_MICS > 0) @@ -469,7 +469,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, #define AUDIO_CHANNEL c_aud_in #endif XUA_AudioHub(AUDIO_CHANNEL -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) c_spdif_tx, #endif #if defined(SPDIF_RX) || defined(ADAT_RX) @@ -545,7 +545,7 @@ int main() #define c_adat_rx null #endif -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) chan c_spdif_tx; #endif @@ -617,7 +617,7 @@ int main() p_mclk_in = p_mclk_in_; } usb_audio_io(c_mix_out, c_adc -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) , c_spdif_tx #endif #ifdef MIXER @@ -633,7 +633,7 @@ int main() ); } -#if defined(SPDIF_TX) && (SPDIF_TX_TILE != AUDIO_IO_TILE) +#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) on tile[SPDIF_TX_TILE]: { thread_speed(); From 3b24c5ed137230ac11534e6c162e833c38319399 Mon Sep 17 00:00:00 2001 From: xross Date: Thu, 4 Jan 2018 12:38:42 +0000 Subject: [PATCH 7/9] Build fixes relating to SPDIF --- lib_xua/src/core/audiohub/xua_audiohub.xc | 12 +++++++++--- lib_xua/src/core/main.xc | 11 +++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index 08922844..0cc8d048 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -113,9 +113,12 @@ extern buffered out port:32 p_adat_tx; extern clock clk_audio_mclk; extern clock clk_audio_bclk; -extern clock clk_mst_spd; -extern void device_reboot(void); +#if XUA_SPDIF_TX_EN +extern clock clk_mst_spd; +#endif + +//extern void device_reboot(void); #define MAX_DIVIDE_48 (MCLK_48/MIN_FREQ_48/64) #define MAX_DIVIDE_44 (MCLK_44/MIN_FREQ_44/64) @@ -1161,7 +1164,10 @@ chanend c_dig_rx, #endif /* Configure ADAT/SPDIF tx ports */ #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE == AUDIO_IO_TILE) - SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, p_mclk_in); + unsafe + { + SpdifTransmitPortConfig(p_spdif_tx, clk_mst_spd, (port)p_mclk_in); + } #endif /* Perform required CODEC/ADC/DAC initialisation */ diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index d2e01db6..9746039a 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -177,7 +177,7 @@ clock clk_pdm = on tile[PDM_TILE]: on tile[MIDI_TILE] : clock clk_midi = CLKBLK_MIDI; #endif -#if defined(SPDIF_TX) || defined(ADAT_TX) +#if XUA_SPDIF_TX_EN || defined(ADAT_TX) on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX; #endif @@ -370,8 +370,11 @@ VENDOR_REQUESTS_PARAMS_DEC_ asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x)); #endif //:buffer - XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO], /* Audio Out*/ + XUA_Buffer(c_xud_out[ENDPOINT_NUMBER_OUT_AUDIO],/* Audio Out*/ +#if (NUM_USB_CHAN_IN > 0) + c_xud_in[ENDPOINT_NUMBER_IN_AUDIO], /* Audio In */ +#endif #if (NUM_USB_CHAN_IN == 0) || defined(UAC_FORCE_FEEDBACK_EP) c_xud_in[ENDPOINT_NUMBER_IN_FEEDBACK], /* Audio FB */ #endif @@ -470,10 +473,10 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, #endif XUA_AudioHub(AUDIO_CHANNEL #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) - c_spdif_tx, + , c_spdif_tx #endif #if defined(SPDIF_RX) || defined(ADAT_RX) - c_dig_rx, + , c_dig_rx, #endif #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , dfuInterface From ca3644ca0926d920338c022729fa879aa6746b7a Mon Sep 17 00:00:00 2001 From: xross Date: Thu, 4 Jan 2018 12:40:01 +0000 Subject: [PATCH 8/9] Syntax error in main with digital RX --- lib_xua/src/core/main.xc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_xua/src/core/main.xc b/lib_xua/src/core/main.xc index 9746039a..ed1a0763 100755 --- a/lib_xua/src/core/main.xc +++ b/lib_xua/src/core/main.xc @@ -476,7 +476,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc, , c_spdif_tx #endif #if defined(SPDIF_RX) || defined(ADAT_RX) - , c_dig_rx, + , c_dig_rx #endif #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) , dfuInterface From 94432b4a0369c3646bc7c699d0f2db6ed0e6eea4 Mon Sep 17 00:00:00 2001 From: xross Date: Thu, 4 Jan 2018 16:02:20 +0000 Subject: [PATCH 9/9] ADAT related build fixes --- lib_xua/src/core/audiohub/xua_audiohub.xc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib_xua/src/core/audiohub/xua_audiohub.xc b/lib_xua/src/core/audiohub/xua_audiohub.xc index 0cc8d048..b596d336 100755 --- a/lib_xua/src/core/audiohub/xua_audiohub.xc +++ b/lib_xua/src/core/audiohub/xua_audiohub.xc @@ -114,7 +114,7 @@ extern buffered out port:32 p_adat_tx; extern clock clk_audio_mclk; extern clock clk_audio_bclk; -#if XUA_SPDIF_TX_EN +#if XUA_SPDIF_TX_EN || defined(ADAT_TX) extern clock clk_mst_spd; #endif @@ -1106,16 +1106,16 @@ static void dummy_deliver(chanend ?c_out, unsigned &command) void XUA_AudioHub(chanend ?c_mix_out #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) -chanend c_spdif_out, + , chanend c_spdif_out #endif #if (defined(ADAT_RX) || defined(SPDIF_RX)) -chanend c_dig_rx, + , chanend c_dig_rx #endif #if (XUD_TILE != 0) && (AUDIO_IO_TILE == 0) && (XUA_DFU_EN == 1) -, server interface i_dfu ?dfuInterface + , server interface i_dfu ?dfuInterface #endif #if (NUM_PDM_MICS > 0) -, chanend c_pdm_in + , chanend c_pdm_in #endif ) { @@ -1155,7 +1155,10 @@ chanend c_dig_rx, #endif #ifdef ADAT_TX /* Share SPDIF clk blk */ - configure_clock_src(clk_mst_spd, p_mclk_in); + unsafe + { + configure_clock_src(clk_mst_spd, (port)p_mclk_in); + } configure_out_port_no_ready(p_adat_tx, clk_mst_spd, 0); set_clock_fall_delay(clk_mst_spd, 7); #if (XUA_SPDIF_TX_EN == 0)