Added start of AN00248
This commit is contained in:
135
examples/AN00248_xua_example_pdm_mics/LICENSE.txt
Normal file
135
examples/AN00248_xua_example_pdm_mics/LICENSE.txt
Normal file
@@ -0,0 +1,135 @@
|
||||
Software Release License Agreement
|
||||
|
||||
Copyright (c) 2018, 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.
|
||||
|
||||
Parties:
|
||||
|
||||
(1) XMOS Limited, incorporated and registered in England and Wales with company number 5494985 whose registered office is 107 Cheapside, London, EC2V 6DN (XMOS).
|
||||
|
||||
(2) An individual or legal entity exercising permissions granted by this License (Customer).
|
||||
|
||||
If you are entering into this Agreement on behalf of another legal entity such as a company, partnership, university, college etc. (for example, as an employee, student or consultant), you warrant that you have authority to bind that entity.
|
||||
|
||||
1. Definitions
|
||||
|
||||
"License" means this Software License and any schedules or annexes to it.
|
||||
|
||||
"License Fee" means the fee for the XMOS Software as detailed in any schedules or annexes to this Software License
|
||||
|
||||
"Licensee Modifications" means all developments and modifications of the XMOS Software developed independently by the Customer.
|
||||
|
||||
"XMOS Modifications" means all developments and modifications of the XMOS Software developed or co-developed by XMOS.
|
||||
|
||||
"XMOS Hardware" means any XMOS hardware devices supplied by XMOS from time to time and/or the particular XMOS devices detailed in any schedules or annexes to this Software License.
|
||||
|
||||
"XMOS Software" comprises the XMOS owned circuit designs, schematics, source code, object code, reference designs, (including related programmer comments and documentation, if any), error corrections, improvements, modifications (including XMOS Modifications) and updates.
|
||||
|
||||
The headings in this License do not affect its interpretation. Save where the context otherwise requires, references to clauses and schedules are to clauses and schedules of this License.
|
||||
|
||||
Unless the context otherwise requires:
|
||||
|
||||
- references to XMOS and the Customer include their permitted successors and assigns;
|
||||
- references to statutory provisions include those statutory provisions as amended or re-enacted; and
|
||||
- references to any gender include all genders.
|
||||
|
||||
Words in the singular include the plural and in the plural include the singular.
|
||||
|
||||
2. License
|
||||
|
||||
XMOS grants the Customer a non-exclusive license to use, develop, modify and distribute the XMOS Software with, or for the purpose of being used with, XMOS Hardware.
|
||||
|
||||
Open Source Software (OSS) must be used and dealt with in accordance with any license terms under which OSS is distributed.
|
||||
|
||||
3. Consideration
|
||||
|
||||
In consideration of the mutual obligations contained in this License, the parties agree to its terms.
|
||||
|
||||
4. Term
|
||||
|
||||
Subject to clause 12 below, this License shall be perpetual.
|
||||
|
||||
5. Restrictions on Use
|
||||
|
||||
The Customer will adhere to all applicable import and export laws and regulations of the country in which it resides and of the United States and United Kingdom, without limitation. The Customer agrees that it is its responsibility to obtain copies of and to familiarise itself fully with these laws and regulations to avoid violation.
|
||||
|
||||
6. Modifications
|
||||
|
||||
The Customer will own all intellectual property rights in the Licensee Modifications but will undertake to provide XMOS with any fixes made to correct any bugs found in the XMOS Software on a non-exclusive, perpetual and royalty free license basis.
|
||||
|
||||
XMOS will own all intellectual property rights in the XMOS Modifications.
|
||||
The Customer may only use the Licensee Modifications and XMOS Modifications on, or in relation to, XMOS Hardware.
|
||||
|
||||
7. Support
|
||||
|
||||
Support of the XMOS Software may be provided by XMOS pursuant to a separate support agreement.
|
||||
|
||||
8. Warranty and Disclaimer
|
||||
|
||||
The XMOS Software is provided "AS IS" without a warranty of any kind. XMOS and its licensors' entire liability and Customer's exclusive remedy under this warranty to be determined in XMOS's sole and absolute discretion, will be either (a) the corrections of defects in media or replacement of the media, or (b) the refund of the license fee paid (if any).
|
||||
|
||||
Whilst XMOS gives the Customer the ability to load their own software and applications onto XMOS devices, the security of such software and applications when on the XMOS devices is the Customer's own responsibility and any breach of security shall not be deemed a defect or failure of the hardware. XMOS shall have no liability whatsoever in relation to any costs, damages or other losses Customer may incur as a result of any breaches of security in relation to your software or applications.
|
||||
|
||||
XMOS AND ITS LICENSORS DISCLAIM ALL OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY/ SATISFACTORY QUALITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS ARE HELD TO BE LEGALLY INVALID UNDER APPLICABLE LAW.
|
||||
|
||||
9. High Risk Activities
|
||||
|
||||
The XMOS Software is not designed or intended for use in conjunction with on-line control equipment in hazardous environments requiring fail-safe performance, including without limitation the operation of nuclear facilities, aircraft navigation or communication systems, air traffic control, life support machines, or weapons systems (collectively "High Risk Activities") in which the failure of the XMOS Software could lead directly to death, personal injury, or severe physical or environmental damage. XMOS and its licensors specifically disclaim any express or implied warranties relating to use of the XMOS Software in connection with High Risk Activities.
|
||||
|
||||
10. Liability
|
||||
|
||||
TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, NEITHER XMOS NOR ITS LICENSORS SHALL BE LIABLE FOR ANY LOST REVENUE, BUSINESS, PROFIT, CONTRACTS OR DATA, ADMINISTRATIVE OR OVERHEAD EXPENSES, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES HOWEVER CAUSED AND REGARDLESS OF THEORY OF LIABILITY ARISING OUT OF THIS LICENSE, EVEN IF XMOS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event shall XMOS's liability to the Customer whether in contract, tort (including negligence), or otherwise exceed the License Fee.
|
||||
|
||||
Customer agrees to indemnify, hold harmless, and defend XMOS and its licensors from and against any claims or lawsuits, including attorneys' fees and any other liabilities, demands, proceedings, damages, losses, costs, expenses fines and charges which are made or brought against or incurred by XMOS as a result of your use or distribution of the Licensee Modifications or your use or distribution of XMOS Software, or any development of it, other than in accordance with the terms of this License.
|
||||
|
||||
11. Ownership
|
||||
|
||||
The copyrights and all other intellectual and industrial property rights for the protection of information with respect to the XMOS Software (including the methods and techniques on which they are based) are retained by XMOS and/or its licensors. Nothing in this Agreement serves to transfer such rights. Customer may not sell, mortgage, underlet, sublease, sublicense, lend or transfer possession of the XMOS Software in any way whatsoever to any third party who is not bound by this Agreement.
|
||||
|
||||
12. Termination
|
||||
|
||||
Either party may terminate this License at any time on written notice to the other if the other:
|
||||
|
||||
- is in material or persistent breach of any of the terms of this License and either that breach is incapable of remedy, or the other party fails to remedy that breach within 30 days after receiving written notice requiring it to remedy that breach; or
|
||||
|
||||
- is unable to pay its debts (within the meaning of section 123 of the Insolvency Act 1986), or becomes insolvent, or is subject to an order or a resolution for its liquidation, administration, winding-up or dissolution (otherwise than for the purposes of a solvent amalgamation or reconstruction), or has an administrative or other receiver, manager, trustee, liquidator, administrator or similar officer appointed over all or any substantial part of its assets, or enters into or proposes any composition or arrangement with its creditors generally, or is subject to any analogous event or proceeding in any applicable jurisdiction.
|
||||
|
||||
Termination by either party in accordance with the rights contained in clause 12 shall be without prejudice to any other rights or remedies of that party accrued prior to termination.
|
||||
|
||||
On termination for any reason:
|
||||
|
||||
- all rights granted to the Customer under this License shall cease;
|
||||
- the Customer shall cease all activities authorised by this License;
|
||||
- the Customer shall immediately pay any sums due to XMOS under this License; and
|
||||
- the Customer shall immediately destroy or return to the XMOS (at the XMOS's option) all copies of the XMOS Software then in its possession, custody or control and, in the case of destruction, certify to XMOS that it has done so.
|
||||
|
||||
Clauses 5, 8, 9, 10 and 11 shall survive any effective termination of this Agreement.
|
||||
|
||||
13. Third party rights
|
||||
|
||||
No term of this License is intended to confer a benefit on, or to be enforceable by, any person who is not a party to this license.
|
||||
|
||||
14. Confidentiality and publicity
|
||||
|
||||
Each party shall, during the term of this License and thereafter, keep confidential all, and shall not use for its own purposes nor without the prior written consent of the other disclose to any third party any, information of a confidential nature (including, without limitation, trade secrets and information of commercial value) which may become known to such party from the other party and which relates to the other party, unless such information is public knowledge or already known to such party at the time of disclosure, or subsequently becomes public knowledge other than by breach of this license, or subsequently comes lawfully into the possession of such party from a third party.
|
||||
|
||||
The terms of this license are confidential and may not be disclosed by the Customer without the prior written consent of XMOS.
|
||||
The provisions of clause 14 shall remain in full force and effect notwithstanding termination of this license for any reason.
|
||||
|
||||
15. Entire agreement
|
||||
|
||||
This License and the documents annexed as appendices to this License or otherwise referred to herein contain the whole agreement between the parties relating to the subject matter hereof and supersede all prior agreements, arrangements and understandings between the parties relating to that subject matter.
|
||||
|
||||
16. Assignment
|
||||
|
||||
The Customer shall not assign this License or any of the rights granted under it without XMOS's prior written consent.
|
||||
|
||||
17. Governing law and jurisdiction
|
||||
|
||||
This License shall be governed by and construed in accordance with English law and each party hereby submits to the non-exclusive jurisdiction of the English courts.
|
||||
|
||||
This License has been entered into on the date stated at the beginning of it.
|
||||
|
||||
Schedule
|
||||
XMOS application note AN00248 software
|
||||
21
examples/AN00248_xua_example_pdm_mics/Makefile
Normal file
21
examples/AN00248_xua_example_pdm_mics/Makefile
Normal file
@@ -0,0 +1,21 @@
|
||||
APP_NAME = app_xua_simple
|
||||
|
||||
TARGET = mic_array_ref.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 -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_xua lib_xud lib_mic_array
|
||||
|
||||
#=============================================================================
|
||||
# The following part of the Makefile includes the common build infrastructure
|
||||
# for compiling XMOS applications. You should not need to edit below here.
|
||||
|
||||
XMOS_MAKE_PATH ?= ../..
|
||||
include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
|
||||
|
||||
37
examples/AN00248_xua_example_pdm_mics/README.rst
Normal file
37
examples/AN00248_xua_example_pdm_mics/README.rst
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
Using lib_xua with lib_mic_array
|
||||
================================
|
||||
|
||||
.. version:: 0.1.0
|
||||
|
||||
Summary
|
||||
-------
|
||||
|
||||
This applicaition note describes how to use ``lib_mic_array`` in conjunction with ``lib_xua``
|
||||
to implement a USB Audio device with the ability to record from multiple PDM microphones.
|
||||
|
||||
Required tools and libraries
|
||||
............................
|
||||
|
||||
.. appdeps::
|
||||
|
||||
Required hardware
|
||||
.................
|
||||
|
||||
The example code provided with the application has been implemented
|
||||
and tested on the xCORE-200 Array Microphone 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
|
||||
|
||||
|
||||
279
examples/AN00248_xua_example_pdm_mics/doc/rst/AN00248.rst
Normal file
279
examples/AN00248_xua_example_pdm_mics/doc/rst/AN00248.rst
Normal file
@@ -0,0 +1,279 @@
|
||||
.. include:: ../../README.rst
|
||||
|
||||
|newpage|
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
Introduction
|
||||
............
|
||||
|
||||
The XMOS USB Audio (XUA) library provides an implemention of USB Audio Class versions 1.0 and 2.0.
|
||||
|
||||
This application note demonstrates the implementation of a basic USB Audio Device with
|
||||
S/PDIF transmit functionality the xCORE-200 MC Audio board.
|
||||
|
||||
To reduce complexity this application note does not enable any other audio interfaces other than recording
|
||||
from PDM microphones (i.e. no I2S and the on board DAC is not configured.
|
||||
|
||||
Readers are encouraged to read applicaition note AN00246 in conjunction with this application note.
|
||||
|
||||
|
||||
The Makefile
|
||||
------------
|
||||
|
||||
To start using ``lib_xua``, you need to add ``lib_xua`` to the Makefile. ``lib_mic_array`` should also be
|
||||
added for this application example::
|
||||
|
||||
USED_MODULES = .. lib_xua lib_mic_array ...
|
||||
|
||||
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 executed, 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"
|
||||
|
||||
The application uses the S/PDIF transmitter from ``lib_spdif``. This header
|
||||
must be included in your code.
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: /* From lib_spdif
|
||||
:end-on: include "spdif.h"
|
||||
|
||||
Declarations
|
||||
------------
|
||||
|
||||
Allocating hardware resources for lib_xua
|
||||
.........................................
|
||||
|
||||
A minimal implementation of a USB Audio device, without I2S functionalilty,
|
||||
using ``lib_xua`` requires the follow pins:
|
||||
|
||||
- Audio Master clock (from clock source to xCORE)
|
||||
|
||||
On an xCORE the pins are controlled by ``ports``. The application therefore declares a
|
||||
port for the master clock input signal.
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: /* Lib_xua port declaration
|
||||
:end-on: in port p_mclk_in
|
||||
|
||||
``lib_xua`` also requires two ports for internally calculating USB feedback. Please refer to
|
||||
the ``lib_xua`` library documentation for further details. The additonal input port for the master
|
||||
clock is required since USB and S/PDIF do not reside of the same tiles on the example hardware.
|
||||
|
||||
These ports are declared as follows:
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: /* Resources for USB feedback
|
||||
:end-on: in port p_mclk_in_usb
|
||||
|
||||
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_usb
|
||||
|
||||
Again, for the same reasoning as the master-clock ports, two master-clock clock-blocks are required
|
||||
- one on each tile.
|
||||
|
||||
|
||||
Allocating hardware resources for lib_spdif
|
||||
...........................................
|
||||
|
||||
The S/PDIF transmitter requires a single (buffered) 1-bit port:
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: /* Lib_spdif port
|
||||
:end-on: buffered out port
|
||||
|
||||
This port must be clocked from the audio master clock. This application note chooses to declare
|
||||
an extra clock-block as follows:
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: clock clk_spdif_tx
|
||||
:end-before: /* Lib_xua
|
||||
|
||||
|
||||
Other declarations
|
||||
..................
|
||||
|
||||
``lib_xua`` currently requires the manual declaration of tables for the endpoint types for
|
||||
``lib_xud`` and the calling the main XUD function 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
|
||||
|
||||
Configuring lib_xua
|
||||
-------------------
|
||||
|
||||
S/PDIF Tx functionality must be ``lib_xua``
|
||||
|
||||
``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
|
||||
|
||||
To enable S/PDIF funtionality ``XUA_SPDIF_TX_EN`` must be set to a non-zero value.
|
||||
|
||||
These parameters are set via defines in an optional ``xua_conf.h`` header file. For this simple application the
|
||||
complete contents of this file are as follows:
|
||||
|
||||
.. literalinclude:: xua_conf.h
|
||||
:start-on: // Copyright
|
||||
:end-on: #endif
|
||||
|
||||
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 first be declared:
|
||||
|
||||
.. literalinclude:: app_xua_simple.xc
|
||||
:start-on: /* Channels for lib_xud
|
||||
:end-on: chan c_spdif_tx
|
||||
|
||||
The rest of the ``main()`` function starts all of 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. Note, since there is no I2S funcitonality in this example this task simply forwards samples to the
|
||||
SPDIF transmitter task. In addition the ``spdif_tx()`` task is also run.
|
||||
|
||||
Note that the ``spdif_tx_port_config()`` function is called before a nested ``par`` of ``spdif_tx()`` and ``XUA_AudioHub()``.
|
||||
This is because of the "shared" nature of ``p_mclk_in`` and avoids a parrallel usage check failure by the XMOS toolchain.
|
||||
|
||||
|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 |
2
examples/AN00248_xua_example_pdm_mics/doc/rst/xdoc.conf
Normal file
2
examples/AN00248_xua_example_pdm_mics/doc/rst/xdoc.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
XMOSNEWSTYLE=1
|
||||
SOURCE_INCLUDE_DIRS=../../src
|
||||
119
examples/AN00248_xua_example_pdm_mics/src/app_xua_simple.xc
Normal file
119
examples/AN00248_xua_example_pdm_mics/src/app_xua_simple.xc
Normal file
@@ -0,0 +1,119 @@
|
||||
// Copyright (c) 2017-2018, XMOS Ltd, All rights reserved
|
||||
|
||||
/* A very simple *example* of a USB audio application (and as such is un-verified for production)
|
||||
*
|
||||
* It uses the main blocks from the lib_xua with the addition of PDM mic support using lib_mic_array
|
||||
*
|
||||
* - No DFU
|
||||
*
|
||||
*/
|
||||
|
||||
#include <xs1.h>
|
||||
#include <platform.h>
|
||||
|
||||
#include "xua.h"
|
||||
#include "xud_device.h"
|
||||
|
||||
/* From lib_mic_array */
|
||||
#include "mic_array.h"
|
||||
|
||||
/* Lib_mic_array declarations. Note, the defines come from the xn file */
|
||||
in port p_pdm_clk = PORT_PDM_CLK; /* Port for PDM mic clock */
|
||||
in port p_pdm_mclk = PORT_PDM_MCLK; /* Master clock for PDM mics */
|
||||
|
||||
in buffered port:32 p_pdm_mics = PORT_PDM_DATA; /* Port for PDM mic data */
|
||||
|
||||
clock clk_pdm = on tile[0]: XS1_CLKBLK_1; /* Clock-block for PDM mics */
|
||||
|
||||
|
||||
/* Lib_xua port declarations. Note, the defines come from the xn file */
|
||||
in port p_mclk_in = PORT_MCLK_IN; /* Master clock for the audio IO tile */
|
||||
|
||||
/* Resources for USB feedback */
|
||||
in port p_for_mclk_count = PORT_MCLK_COUNT; /* Extra port for counting master clock ticks */
|
||||
|
||||
/* Clock-block declarations */
|
||||
clock clk_audio_mclk = 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 */
|
||||
XUD_EpType epTypeTableOut[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE, XUD_EPTYPE_ISO};
|
||||
XUD_EpType epTypeTableIn[] = {XUD_EPTYPE_CTL | XUD_STATUS_ENABLE, XUD_EPTYPE_ISO};
|
||||
|
||||
int main()
|
||||
{
|
||||
/* Channels for lib_xud */
|
||||
chan c_ep_out[2];
|
||||
chan c_ep_in[2];
|
||||
|
||||
/* Channel for communicating SOF notifications from XUD to the Buffering cores */
|
||||
chan c_sof;
|
||||
|
||||
/* Channel for audio data between buffering cores and AudioHub/IO core */
|
||||
chan c_aud;
|
||||
|
||||
/* Channel for communicating control messages from EP0 to the rest of the device (via the buffering cores) */
|
||||
chan c_aud_ctl;
|
||||
|
||||
/* Array of channels for communication between PDM mic decimator task(s) and the XUA mic buffer task */
|
||||
streaming chan c_ds_output[2];
|
||||
|
||||
/* Channel for communcation between XUA_AudioHub() and the XUA mic buffer task */
|
||||
chan c_mic_pcm;
|
||||
|
||||
par
|
||||
{
|
||||
/* Low level USB device layer core */
|
||||
on tile[1]: XUD_Main(c_ep_out, 2, c_ep_in, 2, c_sof, epTypeTableOut, epTypeTableIn, null, null, -1, XUD_SPEED_HS, XUD_PWR_BUS);
|
||||
|
||||
/* Endpoint 0 core from lib_xua */
|
||||
/* Note, since we are not using many features we pass in null for quite a few params.. */
|
||||
on tile[1]: XUA_Endpoint0(c_ep_out[0], c_ep_in[0], c_aud_ctl, null, null, null, null);
|
||||
|
||||
on tile[1]:
|
||||
{
|
||||
/* Connect master-clock clock-block to clock-block pin */
|
||||
set_clock_src(clk_audio_mclk, p_mclk_in); /* Clock clock-block from mclk pin */
|
||||
set_port_clock(p_for_mclk_count, clk_audio_mclk); /* Clock the "count" port from the clock block */
|
||||
/* Note, AudioHub() will start the clock */
|
||||
|
||||
par
|
||||
{
|
||||
/* Buffering task - handles audio data to/from EP's and gives/gets data to/from the audio I/O core */
|
||||
/* Note, this spawns two cores */
|
||||
XUA_Buffer(c_ep_out[1], c_ep_in[1], c_sof, c_aud_ctl, p_for_mclk_count, c_aud);
|
||||
|
||||
/* AudioHub/IO core does most of the audio IO i.e. I2S (also serves as a hub for all audio) */
|
||||
/* Note, since we are not using I2S we pass in null for LR and Bit clock ports and the I2S dataline ports */
|
||||
XUA_AudioHub(c_aud, clk_audio_mclk, null, p_mclk_in, null, null, null, null, c_mic_pcm);
|
||||
}
|
||||
}
|
||||
|
||||
on tile[0]:
|
||||
{
|
||||
streaming chan c_4x_pdm_mic_0;
|
||||
streaming chan c_4x_pdm_mic_1;
|
||||
|
||||
configure_clock_src_divide(clk_pdm, p_pdm_mclk, 4); /* Master clock to PDM clock divide */
|
||||
configure_port_clock_output(p_pdm_clk, clk_pdm);
|
||||
configure_in_port(p_pdm_mics, clk_pdm);
|
||||
start_clock(clk_pdm);
|
||||
|
||||
par
|
||||
{
|
||||
/* PDM receive I/O task */
|
||||
mic_array_pdm_rx(p_pdm_mics, c_4x_pdm_mic_0, c_4x_pdm_mic_1);
|
||||
|
||||
/* Run two decimator tasks for 8 mics */
|
||||
mic_array_decimate_to_pcm_4ch(c_4x_pdm_mic_0, c_ds_output[0], MIC_ARRAY_NO_INTERNAL_CHANS);
|
||||
mic_array_decimate_to_pcm_4ch(c_4x_pdm_mic_1, c_ds_output[1], MIC_ARRAY_NO_INTERNAL_CHANS);
|
||||
|
||||
XUA_PdmBuffer(c_ds_output, c_mic_pcm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
28
examples/AN00248_xua_example_pdm_mics/src/audiohw.xc
Normal file
28
examples/AN00248_xua_example_pdm_mics/src/audiohw.xc
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <xs1.h>
|
||||
#include <assert.h>
|
||||
#include <platform.h>
|
||||
|
||||
#include "xua.h"
|
||||
|
||||
/* 0: DAC reset */
|
||||
/* 1: Ethernet Phy reset */
|
||||
on tile[1] : out port p_gpio = XS1_PORT_4F;
|
||||
|
||||
void AudioHwInit()
|
||||
{
|
||||
/* DAC in reset */
|
||||
p_gpio <: 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Configures the external audio hardware for the required sample frequency */
|
||||
void AudioHwConfig(unsigned samFreq, unsigned mClk, unsigned dsdMode,
|
||||
unsigned sampRes_DAC, unsigned sampRes_ADC)
|
||||
{
|
||||
/* Note, without any config the Cirrus 2100 will output it's 24.576MHz ref clock
|
||||
to the Aux output - which we will use for mclk */
|
||||
|
||||
return;
|
||||
}
|
||||
//:
|
||||
94
examples/AN00248_xua_example_pdm_mics/src/mic_array_ref.xn
Normal file
94
examples/AN00248_xua_example_pdm_mics/src/mic_array_ref.xn
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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" ManuallySpecifiedRouting="true">
|
||||
<Type>Board</Type>
|
||||
<Name>XS2 MC Audio</Name>
|
||||
<Declarations>
|
||||
<Declaration>tileref tile[2]</Declaration>
|
||||
<Declaration>tileref usb_tile</Declaration>
|
||||
</Declarations>
|
||||
<Packages>
|
||||
<Package id="0" Type="XS2-UnA-512-FB236">
|
||||
<Nodes>
|
||||
<Node Id="0" InPackageId="0" Type="XS2-L16A-512" Oscillator="24MHz" SystemFrequency="500MHz" referencefrequency="100MHz">
|
||||
<Boot>
|
||||
<Source Location="SPI: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"/>
|
||||
|
||||
<!-- Mic related ports -->
|
||||
<Port Location="XS1_PORT_1E" Name="PORT_PDM_CLK"/>
|
||||
<Port Location="XS1_PORT_8B" Name="PORT_PDM_DATA"/>
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_PDM_MCLK"/>
|
||||
|
||||
<!-- LED ports -->
|
||||
<Port Location="XS1_PORT_8C" Name="PORT_LED0_TO_7"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_LED8"/>
|
||||
<Port Location="XS1_PORT_1L" Name="PORT_LED9"/>
|
||||
<Port Location="XS1_PORT_8D" Name="PORT_LED10_TO_12"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_LED_OEN"/>
|
||||
|
||||
<!-- Button ports -->
|
||||
<Port Location="XS1_PORT_4A" Name="PORT_BUT_A_TO_D"/>
|
||||
|
||||
</Tile>
|
||||
|
||||
<Tile Number="1" Reference="tile[1]">
|
||||
<Port Location="XS1_PORT_1H" Name="PORT_USB_TX_READYIN"/>
|
||||
<Port Location="XS1_PORT_1J" Name="PORT_USB_CLK"/>
|
||||
<Port Location="XS1_PORT_1K" Name="PORT_USB_TX_READYOUT"/>
|
||||
<Port Location="XS1_PORT_1I" Name="PORT_USB_RX_READY"/>
|
||||
<Port Location="XS1_PORT_1E" Name="PORT_USB_FLAG0"/>
|
||||
<Port Location="XS1_PORT_1F" Name="PORT_USB_FLAG1"/>
|
||||
<Port Location="XS1_PORT_1G" Name="PORT_USB_FLAG2"/>
|
||||
<Port Location="XS1_PORT_8A" Name="PORT_USB_TXD"/>
|
||||
<Port Location="XS1_PORT_8B" Name="PORT_USB_RXD"/>
|
||||
|
||||
<!-- Audio Ports -->
|
||||
<Port Location="XS1_PORT_4D" Name="PORT_PLL_REF"/>
|
||||
<Port Location="XS1_PORT_1O" Name="PORT_MCLK_IN"/>
|
||||
<Port Location="XS1_PORT_1N" Name="PORT_I2S_LRCLK"/>
|
||||
<Port Location="XS1_PORT_1M" Name="PORT_I2S_BCLK"/>
|
||||
<Port Location="XS1_PORT_1P" Name="PORT_I2S_DAC0"/>
|
||||
<Port Location="XS1_PORT_4E" Name="PORT_I2C"/>
|
||||
<Port Location="XS1_PORT_16B" Name="PORT_MCLK_COUNT"/>
|
||||
</Tile>
|
||||
</Node>
|
||||
<Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
|
||||
</Node>
|
||||
</Nodes>
|
||||
<Links>
|
||||
<Link Encoding="5wire">
|
||||
<LinkEndpoint NodeId="0" Link="8" Delays="52clk,52clk"/>
|
||||
<LinkEndpoint NodeId="1" Link="XL0" Delays="1clk,1clk"/>
|
||||
</Link>
|
||||
</Links>
|
||||
</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="4,4" Flags="XSCOPE">
|
||||
<LinkEndpoint NodeId="0" Link="XL0"/>
|
||||
<LinkEndpoint NodeId="2" Chanend="1"/>
|
||||
</Link>
|
||||
</Links>
|
||||
<ExternalDevices>
|
||||
<Device NodeId="0" Tile="0" Class="SQIFlash" Name="bootFlash" Type="S25FL116K">
|
||||
<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"/>
|
||||
<JTAGDevice NodeId="1"/>
|
||||
</JTAGChain>
|
||||
</Network>
|
||||
29
examples/AN00248_xua_example_pdm_mics/src/xua_conf.h
Normal file
29
examples/AN00248_xua_example_pdm_mics/src/xua_conf.h
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2017-2018, XMOS Ltd, All rights reserved
|
||||
|
||||
#ifndef _XUA_CONF_H_
|
||||
#define _XUA_CONF_H_
|
||||
|
||||
#define NUM_USB_CHAN_OUT 0
|
||||
#define NUM_USB_CHAN_IN 8
|
||||
#define I2S_CHANS_DAC 0
|
||||
#define I2S_CHANS_ADC 0
|
||||
#define MCLK_441 (512 * 44100)
|
||||
#define MCLK_48 (512 * 48000)
|
||||
#define MIN_FREQ 48000
|
||||
#define MAX_FREQ 48000
|
||||
|
||||
#define EXCLUDE_USB_AUDIO_MAIN
|
||||
|
||||
#define NUM_PDM_MICS 8
|
||||
#define VENDOR_STR "XMOS"
|
||||
#define VENDOR_ID 0x20B1
|
||||
#define PRODUCT_STR_A2 "XUA PDM Example"
|
||||
#define PRODUCT_STR_A1 "XUA PDM Example"
|
||||
#define PID_AUDIO_1 1
|
||||
#define PID_AUDIO_2 2
|
||||
#define AUDIO_CLASS 2
|
||||
#define AUDIO_CLASS_FALLBACK 0
|
||||
#define BCD_DEVICE 0x1234
|
||||
#define XUA_DFU_EN 0
|
||||
|
||||
#endif
|
||||
7
examples/AN00248_xua_example_pdm_mics/src/xud_conf.h
Normal file
7
examples/AN00248_xua_example_pdm_mics/src/xud_conf.h
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright (c) 2017-2018, XMOS Ltd, All rights reserved
|
||||
|
||||
#include "xua_conf.h"
|
||||
|
||||
/* TODO */
|
||||
#define XUD_UAC_NUM_USB_CHAN_OUT NUM_USB_CHAN_OUT
|
||||
#define XUD_UAC_NUM_USB_CHAN_IN NUM_USB_CHAN_IN
|
||||
Reference in New Issue
Block a user