55 Commits

Author SHA1 Message Date
Ed
67f8badbe7 Fix source/license/changelog check fails 2020-09-02 11:42:23 +01:00
Ed
8be5f0a31f Merge branch 'feature/fix_i2s_pushout' into support/0.1
* feature/fix_i2s_pushout:
  Version bump, changelog and source
  Better fix to avoid zero length packets being added to input buffer before SoF case starts working
  Revert "Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing"
  Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing

# Conflicts:
#	CHANGELOG.rst
2020-09-02 10:07:12 +01:00
Ed
acd5e5f951 Version bump, changelog and source 2020-09-02 08:37:39 +01:00
Ed
0286ca093d Better fix to avoid zero length packets being added to input buffer before SoF case starts working 2020-09-01 17:53:03 +01:00
Ed
2e8e57d5fa Revert "Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing"
This reverts commit 0b32bee3aa.
2020-09-01 17:48:38 +01:00
Ed
0b32bee3aa Handle case at startup where decouple ISR gets stuck for several hundred cycles at startup, pushing out I2S timing 2020-09-01 09:55:53 +01:00
Sam Chesney
e0ab8d4346 Merge pull request #92 from larry-xmos/release/0.1.3
XVF3500 maintenance release
2019-08-23 17:37:33 +01:00
Larry Snizek
0eaefc3478 Jenkins release ready for merging 2019-08-23 17:17:21 +01:00
Larry Snizek
dcfe0235ad Unstuck test script 2019-08-23 17:04:31 +01:00
Larry Snizek
58713733a2 Troubleshoot Jenkins release 2019-08-23 16:38:53 +01:00
Larry Snizek
a135b674f7 Troubleshoot Jenkins release 2019-08-23 16:37:20 +01:00
Larry Snizek
43eb63e271 Test Jenkins release on a pull request 2019-08-23 15:56:34 +01:00
Sam Chesney
7d06aa543a Merge pull request #90 from larry-xmos/release/0.1.3
XVF3500 maintenance release
2019-08-23 14:56:04 +01:00
Larry Snizek
235b06f00a Add Jenkins release steps 2019-08-23 14:32:24 +01:00
Sam Chesney
f90022618b Merge pull request #87 from larry-xmos/release/0.1.3
XVF3500 maintenance release
2019-08-23 13:44:57 +01:00
Larry Snizek
5b1132a603 Changelog update 2019-08-23 13:15:23 +01:00
Larry Snizek
2e6ce1e4e1 More documentation build fixes 2019-08-23 13:10:59 +01:00
Larry Snizek
a48ae96f39 AN00246: Remove missing block diagram 2019-08-23 12:39:35 +01:00
Larry Snizek
ebe263605c AN00246: Fix xdoc build 2019-08-23 12:16:52 +01:00
Larry Snizek
502db6ee48 Git ignore of Python virtual environment 2019-08-22 14:43:00 +01:00
Larry Snizek
df8cdd8692 More release checks 2019-08-22 14:21:54 +01:00
Larry Snizek
83b8c727f6 Buggy Git ignore 2019-08-22 14:21:50 +01:00
Larry Snizek
3cbb8282c7 GitFlow-like view name in Jenkins file 2019-08-22 11:57:15 +01:00
Larry Snizek
9cd76b2a4b Satisfy release checks 2019-08-22 11:48:38 +01:00
Larry Snizek
7d1d2af8d2 Draft Jenkins file 2019-08-20 17:59:06 +01:00
Larry Snizek
fa3ccb555b Also update i2s_loopback test to work with 14.4 tools 2019-08-20 17:58:51 +01:00
Larry Snizek
9ea6a3de3c Remove wscript to ensure always xcommon build 2019-08-20 16:49:00 +01:00
Larry Snizek
58eb2fe612 Update AN00246 to API with master clock passed in 2019-08-20 16:41:49 +01:00
Larry Snizek
f4ab2d9b82 Infrastructure files from pull request #84 2019-08-20 15:29:26 +01:00
Larry Snizek
5a1865d9d5 Changelog and version number for 0.1.3 release 2019-08-20 15:26:11 +01:00
Larry Snizek
c59a545197 Copyright notice update 2019-08-20 15:26:11 +01:00
Luciano Martin
232ab79f78 Remove obsolete flag subword-selectt 2019-08-20 15:26:11 +01:00
Luciano Martin
2aab72a817 Remove global variable for p_mclk_in 2019-08-20 15:26:11 +01:00
Larry Snizek
156bf61b62 Empty Jenkins file 2019-08-19 18:00:26 +01:00
Sam Chesney
408d9b7c42 Merge pull request #53 from lucianomartin/fix_buildbot
Add missing copyright
2018-04-10 11:11:53 +01:00
Luciano Martin
a572bf9c5a Add missing copyright 2018-04-09 10:41:54 +01:00
Ross Owen
711efc8be9 Merge pull request #49 from larry-xmos/MAINTEN/v0.1
Apply host directory move in DFU documentation too
2018-03-15 10:44:31 +00:00
Larry Snizek
566cf12c3f Apply host directory move in DFU documentation too 2018-03-14 17:49:56 +00:00
xross
b6460a266e Fixed SOURCE_DIRS to handle subdirs 2018-03-14 15:33:45 +00:00
xross
69319f706d Ignore dfu src in main build 2018-03-13 18:34:24 +00:00
Larry Snizek
3098e8bce5 Move host directory under lib directory so it gets released 2018-03-13 17:23:22 +00:00
xross
4a8ddb2e40 Changelog update 2018-02-19 15:01:40 +00:00
xross
0afcb6d65c Fixes #39 2018-02-19 14:36:17 +00:00
xross
bc91e21189 Typos only 2018-02-19 11:32:15 +00:00
xross
29deebd07a Scripted changelog update 2018-02-19 10:56:47 +00:00
xross
7027dc2ad4 Changelog update 2018-02-19 10:55:28 +00:00
xross
0674880c11 Undo accidental removal of buffering bounds check 2018-02-15 16:08:21 +00:00
xross
4f6a54f3b0 Whitespace only 2018-02-14 16:53:58 +00:00
xross
90f9588fe0 Comment change only 2018-02-14 16:52:45 +00:00
xross
a19086f0d4 Removed unused tmpBuffer 2018-02-14 16:52:23 +00:00
xross
8a8cc4168a Feedback properly configured in AN00246 app 2018-02-14 16:50:47 +00:00
xross
b3aa9dc009 xScope enabled in AN00246 app 2018-02-14 16:50:16 +00:00
xross
6c091a85d3 Changelog update and version bump 2018-02-14 12:23:18 +00:00
xross
eb0ea91979 Added AN00246 files 2018-02-14 12:19:50 +00:00
xross
1a324855a0 Added AN00246 2018-02-14 11:14:14 +00:00
58 changed files with 558 additions and 177 deletions

3
.gitignore vendored
View File

@@ -11,7 +11,8 @@ module_dfu/host/xmosdfu/xmosdfu
*.xi *.xi
*.i *.i
*.bin *.bin
.* .build*
*/.venv/*
*~ *~
*.a *.a
*.swp *.swp

7
Brewfile Normal file
View File

@@ -0,0 +1,7 @@
tap 'homebrew/core'
brew 'perl'
brew 'cpanm'
brew 'python@2'
brew 'pipenv'

View File

@@ -1,6 +1,29 @@
lib_xua Change Log lib_xua Change Log
================== ==================
0.1.4
-----
* RESOLVED: Zero length input packets generated before enumeration causing I2S
timing pushout at startup
0.1.3
-----
* CHANGED: Remove sharing of global master clock port variable for
compatibility with tools 14.4 (API change but preserve 0.1 version as this
is maintenance branch)
* CHANGED: Remove obsolete -fsubword-select to clear warning in tools 14.4
0.1.2
-----
* ADDED: Application note AN00246
* RESOLVED: Runtime exception issues when incorrect feedback calculated
(introduced in sc_xud 6.13)
* RESOLVED: Output sample counter reset on stream start. Caused playback
issues on some Linux based hosts
0.1.1 0.1.1
----- -----
@@ -46,7 +69,7 @@ lib_xua Change Log
Legacy release history Legacy release history
---------------------- ======================
(Note: Forked from sc_usb_audio at this point) (Note: Forked from sc_usb_audio at this point)
@@ -323,7 +346,7 @@ Legacy release history
Legacy release history Legacy release history
---------------------- ======================
Please see changelog in sw_usb_audio for changes prior to 6.8.0 release. Please see changelog in sw_usb_audio for changes prior to 6.8.0 release.

123
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,123 @@
@Library('xmos_jenkins_shared_library@develop') _
getApproval()
pipeline {
agent none
environment {
REPO = 'lib_xua'
VIEW = 'lib_xua_release_0_1_3'
}
options {
skipDefaultCheckout()
}
stages {
stage('Basic tests') {
agent {
label 'x86_64&&brew'
}
stages {
stage('Get view') {
steps {
xcorePrepareSandbox("${VIEW}", "${REPO}")
}
}
stage('Library checks') {
steps {
xcoreLibraryChecks("${REPO}")
}
}
stage('Tests') {
steps {
runXmostest("${REPO}", 'tests')
}
}
stage('xCORE builds') {
steps {
dir("${REPO}") {
xcoreAllAppNotesBuild('examples')
dir("${REPO}") {
runXdoc('doc')
}
}
}
}
}
post {
cleanup {
xcoreCleanSandbox()
}
}
}
stage('Build host apps') {
failFast true
parallel {
stage('Build Linux host app') {
agent {
label 'x86_64&&brew&&linux'
}
steps {
xcorePrepareSandbox("${VIEW}", "${REPO}")
dir("${REPO}/${REPO}/host/xmosdfu") {
sh 'make -f Makefile.Linux64'
}
}
post {
cleanup {
xcoreCleanSandbox()
}
}
}
stage('Build Mac host app') {
agent {
label 'x86_64&&brew&&macOS'
}
steps {
xcorePrepareSandbox("${VIEW}", "${REPO}")
dir("${REPO}/${REPO}/host/xmosdfu") {
sh 'make -f Makefile.OSX64'
}
}
post {
cleanup {
xcoreCleanSandbox()
}
}
}
}
}
stage('Release and update') {
agent {
label 'x86_64&&brew'
}
stages {
stage('Get view') {
steps {
xcorePrepareSandbox("${VIEW}", "${REPO}")
}
}
stage('Release') {
when {
expression {
isReleaseBranchOfOrganisation('xmos')
}
}
steps {
sh "mkdir ${REPO}/empty"
xcoreReleaseToGithub("${WORKSPACE}/${REPO}","${WORKSPACE}/${REPO}/empty")
}
}
stage('Update') {
steps {
updateViewfiles()
}
}
}
post {
cleanup {
xcoreCleanSandbox()
}
}
}
}
}

View File

@@ -1,6 +1,6 @@
Software Release License Agreement Software Release License Agreement
Copyright (c) 2011-2018, XMOS, All rights reserved. Copyright (c) 2011-2020, XMOS, All rights reserved.
BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software. BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software.

7
Pipfile Normal file
View File

@@ -0,0 +1,7 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
flake8 = "*"

View File

@@ -5,7 +5,7 @@ USB Audio Shared Components. For use in the XMOS USB Audio Refererence Designs.
Required software (dependencies) Required software (dependencies)
................................ --------------------------------
* lib_logging * lib_logging
* lib_xud * lib_xud
@@ -13,6 +13,6 @@ Required software (dependencies)
Checking dependent libs Checking dependent libs
Software version and dependencies Software version and dependencies
................................. ---------------------------------
.. libdeps:: .. libdeps::

2
cpanfile Normal file
View File

@@ -0,0 +1,2 @@
requires 'File::Copy::Recursive';
requires 'LWP::Simple'

View File

@@ -1 +1 @@
SOURCE_INCLUDE_DIRS=../host/xmosdfu SOURCE_INCLUDE_DIRS=../lib_xua/host/xmosdfu

View File

@@ -4,7 +4,7 @@ Building the XMOS DFU loader - macOS
==================================== ====================================
The XMOS DFU loader is provided as source as part of the USB Audio The XMOS DFU loader is provided as source as part of the USB Audio
framework, located in sc_usb_audio/module_dfu/host/xmos_dfu_osx. framework, located in lib_xua/host/xmosdfu.
The loader is compiled using libusb, the code for the loader is contained in the The loader is compiled using libusb, the code for the loader is contained in the
file ``xmosdfu.cpp`` file ``xmosdfu.cpp``

View File

@@ -1,6 +1,6 @@
Software Release License Agreement Software Release License Agreement
Copyright (c) 2018, XMOS, All rights reserved. Copyright (c) 2018-2019, XMOS, All rights reserved.
BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software. BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software.
@@ -132,4 +132,4 @@ This License shall be governed by and construed in accordance with English law a
This License has been entered into on the date stated at the beginning of it. This License has been entered into on the date stated at the beginning of it.
Schedule Schedule
XMOS lib_xua software XMOS application note AN00246 software

View File

@@ -3,13 +3,14 @@ APP_NAME = app_xua_simple
TARGET = xk-audio-216-mc.xn TARGET = xk-audio-216-mc.xn
# The flags passed to xcc when building the application # The flags passed to xcc when building the application
XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -fsubword-select -save-temps -g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1] -DSDA_HIGH=2 -DSCL_HIGH=1 XCC_FLAGS = -fcomment-asm -Xmapper --map -Xmapper MAPFILE -O3 -report -save-temps \
-g -Wno-unused-function -Wno-timing -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1] \
-DSDA_HIGH=2 -DSCL_HIGH=1 -fxscope
# The USED_MODULES variable lists other module used by the application. These # 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 will extend the SOURCE_DIRS, INCLUDE_DIRS and LIB_DIRS variables.
# Modules are expected to be in the directory above the BASE_DIR directory. # Modules are expected to be in the directory above the BASE_DIR directory.
USED_MODULES = lib_mic_array lib_logging lib_xua lib_device_control lib_xud module_i2c_shared module_i2c_single_port module_locks USED_MODULES = lib_xua lib_xud module_i2c_shared module_i2c_single_port
#============================================================================= #=============================================================================
# The following part of the Makefile includes the common build infrastructure # The following part of the Makefile includes the common build infrastructure

View File

@@ -0,0 +1,34 @@
How to use the lib_xua_library
===============================
.. version:: 0.1.3
Summary
-------
Required tools and libraries
............................
.. appdeps::
Required hardware
.................
The example code provided with the application has been implemented
and tested on the xCORE-200 Multi-channel Audio Board
Prerequisites
.............
* This document assumes familiarity with the XMOS xCORE architecture,
the XMOS tool chain and the xC language. Documentation related to these
aspects which are not specific to this application note are linked to in
the references appendix.
* For a description of XMOS related terms found in this document
please see the XMOS Glossary [#]_.
.. [#] http://www.xmos.com/published/glossary

View File

@@ -0,0 +1,2 @@
rst/_build
pdf

View File

@@ -0,0 +1,241 @@
.. include:: ../../README.rst
.. |I2C| replace:: I\ :sup:`2`\ C
|newpage|
Overview
--------
Introduction
............
The XMOS USB Audio (XUA) library provides an implemention of USB Audio Class 2.0
This application note demonstrates the implementation of a basic USB Audio Device on
the xCORE-200 MC Audio board.
Block diagram
.............
.. .. figure:: images/block_diagram.*
.. :width: 80%
..
.. Application block diagram
The application uses a single logical core which runs the application and makes
calls to the |I2C| master library functions as required.
How to use lib_xua
------------------
The Makefile
............
To start using the lib_xua, you need to add ``lib_xua`` to your Makefile::
USED_MODULES = .. lib_xua ...
This demo also uses the XMOS USB Device library (``lib_xud``) for low-level USB connectivity.
The Makefile also includes::
USED_MODULES = .. lib_xud ..
``lib_xud`` library requires some flags for correct operation. Firstly the
tile on which ``lib_xud`` will be execute, for example::
XCC_FLAGS = .. -DUSB_TILE=tile[1] ..
Secondly, the architecture of the target device, for example::
XCC_FLAGS = .. -DXUD_SERIES_SUPPORT=XUD_X200_SERIES ..
Includes
........
This application requires the system header that defines XMOS xCORE specific
defines for declaring and initialising hardware:
.. literalinclude:: app_xua_simple.xc
:start-on: include <xs1.h>
:end-before: include "xua.h"
The XUA library functions are defined in ``xua.h``. This header must
be included in your code to use the library.
.. literalinclude:: app_xua_simple.xc
:start-on: include "xua.h"
:end-on: include "xud_device.h"
Allocating hardware resources
.............................
A most basic implementation of a USB Audio device (i.e. simple stereo input and output via I2S)
using ``lib_xua`` requires the follow pins:
- I2S Bit Clock (from xCORE to DAC)
- I2S L/R clock (from xCORE to DAC)
- I2S Data line (from xCORE to DAC)
- I2S Data line (from ADC to xCORE)
- Audio Master clock (from clock source to xCORE)
.. note::
ANOO246 assumes xCORE is I2S bus master
On an xCORE the pins are controlled by ``ports``. The application therefore declares various ``ports``
for this purpose:
.. literalinclude:: app_xua_simple.xc
:start-on: /* Port declaration
:end-on: /* Clock-block
In addition to ``port`` resources two clock-block resources are also required:
.. literalinclude:: app_xua_simple.xc
:start-on: /* Clock-block
:end-on: /* clock clk_audio_mclk
Other declarations
..................
``lib_xua`` currently requires the manual declaration of tables for the endpoint types for
``lib_xud`` and the calling the main XUD funtion in a par (``XUD_Main()``).
For a simple application the following endpoints are required:
- ``Control`` enpoint zero
- ``Isochonous`` endpoint for each direction for audio data to/from the USB host
These are declared as follows:
.. literalinclude:: app_xua_simple.xc
:start-on: /* Endpoint type tables
:end-on: /* XUD_EpType epTypeTableIn
The application main() function
...............................
The ``main()`` function sets up the tasks in the application.
Various channels are required in order to allow the required tasks to communcate.
These must be declared":
.. literalinclude:: app_xua_simple.xc
:start-on: /* Channels for lib_xud
:end-on: /* chan c_aud_ctl
The rest of the ``main()`` function starts all the tasks in parallel
using the xC ``par`` construct:
.. literalinclude:: app_xua_simple.xc
:start-on: par
:end-before: return 0
This code starts the low-level USB task, an Endpoint 0 task, an Audio buffering task and a task to handle
the audio I/O (i.e. I2S signalling).
Configuration
.............
``lib_xua`` has many parameters than can be configured at build time, some examples include:
- Sample-rates
- Channel counts
- Audio Class version
- Product/Vendor ID's
- Various product strings
- Master clock frequency
These parameters are set via defines in an optional ``xua_conf.h`` header file.
|appendix|
|newpage|
Demo Hardware Setup
-------------------
To run the demo, connect a USB cable to power the xCORE-200 MC Audio board
and plug the xTAG to the board and connect the xTAG USB cable to your
development machine.
.. figure:: images/hw_setup.*
:width: 80%
Hardware setup
|newpage|
Launching the demo application
------------------------------
Once the demo example has been built either from the command line using xmake or
via the build mechanism of xTIMEcomposer studio it can be executed on the xCORE-200
MC Audio board.
Once built there will be a ``bin/`` directory within the project which contains
the binary for the xCORE device. The xCORE binary has a XMOS standard .xe extension.
Launching from the command line
...............................
From the command line you use the ``xrun`` tool to download and run the code
on the xCORE device::
xrun --xscope bin/app_xua_simple.xe
Once this command has executed the application will be running on the
xCORE-200 MC Audio Board
Launching from xTIMEcomposer Studio
...................................
From xTIMEcomposer Studio use the run mechanism to download code to xCORE device.
Select the xCORE binary from the ``bin/`` directory, right click and go to Run
Configurations. Double click on xCORE application to create a new run configuration,
enable the xSCOPE I/O mode in the dialog box and then
select Run.
Once this command has executed the application will be running on the
xCORE-200 MC Audio board.
Running the application
.......................
Once running the device will be detected as a USB Audio device - note, Windows operating
systems may require a third party driver for correct operation
|newpage|
References
----------
.. nopoints::
* XMOS Tools User Guide
http://www.xmos.com/published/xtimecomposer-user-guide
* XMOS xCORE Programming Guide
http://www.xmos.com/published/xmos-programming-guide
* XMOS lib_xua Library
http://www.xmos.com/support/libraries/lib_xua
* XMOS lib_xud Library
http://www.xmos.com/support/libraries/lib_xud
|newpage|
Full source code listing
------------------------
Source code for main.xc
.......................
.. literalinclude:: app_xua_simple.xc
:largelisting:
|newpage|

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View File

@@ -0,0 +1,2 @@
XMOSNEWSTYLE=1
SOURCE_INCLUDE_DIRS=../../src

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2017-2018, XMOS Ltd, All rights reserved // Copyright (c) 2017-2019, XMOS Ltd, All rights reserved
/* A very simple *example* of a USB audio application (and as such is un-verified for production) /* A very simple *example* of a USB audio application (and as such is un-verified for production)
* *
@@ -13,8 +13,8 @@
#include <xs1.h> #include <xs1.h>
#include <platform.h> #include <platform.h>
#include "xud_device.h"
#include "xua.h" #include "xua.h"
#include "xud_device.h"
/* Port declarations. Note, the defines come from the xn file */ /* Port declarations. Note, the defines come from the xn file */
buffered out port:32 p_i2s_dac[] = {PORT_I2S_DAC0}; /* I2S Data-line(s) */ buffered out port:32 p_i2s_dac[] = {PORT_I2S_DAC0}; /* I2S Data-line(s) */
@@ -24,19 +24,15 @@ buffered out port:32 p_bclk = PORT_I2S_BCLK; /* I2S L/R-clock */
/* Note, declared unsafe as sometimes we want to share this port /* Note, declared unsafe as sometimes we want to share this port
e.g. PDM mics and I2S use same master clock IO */ e.g. PDM mics and I2S use same master clock IO */
port p_mclk_in_ = PORT_MCLK_IN; in port p_mclk_in = PORT_MCLK_IN;
unsafe
{
/* TODO simplify this */
unsafe port p_mclk_in; /* Audio master clock input */
}
in port p_for_mclk_count = PORT_MCLK_COUNT; /* Extra port for counting master clock ticks */ in port p_for_mclk_count = PORT_MCLK_COUNT; /* Extra port for counting master clock ticks */
in port p_mclk_in2 = PORT_MCLK_IN2;
/* Clock-block declarations */ /* Clock-block declarations */
clock clk_audio_bclk = on tile[0]: XS1_CLKBLK_4; /* Bit clock */ clock clk_audio_bclk = on tile[0]: XS1_CLKBLK_4; /* Bit clock */
clock clk_audio_mclk = on tile[0]: XS1_CLKBLK_5; /* Master clock */ clock clk_audio_mclk = on tile[0]: XS1_CLKBLK_5; /* Master clock */
clock clk_audio_mclk2 = on tile[1]: XS1_CLKBLK_1; /* Master clock */
/* Endpoint type tables - informs XUD what the transfer types for each Endpoint in use and also /* Endpoint type tables - informs XUD what the transfer types for each Endpoint in use and also
* if the endpoint wishes to be informed of USB bus resets */ * if the endpoint wishes to be informed of USB bus resets */
@@ -55,7 +51,7 @@ int main()
/* Channel for audio data between buffering cores and audio IO core */ /* Channel for audio data between buffering cores and audio IO core */
chan c_aud; chan c_aud;
/* Channel for communcating control messages from EP0 to the rest of the device (via the buffering cores */ /* Channel for communicating control messages from EP0 to the rest of the device (via the buffering cores */
chan c_aud_ctl; chan c_aud_ctl;
par par
@@ -63,7 +59,6 @@ int main()
/* Low level USB device layer core */ /* Low level USB device layer core */
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2,
c_sof, epTypeTableOut, epTypeTableIn, c_sof, epTypeTableOut, epTypeTableIn,
/* TODO rm me! */
null, null, -1 , null, null, -1 ,
XUD_SPEED_HS, XUD_PWR_BUS); XUD_SPEED_HS, XUD_PWR_BUS);
@@ -73,15 +68,18 @@ int main()
/* Buffering cores - handles audio data to/from EP's and gives/gets data to/from the audio I/O core */ /* Buffering cores - handles audio data to/from EP's and gives/gets data to/from the audio I/O core */
/* Note, this spawns two cores */ /* Note, this spawns two cores */
on tile[1]: XUA_Buffer(c_ep_out[1], c_ep_in[1], c_sof, c_aud_ctl, p_for_mclk_count, c_aud); on tile[1]: {
set_clock_src(clk_audio_mclk2, p_mclk_in2);
set_port_clock(p_for_mclk_count, clk_audio_mclk2);
start_clock(clk_audio_mclk2);
XUA_Buffer(c_ep_out[1], c_ep_in[1], c_sof, c_aud_ctl, p_for_mclk_count, c_aud);
}
/* IOHub core does most of the audio IO i.e. I2S (also serves as a hub for all audio) */ /* IOHub core does most of the audio IO i.e. I2S (also serves as a hub for all audio) */
on tile[0]: { on tile[0]: {
unsafe XUA_AudioHub(c_aud, p_mclk_in);
{
p_mclk_in = p_mclk_in_;
}
XUA_AudioHub(c_aud);
} }
} }

View File

@@ -10,10 +10,6 @@
#define MAX_FREQ 48000 #define MAX_FREQ 48000
#define EXCLUDE_USB_AUDIO_MAIN #define EXCLUDE_USB_AUDIO_MAIN
#define NUM_PDM_MICS 0
#define XUD_TILE 1
#define AUDIO_IO_TILE 0
#define MIXER 0
#define SPDIF_TX_INDEX 0 #define SPDIF_TX_INDEX 0
#define VENDOR_STR "XMOS" #define VENDOR_STR "XMOS"
@@ -26,6 +22,3 @@
#define AUDIO_CLASS_FALLBACK 0 #define AUDIO_CLASS_FALLBACK 0
#define BCD_DEVICE 0x1234 #define BCD_DEVICE 0x1234
#define XUA_DFU_EN 0 #define XUA_DFU_EN 0
/* TODO */
#define XUA_DFU XUA_DFU_EN

View File

@@ -1,6 +1,6 @@
Software Release License Agreement Software Release License Agreement
Copyright (c) 2017-2018, XMOS, All rights reserved. Copyright (c) 2017-2020, XMOS, All rights reserved.
BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software. BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software.

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved // Copyright (c) 2011-2019, XMOS Ltd, All rights reserved
#ifndef __XUA_AUDIOHUB_H__ #ifndef __XUA_AUDIOHUB_H__
#define __XUA_AUDIOHUB_H__ #define __XUA_AUDIOHUB_H__
@@ -17,12 +17,14 @@
* *
* \param c_aud Audio sample channel connected to the mixer() thread or the * \param c_aud Audio sample channel connected to the mixer() thread or the
* decouple() thread * decouple() thread
* \param p_mclk_in Master clock port
* \param c_dig channel connected to the clockGen() thread for * \param c_dig channel connected to the clockGen() thread for
* receiving/transmitting samples * receiving/transmitting samples
* \param c_config An optional channel that will be passed on to the * \param c_config An optional channel that will be passed on to the
* CODEC configuration functions. * CODEC configuration functions.
*/ */
void XUA_AudioHub(chanend ?c_aud void XUA_AudioHub(chanend ?c_aud
, in port p_mclk_in
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, chanend c_spdif_tx , chanend c_spdif_tx
#endif #endif

2
lib_xua/doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
rst/_build
pdf

View File

@@ -2,6 +2,7 @@
.. include:: ../../../README.rst .. include:: ../../../README.rst
==============
XMOS USB Audio XMOS USB Audio
============== ==============

View File

@@ -1,3 +1,4 @@
// Copyright (c) 2012-2018, XMOS Ltd, All rights reserved
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@@ -9,14 +9,17 @@
# #
# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc.. # You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-asm -fsubword-select MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-asm
OPTIONAL_HEADERS += xua_conf.h OPTIONAL_HEADERS += xua_conf.h
VERSION = 0.1.1 VERSION = 0.1.4
DEPENDENT_MODULES = lib_logging(>=2.1.0) lib_xud(>=0.1.0) DEPENDENT_MODULES = lib_logging(>=2.1.0) lib_xud(>=0.1.0)
#ignore host dir
SOURCE_DIRS = src/*
#core #core
EXCLUDE_FILES += descriptors_2.rst EXCLUDE_FILES += descriptors_2.rst
XCC_FLAGS_xua_endpoint0.c = -Os -mno-dual-issue $(XCC_FLAGS) XCC_FLAGS_xua_endpoint0.c = -Os -mno-dual-issue $(XCC_FLAGS)

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved // Copyright (c) 2011-2019, XMOS Ltd, All rights reserved
/** /**
* @file xua_audiohub.xc * @file xua_audiohub.xc
* @brief XMOS USB 2.0 Audio Reference Design. Audio Functions. * @brief XMOS USB 2.0 Audio Reference Design. Audio Functions.
@@ -100,7 +100,6 @@ extern buffered out port:32 p_bclk;
unsigned dsdMode = DSD_MODE_OFF; unsigned dsdMode = DSD_MODE_OFF;
/* Master clock input */ /* Master clock input */
extern unsafe port p_mclk_in;
extern in port p_mclk_in2; extern in port p_mclk_in2;
#if (XUA_SPDIF_TX_EN) #if (XUA_SPDIF_TX_EN)
@@ -1274,6 +1273,7 @@ static void dummy_deliver(chanend ?c_out, unsigned &command)
#endif #endif
void XUA_AudioHub(chanend ?c_mix_out void XUA_AudioHub(chanend ?c_mix_out
, in port p_mclk_in
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, chanend c_spdif_out , chanend c_spdif_out
#endif #endif

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved // Copyright (c) 2011-2020, XMOS Ltd, All rights reserved
#ifndef NO_USB #ifndef NO_USB
#include <xs1.h> #include <xs1.h>
#include "xua.h" #include "xua.h"
@@ -491,12 +491,12 @@ __builtin_unreachable();
totalSampsToWrite = speedRem >> 16; totalSampsToWrite = speedRem >> 16;
speedRem &= 0xffff; speedRem &= 0xffff;
# if 0 /* This patches up the case where the FB is well off, leading to totalSampsToWrite to also be off */
/* This can be startup case, bad mclk input etc */
if (totalSampsToWrite < 0 || totalSampsToWrite * g_curSubSlot_In * g_numUsbChan_In > g_maxPacketSize) if (totalSampsToWrite < 0 || totalSampsToWrite * g_curSubSlot_In * g_numUsbChan_In > g_maxPacketSize)
{ {
totalSampsToWrite = 0; totalSampsToWrite = 0;
} }
#endif
/* Calc slots left in fifo */ /* Calc slots left in fifo */
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr; space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
@@ -507,7 +507,6 @@ __builtin_unreachable();
space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr; space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr;
} }
//if((space_left > 0) && (space_left < (totalSampsToWrite * g_numUsbChan_In * g_curSubSlot_In + 4)))
if((space_left < (totalSampsToWrite * g_numUsbChan_In * g_curSubSlot_In + 4))) if((space_left < (totalSampsToWrite * g_numUsbChan_In * g_curSubSlot_In + 4)))
{ {
/* In pipe has filled its buffer - we need to overflow /* In pipe has filled its buffer - we need to overflow
@@ -567,7 +566,6 @@ __builtin_unreachable();
outUnderflow = (g_aud_from_host_rdptr == g_aud_from_host_wrptr); outUnderflow = (g_aud_from_host_rdptr == g_aud_from_host_wrptr);
if (!outUnderflow) if (!outUnderflow)
{ {
read_via_xc_ptr(aud_data_remaining_to_device, g_aud_from_host_rdptr); read_via_xc_ptr(aud_data_remaining_to_device, g_aud_from_host_rdptr);
@@ -595,6 +593,7 @@ static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned samp
asm volatile("stw %0, %1[0]"::"r"(mid),"r"(g_aud_to_host_zeros)); asm volatile("stw %0, %1[0]"::"r"(mid),"r"(g_aud_to_host_zeros));
#if XUA_DEBUG_BUFFER #if XUA_DEBUG_BUFFER
printstr("SetupZerosSendBuffer\n");
printstr("slotSize: "); printstr("slotSize: ");
printintln(slotSize); printintln(slotSize);
printstr("g_numUsbChan_In: "); printstr("g_numUsbChan_In: ");
@@ -613,10 +612,6 @@ static inline void SetupZerosSendBuffer(XUD_ep aud_to_host_usb_ep, unsigned samp
XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, mid); XUD_SetReady_InPtr(aud_to_host_usb_ep, p+4, mid);
} }
unsigned char tmpBuffer[1026];
#pragma unsafe arrays #pragma unsafe arrays
void XUA_Buffer_Decouple(chanend c_mix_out void XUA_Buffer_Decouple(chanend c_mix_out
#ifdef CHAN_BUFF_CTRL #ifdef CHAN_BUFF_CTRL
@@ -839,6 +834,7 @@ void XUA_Buffer_Decouple(chanend c_mix_out
/* Reset OUT buffer state */ /* Reset OUT buffer state */
SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start); SET_SHARED_GLOBAL(g_aud_from_host_rdptr, aud_from_host_fifo_start);
SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start); SET_SHARED_GLOBAL(g_aud_from_host_wrptr, aud_from_host_fifo_start);
SET_SHARED_GLOBAL(aud_data_remaining_to_device, 0);
/* NOTE, this is potentially usefull for UAC1 */ /* NOTE, this is potentially usefull for UAC1 */
unpackState = 0; unpackState = 0;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved // Copyright (c) 2011-2020, XMOS Ltd, All rights reserved
#ifndef NO_USB #ifndef NO_USB
#include <xs1.h> #include <xs1.h>
#include <print.h> #include <print.h>
@@ -38,8 +38,9 @@ extern unsigned int g_curSamFreqMultiplier;
#endif #endif
/* Global var for speed. Related to feedback. Used by input stream to determine IN packet size */ /* Initialise so we get a sensible packet size until we start properly calculating feedback in the SoF case */
unsigned g_speed; /* Without this, zero size packets fill the input FIFO and take time to clear out when feedback starts */
unsigned g_speed = (AUDIO_CLASS == 2) ? (DEFAULT_FREQ/8000) << 16 : (DEFAULT_FREQ/1000) << 16;
unsigned g_freqChange = 0; unsigned g_freqChange = 0;
unsigned feedbackValid = 0; unsigned feedbackValid = 0;
@@ -279,7 +280,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
#if (NUM_USB_CHAN_IN > 0) #if (NUM_USB_CHAN_IN > 0)
unsigned bufferIn = 1; unsigned bufferIn = 1;
#endif #endif
//unsigned remnant = 0;
unsigned sofCount = 0; unsigned sofCount = 0;
unsigned freqChange = 0; unsigned freqChange = 0;
@@ -469,8 +469,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
SET_SHARED_GLOBAL(g_freqChange_sampFreq, receivedSampleFreq); SET_SHARED_GLOBAL(g_freqChange_sampFreq, receivedSampleFreq);
} }
#if (AUDIO_CLASS == 2) #if (AUDIO_CLASS == 2)
else else if(cmd == SET_STREAM_FORMAT_IN)
if(cmd == SET_STREAM_FORMAT_IN)
{ {
unsigned formatChange_DataFormat = inuint(c_aud_ctl); unsigned formatChange_DataFormat = inuint(c_aud_ctl);
unsigned formatChange_NumChans = inuint(c_aud_ctl); unsigned formatChange_NumChans = inuint(c_aud_ctl);

View File

@@ -1,3 +1,4 @@
# Copyright (c) 2015-2019, XMOS Ltd, All rights reserved
def genstrings(outputChanCount, chanString, portString, structureString, adc_dac): def genstrings(outputChanCount, chanString, portString, structureString, adc_dac):

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2012-2018, XMOS Ltd, All rights reserved // Copyright (c) 2012-2019, XMOS Ltd, All rights reserved
#include "xua.h" /* Device specific defines */ #include "xua.h" /* Device specific defines */
#ifndef EXCLUDE_USB_AUDIO_MAIN #ifndef EXCLUDE_USB_AUDIO_MAIN
@@ -123,15 +123,7 @@ on tile[AUDIO_IO_TILE] : buffered out port:32 p_lrclk = PORT_I2S_LRCLK;
on tile[AUDIO_IO_TILE] : buffered out port:32 p_bclk = PORT_I2S_BCLK; on tile[AUDIO_IO_TILE] : buffered out port:32 p_bclk = PORT_I2S_BCLK;
#endif #endif
/* Note, declared unsafe as sometimes we want to share this port on tile[AUDIO_IO_TILE] : in port p_mclk_in = PORT_MCLK_IN;
e.g. PDM mics and I2S use same master clock IO */
on tile[AUDIO_IO_TILE] : port p_mclk_in_ = PORT_MCLK_IN;
/* TODO p_mclk_in should be delared as an unsafe resource */
unsafe
{
unsafe port p_mclk_in;
}
#ifndef NO_USB #ifndef NO_USB
on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT; on tile[XUD_TILE] : in port p_for_mclk_count = PORT_MCLK_COUNT;
@@ -185,6 +177,16 @@ on tile[SPDIF_TX_TILE] : clock clk_mst_spd = CLKBLK_SPDIF_TX;
on tile[XUD_TILE] : clock clk_spd_rx = CLKBLK_SPDIF_RX; on tile[XUD_TILE] : clock clk_spd_rx = CLKBLK_SPDIF_RX;
#endif #endif
#if (NUM_PDM_MICS > 0)
in port p_pdm_clk = PORT_PDM_CLK;
in buffered port:32 p_pdm_mics = PORT_PDM_DATA;
#if (PDM_TILE != AUDIO_IO_TILE)
/* If Mics and I2S are not the same tile we need a separate MCLK port */
in port p_pdm_mclk = PORT_PDM_MCLK;
#endif
#endif
#if(XUD_SERIES_SUPPORT == XUD_L_SERIES) && defined(ADAT_RX) #if(XUD_SERIES_SUPPORT == XUD_L_SERIES) && defined(ADAT_RX)
/* Cannot use default clock (CLKBLK_REF) for ADAT RX since it is tied to the /* Cannot use default clock (CLKBLK_REF) for ADAT RX since it is tied to the
60MHz USB clock on G/L series parts. */ 60MHz USB clock on G/L series parts. */
@@ -351,12 +353,6 @@ VENDOR_REQUESTS_PARAMS_DEC_
unsigned x; unsigned x;
thread_speed(); thread_speed();
/* TODO p_mclk_in should be delared as an unsafe resource */
unsafe
{
p_mclk_in = p_mclk_in_;
}
/* Attach mclk count port to mclk clock-block (for feedback) */ /* Attach mclk count port to mclk clock-block (for feedback) */
//set_port_clock(p_for_mclk_count, clk_audio_mclk); //set_port_clock(p_for_mclk_count, clk_audio_mclk);
#if(AUDIO_IO_TILE != XUD_TILE) #if(AUDIO_IO_TILE != XUD_TILE)
@@ -440,6 +436,9 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
, server interface i_dfu ?dfuInterface , server interface i_dfu ?dfuInterface
#endif #endif
#if (NUM_PDM_MICS > 0) #if (NUM_PDM_MICS > 0)
#if (PDM_TILE == AUDIO_IO_TILE)
, streaming chanend c_ds_output[2]
#endif
, chanend c_pdm_pcm , chanend c_pdm_pcm
#endif #endif
) )
@@ -454,6 +453,11 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#define c_dig_rx null #define c_dig_rx null
#endif #endif
#if (NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE)
/* Configure clocks ports - sharing mclk port with I2S */
xua_pdm_mic_config(p_mclk_in, p_pdm_clk, p_pdm_mics, clk_pdm);
#endif
par par
{ {
#ifdef MIXER #ifdef MIXER
@@ -472,6 +476,7 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#define AUDIO_CHANNEL c_aud_in #define AUDIO_CHANNEL c_aud_in
#endif #endif
XUA_AudioHub(AUDIO_CHANNEL XUA_AudioHub(AUDIO_CHANNEL
, p_mclk_in
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, c_spdif_tx , c_spdif_tx
#endif #endif
@@ -486,6 +491,9 @@ void usb_audio_io(chanend ?c_aud_in, chanend ?c_adc,
#endif #endif
); );
} }
#if (NUM_PDM_MICS > 0) && (PDM_TILE == AUDIO_IO_TILE)
xua_pdm_mic(c_ds_output, p_pdm_mics);
#endif
#if defined(SPDIF_RX) || defined(ADAT_RX) #if defined(SPDIF_RX) || defined(ADAT_RX)
{ {
@@ -614,11 +622,6 @@ int main()
on tile[AUDIO_IO_TILE]: on tile[AUDIO_IO_TILE]:
{ {
/* TODO p_mclk_in should be delared as an unsafe resource */
unsafe
{
p_mclk_in = p_mclk_in_;
}
usb_audio_io(c_mix_out, c_adc usb_audio_io(c_mix_out, c_adc
#if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE) #if (XUA_SPDIF_TX_EN) && (SPDIF_TX_TILE != AUDIO_IO_TILE)
, c_spdif_tx , c_spdif_tx
@@ -631,6 +634,9 @@ int main()
, dfuInterface , dfuInterface
#endif #endif
#if (NUM_PDM_MICS > 0) #if (NUM_PDM_MICS > 0)
#if (PDM_TILE == AUDIO_IO_TILE)
, c_ds_output
#endif
, c_pdm_pcm , c_pdm_pcm
#endif #endif
); );
@@ -706,16 +712,14 @@ int main()
#ifndef PDM_RECORD #ifndef PDM_RECORD
#if (NUM_PDM_MICS > 0) #if (NUM_PDM_MICS > 0)
#if (PDM_TILE != AUDIO_IO_TILE)
/* PDM Mics running on a separate to AudioHub */
on stdcore[PDM_TILE]: on stdcore[PDM_TILE]:
{ {
/* TODO p_mclk_in should be delared as an unsafe resource */ xua_pdm_mic_config(p_pdm_mclk, p_pdm_clk, p_pdm_mics, clk_pdm);
unsafe xua_pdm_mic(c_ds_output, p_pdm_mics);
{
p_mclk_in = p_mclk_in_;
}
pdm_mic(c_ds_output);
} }
#endif
#ifdef MIC_PROCESSING_USE_INTERFACE #ifdef MIC_PROCESSING_USE_INTERFACE
on stdcore[PDM_TILE].core[0]: pdm_buffer(c_ds_output, c_pdm_pcm, i_mic_process); on stdcore[PDM_TILE].core[0]: pdm_buffer(c_ds_output, c_pdm_pcm, i_mic_process);
#else #else

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2015-2018, XMOS Ltd, All rights reserved // Copyright (c) 2015-2019, XMOS Ltd, All rights reserved
#include "xua.h" #include "xua.h"
@@ -20,21 +20,6 @@
#define MAX_DECIMATION_FACTOR (96000/(MIN_FREQ/AUD_TO_MICS_RATIO)) #define MAX_DECIMATION_FACTOR (96000/(MIN_FREQ/AUD_TO_MICS_RATIO))
/* Hardware resources */
/* TODO these should be in main.xc with the rest of the resources */
in port p_pdm_clk = PORT_PDM_CLK;
in buffered port:32 p_pdm_mics = PORT_PDM_DATA;
#if (PDM_TILE != AUDIO_IO_TILE)
/* If Mics and I2S are on the same tile we'll share an MCLK port */
in port p_pdm_mclk = PORT_PDM_MCLK;
#else
extern unsafe port p_mclk_in;
#endif
/* Delcared in main.xc */
extern clock clk_pdm;
#ifndef MIC_BUFFER_DEPTH #ifndef MIC_BUFFER_DEPTH
#define MIC_BUFFER_DEPTH 1 #define MIC_BUFFER_DEPTH 1
#endif #endif
@@ -228,15 +213,8 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio)
#error MAX_FREQ > 48000 NOT CURRENTLY SUPPORTED #error MAX_FREQ > 48000 NOT CURRENTLY SUPPORTED
#endif #endif
void pdm_mic(streaming chanend c_ds_output[2]) void xua_pdm_mic_config(in port p_pdm_mclk, in port p_pdm_clk, buffered in port:32 p_pdm_mics, clock clk_pdm)
{ {
streaming chan c_4x_pdm_mic_0;
#if (NUM_PDM_MICS > 4)
streaming chan c_4x_pdm_mic_1;
#else
#define c_4x_pdm_mic_1 null
#endif
/* Mics expect a clock in the 3Mhz range, calculate the divide based on mclk */ /* Mics expect a clock in the 3Mhz range, calculate the divide based on mclk */
/* e.g. For a 48kHz range mclk we expect a 3072000Hz mic clock */ /* e.g. For a 48kHz range mclk we expect a 3072000Hz mic clock */
/* e.g. For a 44.1kHz range mclk we expect a 2822400Hz mic clock */ /* e.g. For a 44.1kHz range mclk we expect a 2822400Hz mic clock */
@@ -246,18 +224,21 @@ void pdm_mic(streaming chanend c_ds_output[2])
unsigned micDiv = MCLK_48/3072000; unsigned micDiv = MCLK_48/3072000;
#if (PDM_TILE != AUDIO_IO_TILE)
configure_clock_src_divide(clk_pdm, p_pdm_mclk, micDiv/2); configure_clock_src_divide(clk_pdm, p_pdm_mclk, micDiv/2);
#else
/* Sharing mclk port with I2S */
unsafe
{
configure_clock_src_divide(clk_pdm, (port) p_mclk_in, micDiv/2);
}
#endif
configure_port_clock_output(p_pdm_clk, clk_pdm); configure_port_clock_output(p_pdm_clk, clk_pdm);
configure_in_port(p_pdm_mics, clk_pdm); configure_in_port(p_pdm_mics, clk_pdm);
start_clock(clk_pdm); start_clock(clk_pdm);
}
void xua_pdm_mic(streaming chanend c_ds_output[2], buffered in port:32 p_pdm_mics)
{
streaming chan c_4x_pdm_mic_0;
#if (NUM_PDM_MICS > 4)
streaming chan c_4x_pdm_mic_1;
#else
#define c_4x_pdm_mic_1 null
#endif
par par
{ {
@@ -268,4 +249,5 @@ void pdm_mic(streaming chanend c_ds_output[2])
#endif #endif
} }
} }
#endif #endif

View File

@@ -1,7 +1,10 @@
// Copyright (c) 2015-2018, XMOS Ltd, All rights reserved // Copyright (c) 2015-2019, XMOS Ltd, All rights reserved
#include "mic_array.h" #include "mic_array.h"
/* Configures PDM ports/clocks */
void xua_pdm_mic_config(in port p_pdm_mclk, in port p_pdm_clk, buffered in port:32 p_pdm_mics, clock clk_pdm);
#ifdef MIC_PROCESSING_USE_INTERFACE #ifdef MIC_PROCESSING_USE_INTERFACE
/* Interface based user processing */ /* Interface based user processing */
typedef interface mic_process_if typedef interface mic_process_if
@@ -22,7 +25,7 @@ void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio
void user_pdm_process(server mic_process_if i_mic_data); void user_pdm_process(server mic_process_if i_mic_data);
/* PDM interface and decimation cores */ /* PDM interface and decimation cores */
void pdm_mic(streaming chanend c_ds_output[2]); void xua_pdm_mic(streaming chanend c_ds_output[2], buffered in port:32 p_pdm_mics);
#else #else
@@ -36,7 +39,7 @@ void user_pdm_init();
void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio); void pdm_buffer(streaming chanend c_ds_output[2], chanend c_audio);
/* PDM interface and decimation cores */ /* PDM interface and decimation cores */
void pdm_mic(streaming chanend c_ds_output[2]); void xua_pdm_mic(streaming chanend c_ds_output[2], buffered in port:32 p_pdm_mics);
#endif #endif

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved // Copyright (c) 2011-2019, XMOS Ltd, All rights reserved
#include <xs1.h> #include <xs1.h>
#include <platform.h> #include <platform.h>
#include <print.h> #include <print.h>
@@ -7,7 +7,7 @@
extern unsafe port p_mclk_in; extern in port p_mclk_in;
extern clock clk_audio_mclk; extern clock clk_audio_mclk;
extern clock clk_audio_bclk; extern clock clk_audio_bclk;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2013-2018, XMOS Ltd, All rights reserved // Copyright (c) 2013-2019, XMOS Ltd, All rights reserved
/* /*
Warnings relating to configuration defines located in this XC source file rather than the devicedefines.h header file in order to avoid multiple warnings being issued when the devicedefines.h header file is included in multiple files. Warnings relating to configuration defines located in this XC source file rather than the devicedefines.h header file in order to avoid multiple warnings being issued when the devicedefines.h header file is included in multiple files.
@@ -60,10 +60,6 @@ Warnings relating to configuration defines located in this XC source file rather
#warning AUDIO_CLASS not defined, using 2 #warning AUDIO_CLASS not defined, using 2
#endif #endif
#ifndef AUDIO_CLASS_FALLBACK
#warning AUDIO_CLASS_FALLBACK not defined, using 0 (i.e. disabled)
#endif
/* Sanity check on FS channel counts */ /* Sanity check on FS channel counts */
#if (NUM_USB_CHAN_OUT_FS > NUM_USB_CHAN_OUT) #if (NUM_USB_CHAN_OUT_FS > NUM_USB_CHAN_OUT)
#error NUM_USB_CHAN_OUT_FS expected to be less than or equal to NUM_USB_CHAN_OUT #error NUM_USB_CHAN_OUT_FS expected to be less than or equal to NUM_USB_CHAN_OUT

View File

@@ -1,35 +0,0 @@
def use_module(bld):
bld.env.XCC_FLAGS = bld.env.XCC_FLAGS + [
'-O3', '-DREF_CLK_FREQ=100', '-fasm-linenum', '-fcomment-asm',
'-fsubword-select', '-DXUD_FULL_PIDTABLE=1'
]
source = bld.path.ant_glob(
[
'src/**/*.xc', 'src/**/*.c', 'src/**/*.S'
],
excl=[
'**/descriptors_2.rst'
])
depends_on = [
'lib_logging(>=2.0.0)', 'lib_xassert(>=2.0.0)', 'lib_xud(>=1.0.0)'
]
bld.env['XCC_FLAGS_endpoint0.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_dbcalc.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_audiorequests.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_flashlib_user.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_audioports.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_audioports.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_dfu.xc'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.env['XCC_FLAGS_flash_interface.c'] = bld.env.XCC_FLAGS + ['-Os', '-mno-dual-issue']
bld.module(
source=source,
depends_on=depends_on,
includes=['api'],
optional_headers='xua_conf.h',
version='1.0.0')

View File

@@ -1,6 +1,6 @@
Software Release License Agreement Software Release License Agreement
Copyright (c) 2016-2018, XMOS, All rights reserved. Copyright (c) 2016-2019, XMOS, All rights reserved.
BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software. BY ACCESSING, USING, INSTALLING OR DOWNLOADING THE XMOS SOFTWARE, YOU AGREE TO BE BOUND BY THE FOLLOWING TERMS. IF YOU DO NOT AGREE TO THESE, DO NOT ATTEMPT TO DOWNLOAD, ACCESS OR USE THE XMOS Software.

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2016-2018, XMOS Ltd, All rights reserved // Copyright (c) 2016-2019, XMOS Ltd, All rights reserved
#include <platform.h> #include <platform.h>
#include <stdlib.h> #include <stdlib.h>
#include <print.h> #include <print.h>
@@ -79,18 +79,12 @@ buffered out port:32 p_bclk = PORT_I2S_BCLK; /* I2S L/R-clock */
/* Note, declared unsafe as sometimes we want to share this port /* Note, declared unsafe as sometimes we want to share this port
e.g. PDM mics and I2S use same master clock IO */ e.g. PDM mics and I2S use same master clock IO */
port p_mclk_in_ = PORT_MCLK_IN; in port p_mclk_in = PORT_MCLK_IN;
/* Clock-block declarations */ /* Clock-block declarations */
clock clk_audio_bclk = on tile[AUDIO_IO_TILE]: XS1_CLKBLK_1; /* Bit clock */ clock clk_audio_bclk = on tile[AUDIO_IO_TILE]: XS1_CLKBLK_1; /* Bit clock */
clock clk_audio_mclk = on tile[AUDIO_IO_TILE]: XS1_CLKBLK_2; /* Master clock */ clock clk_audio_mclk = on tile[AUDIO_IO_TILE]: XS1_CLKBLK_2; /* Master clock */
unsafe
{
/* TODO simplify this */
unsafe port p_mclk_in; /* Audio master clock input */
}
#ifdef SIMULATION #ifdef SIMULATION
#define INITIAL_SKIP_FRAMES 10 #define INITIAL_SKIP_FRAMES 10
#define TOTAL_TEST_FRAMES 100 #define TOTAL_TEST_FRAMES 100
@@ -224,13 +218,9 @@ int main(void)
par { par {
on tile[AUDIO_IO_TILE]: on tile[AUDIO_IO_TILE]:
{ {
unsafe
{
p_mclk_in = p_mclk_in_;
}
par par
{ {
XUA_AudioHub(c_out); XUA_AudioHub(c_out, p_mclk_in);
generator(c_checker, c_out); generator(c_checker, c_out);
checker(c_checker, 0); checker(c_checker, 0);
#ifdef SIMULATION #ifdef SIMULATION

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
# Copyright (c) 2018-2019, XMOS Ltd, All rights reserved
import xmostest import xmostest
import os.path import os.path

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2018-2019, XMOS Ltd, All rights reserved
import xmostest import xmostest
def runtest_one_config(env, format, i2s_role, num_chans_in, num_chans_out, sample_rate): def runtest_one_config(env, format, i2s_role, num_chans_in, num_chans_out, sample_rate):