forked from PAWPAW-Mirror/lib_xua
Compare commits
21 Commits
v0.1.1alph
...
v0.1.2alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
711efc8be9 | ||
|
|
566cf12c3f | ||
|
|
b6460a266e | ||
|
|
69319f706d | ||
|
|
3098e8bce5 | ||
|
|
4a8ddb2e40 | ||
|
|
0afcb6d65c | ||
|
|
bc91e21189 | ||
|
|
29deebd07a | ||
|
|
7027dc2ad4 | ||
|
|
0674880c11 | ||
|
|
4f6a54f3b0 | ||
|
|
90f9588fe0 | ||
|
|
a19086f0d4 | ||
|
|
8a8cc4168a | ||
|
|
b3aa9dc009 | ||
|
|
6c091a85d3 | ||
|
|
eb0ea91979 | ||
|
|
1a324855a0 | ||
|
|
2ae49afa17 | ||
|
|
b2e64ba9fc |
@@ -1,6 +1,15 @@
|
||||
lib_xua Change Log
|
||||
==================
|
||||
|
||||
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
|
||||
-----
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
SOURCE_INCLUDE_DIRS=../host/xmosdfu
|
||||
SOURCE_INCLUDE_DIRS=../lib_xua/host/xmosdfu
|
||||
|
||||
@@ -4,7 +4,7 @@ Building the XMOS DFU loader - macOS
|
||||
====================================
|
||||
|
||||
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
|
||||
file ``xmosdfu.cpp``
|
||||
|
||||
@@ -3,13 +3,14 @@ APP_NAME = app_xua_simple
|
||||
TARGET = xk-audio-216-mc.xn
|
||||
|
||||
# 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 -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 -fxscope
|
||||
|
||||
# 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 = 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_device_control lib_xud module_i2c_shared module_i2c_single_port module_locks
|
||||
|
||||
#=============================================================================
|
||||
# The following part of the Makefile includes the common build infrastructure
|
||||
34
examples/AN00246_xua_example/README.rst
Normal file
34
examples/AN00246_xua_example/README.rst
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
How to use the lib_xua_library
|
||||
===============================
|
||||
|
||||
.. version:: 0.1.0
|
||||
|
||||
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
|
||||
|
||||
|
||||
240
examples/AN00246_xua_example/doc/AN00246.rst
Normal file
240
examples/AN00246_xua_example/doc/AN00246.rst
Normal file
@@ -0,0 +1,240 @@
|
||||
.. include:: ../../README.rst
|
||||
|
||||
|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|
|
||||
229
examples/AN00246_xua_example/doc/rst/AN00246.rst
Normal file
229
examples/AN00246_xua_example/doc/rst/AN00246.rst
Normal file
@@ -0,0 +1,229 @@
|
||||
.. include:: ../../README.rst
|
||||
|
||||
|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
|
||||
.............
|
||||
|
||||
|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|
|
||||
BIN
examples/AN00246_xua_example/doc/rst/images/hw_setup.jpg
Normal file
BIN
examples/AN00246_xua_example/doc/rst/images/hw_setup.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 75 KiB |
2
examples/AN00246_xua_example/doc/rst/xdoc.conf
Normal file
2
examples/AN00246_xua_example/doc/rst/xdoc.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
XMOSNEWSTYLE=1
|
||||
SOURCE_INCLUDE_DIRS=../../src
|
||||
@@ -13,8 +13,8 @@
|
||||
#include <xs1.h>
|
||||
#include <platform.h>
|
||||
|
||||
#include "xud_device.h"
|
||||
#include "xua.h"
|
||||
#include "xud_device.h"
|
||||
|
||||
/* Port declarations. Note, the defines come from the xn file */
|
||||
buffered out port:32 p_i2s_dac[] = {PORT_I2S_DAC0}; /* I2S Data-line(s) */
|
||||
@@ -24,19 +24,21 @@ buffered out port:32 p_bclk = PORT_I2S_BCLK; /* I2S L/R-clock */
|
||||
|
||||
/* Note, declared unsafe as sometimes we want to share this port
|
||||
e.g. PDM mics and I2S use same master clock IO */
|
||||
port p_mclk_in_ = PORT_MCLK_IN;
|
||||
port p_mclk_in_ = PORT_MCLK_IN;
|
||||
|
||||
unsafe
|
||||
{
|
||||
/* TODO simplify this */
|
||||
unsafe port p_mclk_in; /* Audio master clock input */
|
||||
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_mclk_in2 = PORT_MCLK_IN2;
|
||||
|
||||
/* Clock-block declarations */
|
||||
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_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
|
||||
* if the endpoint wishes to be informed of USB bus resets */
|
||||
@@ -55,7 +57,7 @@ int main()
|
||||
/* Channel for audio data between buffering cores and audio IO core */
|
||||
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;
|
||||
|
||||
par
|
||||
@@ -63,7 +65,6 @@ int main()
|
||||
/* Low level USB device layer core */
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2,
|
||||
c_sof, epTypeTableOut, epTypeTableIn,
|
||||
/* TODO rm me! */
|
||||
null, null, -1 ,
|
||||
XUD_SPEED_HS, XUD_PWR_BUS);
|
||||
|
||||
@@ -73,7 +74,14 @@ int main()
|
||||
|
||||
/* 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 */
|
||||
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) */
|
||||
on tile[0]: {
|
||||
@@ -10,10 +10,6 @@
|
||||
#define MAX_FREQ 48000
|
||||
|
||||
#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 VENDOR_STR "XMOS"
|
||||
@@ -26,6 +22,3 @@
|
||||
#define AUDIO_CLASS_FALLBACK 0
|
||||
#define BCD_DEVICE 0x1234
|
||||
#define XUA_DFU_EN 0
|
||||
|
||||
/* TODO */
|
||||
#define XUA_DFU XUA_DFU_EN
|
||||
@@ -18,9 +18,7 @@ device_pid_t pidList[] = {
|
||||
{ "XMOS_L1_AUDIO1_PID", 0x0003},
|
||||
{ "XMOS_L2_AUDIO2_PID", 0x0004},
|
||||
{ "XMOS_SU1_AUDIO2_PID", 0x0008},
|
||||
{ "XMOS_U8_MFA_AUDIO2_PID", 0x000A},
|
||||
{ "XMOS_VF_SPK_BASE_AUDIO2_PID", 0x0010},
|
||||
{ "XMOS_VF_SPK_BASE_AUDIO1_PID", 0x0011}
|
||||
{ "XMOS_U8_MFA_AUDIO2_PID", 0x000A}
|
||||
};
|
||||
|
||||
unsigned int XMOS_DFU_IF = 0;
|
||||
@@ -13,10 +13,13 @@ MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3 -DREF_CLK_FREQ=100 -fasm-linenum -fcomment-a
|
||||
|
||||
OPTIONAL_HEADERS += xua_conf.h
|
||||
|
||||
VERSION = 0.1.1
|
||||
VERSION = 0.1.2
|
||||
|
||||
DEPENDENT_MODULES = lib_logging(>=2.1.0) lib_xud(>=0.1.0)
|
||||
|
||||
#ignore host dir
|
||||
SOURCE_DIRS = src/*
|
||||
|
||||
#core
|
||||
EXCLUDE_FILES += descriptors_2.rst
|
||||
XCC_FLAGS_xua_endpoint0.c = -Os -mno-dual-issue $(XCC_FLAGS)
|
||||
|
||||
@@ -491,12 +491,12 @@ __builtin_unreachable();
|
||||
totalSampsToWrite = speedRem >> 16;
|
||||
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)
|
||||
{
|
||||
totalSampsToWrite = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Calc slots left in fifo */
|
||||
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;
|
||||
}
|
||||
|
||||
//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)))
|
||||
{
|
||||
/* 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);
|
||||
|
||||
|
||||
if (!outUnderflow)
|
||||
{
|
||||
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));
|
||||
|
||||
#if XUA_DEBUG_BUFFER
|
||||
printstr("SetupZerosSendBuffer\n");
|
||||
printstr("slotSize: ");
|
||||
printintln(slotSize);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned char tmpBuffer[1026];
|
||||
|
||||
#pragma unsafe arrays
|
||||
void XUA_Buffer_Decouple(chanend c_mix_out
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
@@ -839,6 +834,7 @@ void XUA_Buffer_Decouple(chanend c_mix_out
|
||||
/* Reset OUT buffer state */
|
||||
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(aud_data_remaining_to_device, 0);
|
||||
|
||||
/* NOTE, this is potentially usefull for UAC1 */
|
||||
unpackState = 0;
|
||||
|
||||
@@ -279,7 +279,6 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
#if (NUM_USB_CHAN_IN > 0)
|
||||
unsigned bufferIn = 1;
|
||||
#endif
|
||||
//unsigned remnant = 0;
|
||||
unsigned sofCount = 0;
|
||||
unsigned freqChange = 0;
|
||||
|
||||
@@ -469,8 +468,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
|
||||
SET_SHARED_GLOBAL(g_freqChange_sampFreq, receivedSampleFreq);
|
||||
}
|
||||
#if (AUDIO_CLASS == 2)
|
||||
else
|
||||
if(cmd == SET_STREAM_FORMAT_IN)
|
||||
else if(cmd == SET_STREAM_FORMAT_IN)
|
||||
{
|
||||
unsigned formatChange_DataFormat = inuint(c_aud_ctl);
|
||||
unsigned formatChange_NumChans = inuint(c_aud_ctl);
|
||||
|
||||
Reference in New Issue
Block a user