-
Notifications
You must be signed in to change notification settings - Fork 32
Added template app #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xross
wants to merge
1
commit into
xmos:develop
Choose a base branch
from
xross:feature/app_template
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Added template app #348
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ************ | ||
|
|
||
| - None | ||
|
|
||
| See README in sw_usb_audio for general issues. | ||
|
|
||
| ******* | ||
| Support | ||
| ******* | ||
|
|
||
| For all support issues please visit http://www.xmos.com/support | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| { | ||
|
|
||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
xross marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* 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) | ||
| { | ||
|
|
||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
|
|
||
xross marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* Called when USB host becomes active or inactive | ||
| * active: 1 when host is active, 0 when inactive | ||
| */ | ||
| void UserHostActive(int active) | ||
| { | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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').