Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ add_subdirectory(app_usb_aud_xk_316_mc)
add_subdirectory(app_usb_aud_xk_216_mc)
add_subdirectory(app_usb_aud_xk_evk_xu316)
add_subdirectory(app_usb_aud_xk_evk_xu316_extrai2s)
add_subdirectory(app_usb_aud_template)
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ This repository contains the following:
+--------------------------+--------------------------+--------------------------------------------+
| app_usb_aud_xk_evk_xu316 | xk-evk-xu316 | xcore.ai Evaluation Kit |
+--------------------------+--------------------------+--------------------------------------------+
| app_usb_aud_template | | Template/blank application |
+--------------------------+--------------------------+--------------------------------------------+

Please refer to individual README files in these apps for more detailed information.

Expand Down
24 changes: 24 additions & 0 deletions app_usb_aud_template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)

set(APP_INCLUDES src src/core src/extensions)
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
include(${CMAKE_CURRENT_LIST_DIR}/../deps.cmake)

set(SW_USB_AUDIO_FLAGS ${EXTRA_BUILD_FLAGS} -O3
-report
-lquadflash
-g
-Wall
-fxscope
-DADAT_TX_USE_SHARED_BUFF=1)

project(app_usb_aud_template)

set(APP_HW_TARGET custom_board.xn)

# Simple 2 in/2 out configuration
set(APP_COMPILER_FLAGS ${SW_USB_AUDIO_FLAGS} -DNUM_USB_CHAN_IN=2
-DNUM_USB_CHAN_OUT=2)

XMOS_REGISTER_APP()
49 changes: 49 additions & 0 deletions app_usb_aud_template/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
##############################
Template USB Audio application
##############################

:scope: Example
:description: Template USB Audio application
:keywords: USB, UAC
:boards:

*******
Summary
*******

The firmware provides a high-speed USB Audio device designed to be compliant to version 2.0 of the
USB Audio Class Specification based on the xcore.ai device.

********
Features
********

The app_usb_aud_template application is a template application provided as a good starting point for
porting to custom hardware.

It uses the XMOS USB Audio framework to implement a USB Audio device with the following default
key features:

- USB Audio Class 1.0/2.0 Compliant

- Fully Asynchronous operation

- 2 channels analogue input and 2 channels analogue output

- Support for the following sample frequencies: 44.1, 48, 88.2, 96, 176.4, 192kHz

************
Known Issues
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The casing of "Known Issues" should match the consistent pattern used in other README files. Based on app_usb_aud_xk_316_mc/README.rst line 38, this should be "Known issues" (lowercase 'i').

Suggested change
Known Issues
Known issues

Copilot uses AI. Check for mistakes.
************

- None

See README in sw_usb_audio for general issues.

*******
Support
*******

For all support issues please visit http://www.xmos.com/support


86 changes: 86 additions & 0 deletions app_usb_aud_template/src/core/custom_board.xn
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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>Board</Type>
<Name>Custom USB Audio Board</Name>

<Declarations>
<Declaration>tileref tile[2]</Declaration>
</Declarations>

<Packages>
<Package id="0" Type="XS3-UnA-1024-TQ128">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS3-L16A-1024" Oscillator="24MHz" SystemFrequency="600MHz" ReferenceFrequency="100MHz">
<Boot>
<Source Location="bootFlash"/>
</Boot>
<Tile Number="0" Reference="tile[0]">
<Port Location="XS1_PORT_1B" Name="PORT_SQI_CS"/>
<Port Location="XS1_PORT_1C" Name="PORT_SQI_SCLK"/>
<Port Location="XS1_PORT_4B" Name="PORT_SQI_SIO"/>

<!-- Clocking -->
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN_USB"/>
<Port Location="XS1_PORT_1A" Name="PORT_PLL_REF"/>

<!-- Audio Ports: Digital -->
<Port Location="XS1_PORT_1O" Name="PORT_ADAT_IN"/>
<Port Location="XS1_PORT_1N" Name="PORT_SPDIF_IN"/>

</Tile>
<Tile Number="1" Reference="tile[1]">
<!-- Audio Ports: I2S -->
<Port Location="XS1_PORT_1D" Name="PORT_MCLK_IN"/>
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT_2"/>
<Port Location="XS1_PORT_1B" Name="PORT_I2S_LRCLK"/>
<Port Location="XS1_PORT_1C" Name="PORT_I2S_BCLK"/>
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
<Port Location="XS1_PORT_1O" Name="PORT_I2S_DAC1"/>
<Port Location="XS1_PORT_1N" Name="PORT_I2S_DAC2"/>
<Port Location="XS1_PORT_1M" Name="PORT_I2S_DAC3"/>
<Port Location="XS1_PORT_1I" Name="PORT_I2S_ADC0"/>
<Port Location="XS1_PORT_1J" Name="PORT_I2S_ADC1"/>
<Port Location="XS1_PORT_1K" Name="PORT_I2S_ADC2"/>
<Port Location="XS1_PORT_1L" Name="PORT_I2S_ADC3"/>

<!-- Audio Ports: Digital -->
<Port Location="XS1_PORT_1G" Name="PORT_ADAT_OUT"/>
<Port Location="XS1_PORT_1A" Name="PORT_SPDIF_OUT"/>

<!-- MIDI -->
<Port Location="XS1_PORT_1F" Name="PORT_MIDI_IN"/>
<Port Location="XS1_PORT_4C" Name="PORT_MIDI_OUT"/>

</Tile>
</Node>
</Nodes>
</Package>
</Packages>
<Nodes>
<Node Id="2" Type="device:" RoutingId="0x8000">
<Service Id="0" Proto="xscope_host_data(chanend c);">
<Chanend Identifier="c" end="3"/>
</Service>
</Node>
</Nodes>
<Links>
<Link Encoding="2wire" Delays="5clk" Flags="XSCOPE">
<LinkEndpoint NodeId="0" Link="XL0"/>
<LinkEndpoint NodeId="2" Chanend="1"/>
</Link>
</Links>
<ExternalDevices>
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" PageSize="256" SectorSize="4096" NumPages="16384">
<Attribute Name="PORT_SQI_CS" Value="PORT_SQI_CS"/>
<Attribute Name="PORT_SQI_SCLK" Value="PORT_SQI_SCLK"/>
<Attribute Name="PORT_SQI_SIO" Value="PORT_SQI_SIO"/>
</Device>
</ExternalDevices>
<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>

</Network>
169 changes: 169 additions & 0 deletions app_usb_aud_template/src/core/xua_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
// Copyright 2012-2025 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

// Defines relating to device configuration and customisation.

#ifndef _XUA_CONF_H_
#define _XUA_CONF_H_

#include "../../../shared/version.h"

/*
* Device configuration option defines to override default defines found in lib_xua/api/xua_conf_default.h
*
* Build can be customised by changing and adding defines here
*
* Note, we check if they are already defined in Makefile
*/

/*** Defines relating to basic functionality ***/
/* Enable/Disable MIDI - Default is MIDI off */
#ifndef MIDI
#define MIDI (0)
#endif

/* Enable/Disable S/PDIF output - Default is S/PDIF off */
#ifndef XUA_SPDIF_TX_EN
#define XUA_SPDIF_TX_EN (0)
#endif

/* Enable/Disable S/PDIF input - Default is S/PDIF off */
#ifndef XUA_SPDIF_RX_EN
#define XUA_SPDIF_RX_EN (0)
#endif

/* Enable/Disable ADAT output - Default is ADAT off */
#ifndef XUA_ADAT_TX_EN
#define XUA_ADAT_TX_EN (0)
#endif

/* Enable/Disable ADAT input - Default is ADAT off */
#ifndef XUA_ADAT_RX_EN
#define XUA_ADAT_RX_EN (0)
#endif

/* Enable/Disable Mixing core(s) - Default is on */
#ifndef MIXER
#define MIXER (1)
#endif

/* Set the number of mixes to perform - Default is 0 i.e mixing disabled */
#ifndef MAX_MIX_COUNT
#define MAX_MIX_COUNT (0)
#endif

/* Audio Class version - Default is 2.0 */
#ifndef AUDIO_CLASS
#define AUDIO_CLASS (2)
#endif

/*** Defines relating to channel counts ***/
/* Number of I2S channels to DACs*/
#ifndef I2S_CHANS_DAC
#define I2S_CHANS_DAC (2)
#endif

/* Number of I2S channels from ADCs */
#ifndef I2S_CHANS_ADC
#define I2S_CHANS_ADC (2)
#endif

/* Number of USB streaming channels - by default calculate by counting audio interfaces */
#ifndef NUM_USB_CHAN_IN
#define NUM_USB_CHAN_IN (I2S_CHANS_ADC + 2*XUA_SPDIF_RX_EN + 8*XUA_ADAT_RX_EN) /* Device to Host */
#endif

#ifndef NUM_USB_CHAN_OUT
#define NUM_USB_CHAN_OUT (I2S_CHANS_DAC + 2*XUA_SPDIF_TX_EN + 8*XUA_ADAT_TX_EN) /* Host to Device */
#endif

/*** Defines relating to channel arrangement/indices ***/
/* Channel index of S/PDIF Tx channels: separate channels after analogue channels (if they fit) */
#ifndef SPDIF_TX_INDEX
#if (I2S_CHANS_DAC + 2*XUA_SPDIF_TX_EN) <= NUM_USB_CHAN_OUT
#define SPDIF_TX_INDEX (I2S_CHANS_DAC)
#else
#define SPDIF_TX_INDEX (0)
#endif
#endif

/* Channel index of S/PDIF Rx channels: separate channels after analogue channels */
#ifndef SPDIF_RX_INDEX
#define SPDIF_RX_INDEX (I2S_CHANS_ADC)
#endif

/* Channel index of ADAT Tx channels: separate channels after S/PDIF channels (if they fit) */
#ifndef ADAT_TX_INDEX
#define ADAT_TX_INDEX (I2S_CHANS_DAC + 2*XUA_SPDIF_TX_EN)
#endif

/* Channel index of ADAT Rx channels: separate channels after S/PDIF channels */
#ifndef ADAT_RX_INDEX
#define ADAT_RX_INDEX (I2S_CHANS_ADC + 2*XUA_SPDIF_RX_EN)
#endif

/*** Defines relating to audio frequencies ***/
/* Master clock defines (in Hz) */
#ifndef MCLK_441
#define MCLK_441 (512*44100) /* 44.1, 88.2 etc */
#endif

#ifndef MCLK_48
#define MCLK_48 (512*48000) /* 48, 96 etc */
#endif

/* Minimum sample frequency device runs at */
#ifndef MIN_FREQ
#define MIN_FREQ (44100)
#endif

/* Maximum sample frequency device runs at */
#ifndef MAX_FREQ
#define MAX_FREQ (192000)
#endif

/*** Defines relating to feature placement regarding tiles ***/
#define XUA_XUD_TILE_NUM (0)
#define XUA_PLL_REF_TILE_NUM (0)

#define XUA_AUDIO_IO_TILE_NUM (1)
#define XUA_MIDI_TILE_NUM (1)

/*** Defines relating to USB descriptor strings and ID's ***/
#define VENDOR_ID (0x20B1) /* XMOS VID */
#ifndef PID_AUDIO_2
#if MIDI
#define PID_AUDIO_2 (0x0020) /* Enumerate with a different PID since the
* interface numbering is different between MIDI
* enabled vs disabled and the Thesycon driver doesn't
* support different interface layouts with the same PID */
#else
#define PID_AUDIO_2 (0x0016)
#endif
#endif
#ifndef PID_AUDIO_1
#define PID_AUDIO_1 (0x0017)
#endif

#ifndef DFU_PID
#if (AUDIO_CLASS == 1)
#define DFU_PID (0xD000 + PID_AUDIO_1)
#else
#define DFU_PID (0xD000 + PID_AUDIO_2)
#endif
#endif

#define PRODUCT_STR_A2 "XMOS (UAC2.0)"
#define PRODUCT_STR_A1 "XMOS (UAC1.0)"

/* Board power source - Default is bus-powered */
#ifndef XUA_POWERMODE
#define XUA_POWERMODE XUA_POWERMODE_BUS
#endif

/* Enable/Disable example HID code - Default is off */
#ifndef HID_CONTROLS
#define HID_CONTROLS (0)
#endif

#endif
23 changes: 23 additions & 0 deletions app_usb_aud_template/src/extensions/audiohw.xc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022-2025 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "xua.h"

/* Configures the external audio hardware at startup */
void AudioHwInit()
{

}

/* Configures the external audio hardware for the required sample frequency
*
* samFreq: Sample frequency in Hz
* mClk: Master clock frequency in Hz
* dsdMode: DSD mode flag (0 for PCM, non-zero for DSD)
* sampRes_DAC: Sample resolution for DAC in bits
* sampRes_ADC: Sample resolution for ADC in bits
*/
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode, unsigned sampRes_DAC, unsigned sampRes_ADC)
{

}

12 changes: 12 additions & 0 deletions app_usb_aud_template/src/extensions/audiostream.xc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2022-2025 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

/* Called when audio streaming starts or stops
* inputActive: 1 when input stream is active, 0 when inactive
* outputActive: 1 when output stream is active, 0 when inactive
*/
void UserAudioStreamState(int inputActive, int outputActive)
{

}

10 changes: 10 additions & 0 deletions app_usb_aud_template/src/extensions/hostactive.xc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2023-2025 XMOS LIMITED.
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

/* Called when USB host becomes active or inactive
* active: 1 when host is active, 0 when inactive
*/
void UserHostActive(int active)
{

}
Loading