#Load environment variables
source /Applications/XMOS_xTIMEcomposer_Community_14.2.3/SetEnv.sh
#Flash with xflash
/Applications/XMOS_xTIMEcomposer_Community_14.2.3/bin/xflash --spi-spec AT25S.spec 8SoundsUSB_Firmware_500MHz_3.0.2.xe
You can get the code by agreeing to the licence on the XMOS site and make few changes to the sw_usb_audio-[sw]_6.15.2rc1 reference firmware. Start from the app_usb_aud_l2 project and change the .xn file, customdefines.h and duplicate the i2c calls in audiohw.xc to configure both codecs.
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Device</Type>
<Name>XS1-L16A-128-QF124-C10 Device</Name>
<Declarations>
<Declaration>tileref tile[2]</Declaration>
</Declarations>
<Nodes>
<!-- Warning, This will cause C8 devices out of specs. Should not be problematic -->
<!-- Use 400MHz if you prefer -->
<Node Id="0" Type="XS1-L8A-64" oscillator="13Mhz" systemfrequency="500Mhz" referencefrequency="100MHz">
<Core Number="0" Reference="tile[0]">
<!-- SPI Ports -->
<Port Location="XS1_PORT_1A" Name="PORT_SPI_MISO"/>
<Port Location="XS1_PORT_1B" Name="PORT_SPI_SS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SPI_CLK"/>
<Port Location="XS1_PORT_1D" Name="PORT_SPI_MOSI"/>
<!-- Standard USB Audio Ports -->
<Port Location="XS1_PORT_1L" Name="PORT_MCLK_IN2"/>
<Port Location="XS1_PORT_1M" Name="PORT_USB_RESET"/>
<!--<Port Location="XS1_PORT_4E" Name="PORT_PLL_CLK"/> -->
<Port Location="XS1_PORT_32A" Name="PORT_MCLK_COUNT"/>
</Core>
<Boot>
<Source Location="SPI:bootFlash"/>
<Bootee NodeId="1"/>
</Boot>
</Node>
<!-- Warning, This will cause C8 devices out of specs. Should not be problematic -->
<!-- Use 400MHz if you prefer -->
<Node Id="1" Type="XS1-L8A-64" oscillator="13Mhz" systemfrequency="500MHz" referencefrequency="100MHz">
<Boot>
<Source Location="XMOSLINK"/>
</Boot>
<Core Number="0" Reference="tile[1]">
<!-- Standard USB Audio Ports -->
<Port Location="XS1_PORT_1A" Name="PORT_I2S_ADC3"/>
<Port Location="XS1_PORT_1B" Name="PORT_I2S_ADC2"/>
<Port Location="XS1_PORT_1C" Name="PORT_I2C_SDA"/>
<Port Location="XS1_PORT_1D" Name="PORT_I2C_SCL"/>
<Port Location="XS1_PORT_1E" Name="PORT_I2S_LRCLK"/>
<Port Location="XS1_PORT_1I" Name="PORT_I2S_BCLK"/>
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC0"/>
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC1"/>
<Port Location="XS1_PORT_1L" Name="PORT_MCLK_IN"/>
<Port Location="XS1_PORT_1M" Name="PORT_I2S_DAC0"/>
<Port Location="XS1_PORT_1N" Name="PORT_I2S_DAC1"/>
<Port Location="XS1_PORT_1O" Name="PORT_MIDI_OUT"/>
<Port Location="XS1_PORT_1P" Name="PORT_MIDI_IN"/>
<Port Location="XS1_PORT_4A" Name="PORT_AUD_CFG"/>
<Port Location="XS1_PORT_4E" Name="PORT_PLL_REF"/>
<Port Location="XS1_PORT_4F" Name="PORT_GPIO"/>
<Port Location="XS1_PORT_8B" Name="PORT_LED"/>
</Core>
</Node>
</Nodes>
<Links>
<Link Encoding="5wire" Delays="0,1">
<LinkEndpoint NodeId="0" Link="4"/>
<LinkEndpoint NodeId="1" Link="7"/>
</Link>
<Link Encoding="5wire" Delays="0,1">
<LinkEndpoint NodeId="0" Link="5"/>
<LinkEndpoint NodeId="1" Link="6"/>
</Link>
<Link Encoding="5wire" Delays="0,1">
<LinkEndpoint NodeId="0" Link="6"/>
<LinkEndpoint NodeId="1" Link="5"/>
</Link>
<Link Encoding="5wire" Delays="0,1">
<LinkEndpoint NodeId="0" Link="7"/>
<LinkEndpoint NodeId="1" Link="4"/>
</Link>
<Link Encoding="2wire" Delays="4,4" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="X0LA" />
<LinkEndpoint RoutingId="0x8000" Chanend="1" />
</Link>
</Links>
<Packages>
<Package ID="0" Type="XS1-LnA-128-QF124">
<Component NodeId="0" InPackage="0"/>
<Component NodeId="1" InPackage="1"/>
</Package>
</Packages>
<ExternalDevices>
<Device NodeId="0" Core="0" Class="SPIFlash" Name="bootFlash" Type="AT25DF041A">
<Attribute Name="PORT_SPI_MISO" Value="PORT_SPI_MISO"/>
<Attribute Name="PORT_SPI_SS" Value="PORT_SPI_SS"/>
<Attribute Name="PORT_SPI_CLK" Value="PORT_SPI_CLK"/>
<Attribute Name="PORT_SPI_MOSI" Value="PORT_SPI_MOSI"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
<JTAGDevice NodeId="1"/>
</JTAGChain>
</Network>
#include "user_main.h"
/* Audio I/O is on tile 1 */
#define AUDIO_IO_TILE 1
/* Audio Class Version */
#ifndef AUDIO_CLASS
#define AUDIO_CLASS (2)
#endif
/* When connected to a full-speed hub, run in USB Audio Class 2.0 mode */
#ifndef FULL_SPEED_AUDIO_2
#if (AUDIO_CLASS == 2)
#define FULL_SPEED_AUDIO_2 (1)
#else
#define FULL_SPEED_AUDIO_2 (0)
#endif
#endif
/* Defines relating to channel count and channel arrangement (0 for disable) */
/* Number of USB streaming channels */
#ifndef NUM_USB_CHAN_IN
#define NUM_USB_CHAN_IN (8) /* Device to Host */
#endif
#ifndef NUM_USB_CHAN_OUT
#define NUM_USB_CHAN_OUT (4) /* Host to Device */
#endif
/* S/PDIF Tx enabled by default */
#ifndef SPDIF_TX
#define SPDIF_TX 0
#endif
/* Enable Mixer Core(s) */
#ifndef MIXER
#define MIXER 1
#endif
/* Disable mixing - mixer core used for volume only */
#ifndef MAX_MIX_COUNT
#define MAX_MIX_COUNT 0
#endif
/* Device is self powered (i.e. not USB bus powered) */
#define SELF_POWERED 1
/* Number of IS2 chans to DAC..*/
#ifndef I2S_CHANS_DAC
#define I2S_CHANS_DAC (4)
#endif
/* Number of I2S chans from ADC */
#ifndef I2S_CHANS_ADC
#define I2S_CHANS_ADC (8)
#endif
/* SPDIF and ADAT first input chan indices */
#define SPDIF_RX_INDEX (6)
#define ADAT_RX_INDEX (8)
#define SPDIF_TX_INDEX (I2S_CHANS_DAC)
#if defined(SPDIF_TX) && (SPDIF_TX==1)
#define ADAT_TX_INDEX (SPDIF_TX_INDEX+2)
#else
#define ADAT_TX_INDEX (I2S_CHANS_DAC)
#endif
/* Master clock defines (in Hz) */
#define MCLK_441 (512*44100) /* 44.1, 88.2 etc */
#define MCLK_48 (512*48000) /* 48, 96 etc */
/* Maximum frequency device runs at */
#ifndef MAX_FREQ
#define MAX_FREQ (192000)
#endif
/***** Defines relating to USB descriptors etc *****/
#define VENDOR_ID (0x0000)
#define PID_AUDIO_1 (0x0005)
#define PID_AUDIO_2 (0x0004)
/* Flash device for DFU. Device supported by tools so no need to spec */
//#define DFU_FLASH_DEVICE FL_DEVICE_ATMEL_AT25DF041A
#define PRODUCT_STR_A1 "8SoundsUSB Audio 1.0"
#define PRODUCT_STR_A2 "8SoundsUSB Audio 2.0"
#define AUDIO_CLASS_FALLBACK 0 //disabled
#define VENDOR_STR "IntRoLab"
#define BCD_DEVICE (0x0530)
#define MIN_FREQ 48000
#define DEFAULT_FREQ 96000
//NO DFU
#ifdef DFU
#undef DFU
#endif
//Define codec0 & codec1 addresses
#define COD0_DEV_ADRS (0x90>>1)
#define COD1_DEV_ADRS (0x92>>1)
//Find & replace the reset of codecs
//DL - reset both codecs
p_aud_cfg <: 0b1001;
//Find & replace the i2c code to configure both codecs
//0x2
i2c_master_write_reg(COD0_DEV_ADRS, 0x2, tmp, 1, i2cPorts);
i2c_master_write_reg(COD1_DEV_ADRS, 0x2, tmp, 1, i2cPorts);
//0x4
i2c_master_write_reg(COD0_DEV_ADRS, 0x4, tmp, 1, i2cPorts);
i2c_master_write_reg(COD1_DEV_ADRS, 0x4, tmp, 1, i2cPorts);
//0x5
//DL - DIFFERENTIAL...
//tmp[0] = 0x1C;
tmp[0] = 0x00;
i2c_master_write_reg(COD0_DEV_ADRS, 0x5, tmp, 1, i2cPorts);
i2c_master_write_reg(COD1_DEV_ADRS, 0x5, tmp, 1, i2cPorts);
//0x3
i2c_master_write_reg(COD0_DEV_ADRS, 0x3, tmp, 1, i2cPorts);
i2c_master_write_reg(COD1_DEV_ADRS, 0x3, tmp, 1, i2cPorts);
//0x2
i2c_master_write_reg(COD0_DEV_ADRS, 0x2, tmp, 1, i2cPorts);
i2c_master_write_reg(COD1_DEV_ADRS, 0x2, tmp, 1, i2cPorts);
# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling.
TARGET = 8SoundsUSB
APP_NAME =
# The flags passed to xcc when building the application
BUILD_FLAGS = -DFLASH_MAX_UPGRADE_SIZE=64*1024 -fcomment-asm -Xmapper --map -Xmapper MAPFILE -Wall -O3 -report -lflash -fsubword-select -save-temps -g -DXUD_SERIES_SUPPORT=2 -DXSCOPE=1 -fxscope -DADAT_TX_USE_SHARED_BUFF=1
#-fschedule
TEST_DFU_1 ?= 0
ifeq ($(TEST_DFU_1),1)
BUILD_FLAGS += -DBCD_DEVICE=0x9901
endif
TEST_DFU_2 ?= 0
ifeq ($(TEST_DFU_2),1)
BUILD_FLAGS += -DBCD_DEVICE=0x9902
endif
#Test build configs (Note these make use of the defaults in customdefines.h)
# Audio Class 2, Input, Output, No MIDI, No SPDIF, TDM
XCC_FLAGS_2io_tdm8 = $(BUILD_FLAGS) -DSPDIF_TX=0 -DI2S_MODE_TDM=1 -DMAX_FREQ=96000 -DI2S_CHANS_DAC=8 -DI2S_CHANS_ADC=8 -DNUM_USB_CHAN_OUT=8 -DNUM_USB_CHAN_IN=8
INCLUDE_ONLY_IN_2io_tdm8 =
# Audio Class 2, no Input, Output, no MIDI, SPDIF
XCC_FLAGS_2xoxs = $(BUILD_FLAGS) -DMIDI=0 -DSPDIF_TX=1 -DNUM_USB_CHAN_IN=0 -DI2S_CHANS_ADC=0
INCLUDE_ONLY_IN_2xoxs =
# Audio Class 2, Input, Output, No MIDI, No SPDIF
XCC_FLAGS_2ioxx = $(BUILD_FLAGS) -DSPDIF_TX=0
INCLUDE_ONLY_IN_2ioxx =
# Audio Class 2, Input, Output, No MIDI, No SPDIF, Mixing
XCC_FLAGS_2ioxx_mix8 = $(BUILD_FLAGS) -DSPDIF_TX=0 -DMAX_MIX_COUNT=8
INCLUDE_ONLY_IN_2ioxx_mix8 =
# Audio Class 2, Input, Output, No MIDI, SPDIF
XCC_FLAGS_2ioxs = $(BUILD_FLAGS)
INCLUDE_ONLY_IN_2ioxs =
# Audio Class 2, Input, Output, MIDI, no SPDIF
XCC_FLAGS_2iomx = $(BUILD_FLAGS) -DMIDI=1 -DSPDIF_TX=0
INCLUDE_ONLY_IN_2iomx =
# Audio Class 1, Input, Output, no MIDI, no SPDIF
XCC_FLAGS_1ioxx = $(BUILD_FLAGS) -DAUDIO_CLASS=1 -DMIDI=0 -DSPDIF_TX=0
INCLUDE_ONLY_IN_1ioxx =
# Audio Class 2, Input, Output, No MIDI, SPDIF out, SPDIF in
XCC_FLAGS_2io_spdifout_spdifin = $(BUILD_FLAGS) -DSPDIF_RX=1
INCLUDE_ONLY_IN_2io_spdifout_spdifin =
# Audio Class 2, Input, Output, ADAT out
XCC_FLAGS_2io_adatout = $(BUILD_FLAGS) -DSPDIF_TX=0 -DMIDI=0 -DADAT_TX=1 -DMAX_FREQ=96000 -DNUM_USB_CHAN_OUT=16
INCLUDE_ONLY_IN_2io_adatout =
# Audio Class 2, Input, Output, SPDIF out, ADAT out
XCC_FLAGS_2io_spdifout_adatout = $(BUILD_FLAGS) -DMIDI=0 -DADAT_TX=1 -DMAX_FREQ=96000 -DNUM_USB_CHAN_OUT=18
INCLUDE_ONLY_IN_2io_spdifout_adatout =
# Audio Class 2, Input, Output, No MIDI, SPDIF out, SPDIF in, Mixer enabled
XCC_FLAGS_2io_spdifout_spdifin_mix8 = $(BUILD_FLAGS) -DSPDIF_RX=1 -DMAX_MIX_COUNT=8 -DLEVEL_METER_LEDS=1 -DLEVEL_METER_HOST=1
INCLUDE_ONLY_IN_2io_spdifout_spdifin_mix8 =
# Audio Class 2, Input, Output, No MIDI, ADAT in
XCC_FLAGS_2io_adatin = $(BUILD_FLAGS) -DNUM_USB_CHAN_IN=16 -DADAT_RX=1 -DMAX_FREQ=96000
INCLUDE_ONLY_IN_2io_adatin =
# Audio Class 1, no Input, Output, no MIDI, no SPDIF
XCC_FLAGS_1xoxx = $(BUILD_FLAGS) -DAUDIO_CLASS=1 -DMIDI=0 -DSPDIF_TX=0 -DNUM_USB_CHAN_IN=0
INCLUDE_ONLY_IN_1xoxx =
ifeq ($(TEST_CONFIGS),1)
XCC_FLAGS_2ioxs_codec_master = $(BUILD_FLAGS) -DCODEC_MASTER=1
endif
ifeq ($(TEST_CONFIGS),1)
XCC_FLAGS_upgrade1 = $(BUILD_FLAGS) -DBCD_DEVICE_J=0x99 -DBCD_DEVICE_M=0x0 -DBCD_DEVICE_N=0x1
XCC_FLAGS_upgrade2 = $(BUILD_FLAGS) -DBCD_DEVICE_J=0x99 -DBCD_DEVICE_M=0x0 -DBCD_DEVICE_N=0x2
endif
# The USED_MODULES variable lists other module used by the application. These
# modules will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables.
# Modules are expected to be in the directory above the BASE_DIR directory.
USED_MODULES = module_usb_shared module_xud module_usb_audio module_spdif_tx module_spdif_rx module_usb_midi module_dfu module_usb_device module_i2c_simple module_adat_rx module_adat_tx
MODULE_LIBRARIES = xud_l
#=============================================================================
# The following part of the Makefile includes the common build infrastructure
# for compiling XMOS applications. You should not need to edit below here.
XMOS_MAKE_PATH ?= ../..
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
Build the 2ioxx target.
That's it!
Enjoy!