diff --git a/lib_gpio/.gitignore b/lib_gpio/.gitignore
new file mode 100644
index 0000000..565eda2
--- /dev/null
+++ b/lib_gpio/.gitignore
@@ -0,0 +1,21 @@
+.*.swp
+**/.build*/*
+**/bin/*
+*.o
+*.xe
+*.vcd
+*.s
+*.xi
+*.i
+*.a
+**/_build/
+**/run_*.log
+**/pdf/*
+*.pyc
+test_results.csv
+**/.venv/**
+
+# waf build files
+.lock-waf_*
+.waf-*/
+build/
diff --git a/lib_gpio/CHANGELOG.rst b/lib_gpio/CHANGELOG.rst
new file mode 100644
index 0000000..67ee84c
--- /dev/null
+++ b/lib_gpio/CHANGELOG.rst
@@ -0,0 +1,44 @@
+GPIO library change log
+=======================
+
+2.2.0
+-----
+
+ * CHANGED: Update tests to support tools 15.x.x
+
+2.1.0
+-----
+
+ * CHANGED: Use XMOS Public Licence Version 1
+
+2.0.1
+-----
+
+ * CHANGED: Pin Python package versions
+ * REMOVED: not necessary cpanfile
+
+2.0.0
+-----
+
+ * CHANGED: Build files updated to support new "xcommon" behaviour in xwaf.
+
+1.1.0
+-----
+
+ * CHANGE: Minor documentation clarifications
+ * CHANGE: Update to dependency (lib_xassert moved to 3.0.0)
+
+1.0.1
+-----
+
+ * CHANGE: Update to source code license and copyright
+
+1.0.0
+-----
+
+ * Initial version
+
+ * Changes to dependencies:
+
+ - lib_xassert: Added dependency 2.0.0
+
diff --git a/lib_gpio/Jenkinsfile b/lib_gpio/Jenkinsfile
new file mode 100644
index 0000000..cb88594
--- /dev/null
+++ b/lib_gpio/Jenkinsfile
@@ -0,0 +1,55 @@
+@Library('xmos_jenkins_shared_library@v0.32.0') _
+
+getApproval()
+
+pipeline {
+ agent {
+ label 'x86_64&&linux'
+ }
+ environment {
+ REPO = 'lib_gpio'
+ VIEW = getViewName(REPO)
+ }
+ options {
+ skipDefaultCheckout()
+ }
+ 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}") {
+ xcoreAllAppsBuild('examples')
+ dir("${REPO}") {
+ runXdoc('doc')
+ }
+ }
+
+ // Archive all the generated .pdf docs
+ archiveArtifacts artifacts: "${REPO}/**/pdf/*.pdf", fingerprint: true, allowEmptyArchive: true
+ }
+ }
+ }
+ post {
+ success {
+ updateViewfiles()
+ }
+ cleanup {
+ xcoreCleanSandbox()
+ }
+ }
+}
diff --git a/lib_gpio/LICENSE.rst b/lib_gpio/LICENSE.rst
new file mode 100644
index 0000000..ca48f20
--- /dev/null
+++ b/lib_gpio/LICENSE.rst
@@ -0,0 +1,84 @@
+*******************************
+XMOS PUBLIC LICENCE: Version 1
+*******************************
+
+Subject to the conditions and limitations below, permission is hereby granted by XMOS LIMITED (“XMOS”), free of charge, to any person or entity obtaining a copy of the XMOS Software.
+
+**1. Definitions**
+
+**“Applicable Patent Rights”** means: (a) where XMOS is the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to XMOS and (ii) that cover subject matter contained in the Software, but only to the extent it is necessary to use, reproduce or distribute the Software without infringement; and (b) where you are the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to you and (ii) that cover the subject matter contained in your Derivatives, taken alone or in combination with the Software.
+
+**“Compiled Code”** means any compiled, binary, machine readable or executable version of the Source Code.
+
+**“Contributor”** means any person or entity that creates or contributes to the creation of Derivatives.
+
+**“Derivatives”** means any addition to, deletion from and/or change to the substance, structure of the Software, any previous Derivatives, the combination of the Derivatives and the Software and/or any respective portions thereof.
+
+**“Source Code”** means the human readable code that is suitable for making modifications but excluding any Compiled Code.
+
+**“Software”** means the software and associated documentation files which XMOS makes available and which contain a notice identifying the software as original XMOS software and referring to the software being subject to the terms of this XMOS Public Licence.
+
+This Licence refers to XMOS Software and does not relate to any XMOS hardware or devices which are protected by intellectual property rights (including patent and trade marks) which may be sold to you under a separate agreement.
+
+
+**2. Licence**
+
+**Permitted Uses, Conditions and Restrictions.** Subject to the conditions below, XMOS grants you a worldwide, royalty free, non-exclusive licence, to the extent of any Patent Rights to do the following:
+
+2.1 **Unmodified Software.** You may use, copy, display, publish, distribute and make available unmodified copies of the Software:
+
+2.1.1 for personal or academic, non-commercial purposes; or
+
+2.1.2 for commercial purposes provided the Software is at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.1.1 and 2.1.2):
+
+(a) you must retain and reproduce in all copies of the Software the copyright and proprietary notices and disclaimers of XMOS as they appear in the Software, and keep intact all notices and disclaimers in the Software files that refer to this Licence; and
+
+(b) you must include a copy of this Licence with every copy of the Software and documentation you publish, distribute and make available and you may not offer or impose any terms on such Software that alter or restrict this Licence or the intent of such Licence, except as permitted below (Additional Terms).
+
+The licence above does not include any Compiled Code which XMOS may make available under a separate support and licence agreement.
+
+2.2 **Derivatives.** You may create and modify Derivatives and use, copy, display, publish, distribute and make available Derivatives:
+
+2.2.1 for personal or academic, non-commercial purposes; or
+
+2.2.2 for commercial purposes, provided the Derivatives are at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.2.1 and 2.2.2):
+
+(a) you must comply with the terms of clause 2.1 with respect to the Derivatives;
+
+(b) you must copy (to the extent it doesn’t already exist) the notice below in each file of the Derivatives, and ensure all the modified files carry prominent notices stating that you have changed the files and the date of any change; and
+
+(c) if you sublicence, distribute or otherwise make the Software and/or the Derivatives available for commercial purposes, you must provide that the Software and Derivatives are at all times used on a device designed, licensed or developed by XMOS.
+
+Without limitation to these terms and clause 3 below, the Source Code and Compiled Code to your Derivatives may at your discretion (but without obligation) be released, copied, displayed, published, distributed and made available; and if you elect to do so, it must be under the terms of this Licence including the terms of the licence at clauses 2.2.1, 2.2.2 and clause 3 below.
+
+2.3 **Distribution of Executable Versions.** If you distribute or make available Derivatives, you must include a prominent notice in the code itself as well as in all related documentation, stating that the Source Code of the Software from which the Derivatives are based is available under the terms of this Licence, with information on how and where to obtain such Source Code.
+
+**3. Your Grant of Rights.** In consideration and as a condition to this Licence, you grant to any person or entity receiving or distributing any Derivatives, a non-exclusive, royalty free, perpetual, irrevocable license under your Applicable Patent Rights and all other intellectual property rights owned or controlled by you, to use, copy, display, publish, distribute and make available your Derivatives of the same scope and extent as XMOS’s licence under clause 2.2 above.
+
+**4. Combined Products.** You may create a combined product by combining Software, Derivatives and other code not covered by this Licence as a single application or product. In such instance, you must comply with the requirements of this Licence for any portion of the Software and/or Derivatives.
+
+**5. Additional Terms.** You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations and/or other rights consistent with the term of this Licence (“Additional Terms”) to any legitimate recipients of the Software and/or Derivatives. The terms on which you provide such Additional Terms are on your sole responsibility and you shall indemnify, defend and hold XMOS harmless against any claims asserted against XMOS.
+
+**6. New Versions.** XMOS may publish revised and/or new versions of this Licence from time to time to accommodate changes to the Licence terms, new versions, updates and bug fixes of the Software. Each version will be given a distinguishing version number. Once Software has been published under a particular version of this Licence, you may continue to use it under the terms of that version. You may also choose to use the latest version of the Software under any subsequent version published by XMOS. Only XMOS shall have the right to modify these terms.
+
+**7. IPR and Ownership**
+Any rights, including all intellectual property rights and all trademarks not expressly granted herein are reserved in full by the authors or copyright holders. Any requests for additional permissions by XMOS including any rights to use XMOS trademarks, should be made (without obligation) to XMOS at **support@xmos.com**
+
+Nothing herein shall limit any rights that XMOS is otherwise entitled to under the doctrines of patent exhaustion, implied license, or legal estoppel. Neither the name of the authors, the copyright holders or any contributors may be used to endorse or promote any Derivatives from this Software without specific written permission. Any attempt to deal with the Software which does not comply with this Licence shall be void and shall automatically terminate any rights granted under this licence (including any licence of any intellectual property rights granted herein).
+Subject to the licences granted under this Licence any Contributor retains all rights, title and interest in and to any Derivatives made by Contributor subject to the underlying rights of XMOS in the Software. XMOS shall retain all rights, title and interest in the Software and any Derivatives made by XMOS (“XMOS Derivatives”). XMOS Derivatives will not automatically be subject to this Licence and XMOS shall be entitled to licence such rights on any terms (without obligation) as it sees fit.
+
+**8. Termination**
+
+8.1 This Licence will automatically terminate immediately, without notice to you, if:
+
+(a) you fail to comply with the terms of this Licence; and/or
+
+(b) you directly or indirectly commence any action for patent or intellectual property right infringement against XMOS, or any parent, group, affiliate or subsidiary of XMOS; provided XMOS did not first commence an action or patent infringement against you in that instance; and/or
+
+(c) the terms of this Licence are held by any court of competent jurisdiction to be unenforceable in whole or in part.
+
+**9. Critical Applications.** Unless XMOS has agreed in writing with you an agreement specifically governing use of the Goods in military, aerospace, automotive or medically related functions (collectively and individually hereinafter referred to as "Special Use"), any permitted use of the Software excludes Special Use. Notwithstanding any agreement between XMOS and you for Special Use, Special Use shall be at your own risk, and you shall fully indemnify XMOS against any damages, losses, costs and claims (direct and indirect) arising out of any Special Use.
+
+**10. NO WARRANTY OR SUPPORT.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XMOS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, WARRANTY, CIVIL TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE INCLUDING GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND NOT WITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE. IN SOME JURISDICTIONS PARTIES ARE UNABLE TO LIMIT LIABILTY IN THIS WAY, IF THIS APPLIES TO YOUR JURISDICTION THIS LIABILITY CLAUSE ABOVE MAY NOT APPLY. NOTWITHSTANDING THE ABOVE, IN NO EVENT SHALL XMOS’s TOTAL LIABILITY TO YOU FOR ALL DAMAGES, LOSS OR OTHERWISE EXCEED $50.
+
+**11. Governing Law and Jurisdiction.** This Licence constitutes the entire agreement between the parties with respect to the subject matter hereof. The Licence shall be governed by the laws of England and the conflict of laws and UN Convention on Contracts for the International Sale of Goods, shall not apply.
diff --git a/lib_gpio/README.rst b/lib_gpio/README.rst
new file mode 100644
index 0000000..f6c65b8
--- /dev/null
+++ b/lib_gpio/README.rst
@@ -0,0 +1,39 @@
+GPIO Library
+============
+
+Overview
+--------
+
+The XMOS GPIO library allows you to access xCORE ports as low-speed GPIO.
+
+Although xCORE ports can be directly accessed via the xC programming
+language this library allows more flexible usage. In particular, it
+allows splitting a multi-pin output/input port to be able to use
+the individual pins independently. It also allows accessing ports
+across separate XMOS tiles or separate XMOS chips.
+
+Features
+........
+
+ * Abstract interface to GPIO functionality of XMOS ports
+ * Allow control of individual bits of multi-bit ports
+ * Allow access to ports across tiles
+
+Operating modes
+...............
+
+ * Multi-bit output for individual access to the pins of a multi-bit output port
+ * Multi-bit input for individual access to the pins of a multi-bit input port
+ * Multi-bit input for individual access to the pins of a multi-bit
+ input port allowing the application to react to events on those pins
+
+Software version and dependencies
+.................................
+
+The CHANGELOG contains information about the current and previous versions.
+For a list of direct dependencies, look for DEPENDENT_MODULES in lib_gpio/module_build_info.
+
+Related application notes
+.........................
+
+Currently there are none.
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/.cproject b/lib_gpio/examples/app_gpio_flashing_leds/.cproject
new file mode 100644
index 0000000..d0a86d3
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/.cproject
@@ -0,0 +1,528 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/.project b/lib_gpio/examples/app_gpio_flashing_leds/.project
new file mode 100644
index 0000000..9f60a51
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/.project
@@ -0,0 +1,75 @@
+
+
+ gpio_flashing_leds
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/LICENSE.rst b/lib_gpio/examples/app_gpio_flashing_leds/LICENSE.rst
new file mode 100644
index 0000000..ca48f20
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/LICENSE.rst
@@ -0,0 +1,84 @@
+*******************************
+XMOS PUBLIC LICENCE: Version 1
+*******************************
+
+Subject to the conditions and limitations below, permission is hereby granted by XMOS LIMITED (“XMOS”), free of charge, to any person or entity obtaining a copy of the XMOS Software.
+
+**1. Definitions**
+
+**“Applicable Patent Rights”** means: (a) where XMOS is the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to XMOS and (ii) that cover subject matter contained in the Software, but only to the extent it is necessary to use, reproduce or distribute the Software without infringement; and (b) where you are the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to you and (ii) that cover the subject matter contained in your Derivatives, taken alone or in combination with the Software.
+
+**“Compiled Code”** means any compiled, binary, machine readable or executable version of the Source Code.
+
+**“Contributor”** means any person or entity that creates or contributes to the creation of Derivatives.
+
+**“Derivatives”** means any addition to, deletion from and/or change to the substance, structure of the Software, any previous Derivatives, the combination of the Derivatives and the Software and/or any respective portions thereof.
+
+**“Source Code”** means the human readable code that is suitable for making modifications but excluding any Compiled Code.
+
+**“Software”** means the software and associated documentation files which XMOS makes available and which contain a notice identifying the software as original XMOS software and referring to the software being subject to the terms of this XMOS Public Licence.
+
+This Licence refers to XMOS Software and does not relate to any XMOS hardware or devices which are protected by intellectual property rights (including patent and trade marks) which may be sold to you under a separate agreement.
+
+
+**2. Licence**
+
+**Permitted Uses, Conditions and Restrictions.** Subject to the conditions below, XMOS grants you a worldwide, royalty free, non-exclusive licence, to the extent of any Patent Rights to do the following:
+
+2.1 **Unmodified Software.** You may use, copy, display, publish, distribute and make available unmodified copies of the Software:
+
+2.1.1 for personal or academic, non-commercial purposes; or
+
+2.1.2 for commercial purposes provided the Software is at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.1.1 and 2.1.2):
+
+(a) you must retain and reproduce in all copies of the Software the copyright and proprietary notices and disclaimers of XMOS as they appear in the Software, and keep intact all notices and disclaimers in the Software files that refer to this Licence; and
+
+(b) you must include a copy of this Licence with every copy of the Software and documentation you publish, distribute and make available and you may not offer or impose any terms on such Software that alter or restrict this Licence or the intent of such Licence, except as permitted below (Additional Terms).
+
+The licence above does not include any Compiled Code which XMOS may make available under a separate support and licence agreement.
+
+2.2 **Derivatives.** You may create and modify Derivatives and use, copy, display, publish, distribute and make available Derivatives:
+
+2.2.1 for personal or academic, non-commercial purposes; or
+
+2.2.2 for commercial purposes, provided the Derivatives are at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.2.1 and 2.2.2):
+
+(a) you must comply with the terms of clause 2.1 with respect to the Derivatives;
+
+(b) you must copy (to the extent it doesn’t already exist) the notice below in each file of the Derivatives, and ensure all the modified files carry prominent notices stating that you have changed the files and the date of any change; and
+
+(c) if you sublicence, distribute or otherwise make the Software and/or the Derivatives available for commercial purposes, you must provide that the Software and Derivatives are at all times used on a device designed, licensed or developed by XMOS.
+
+Without limitation to these terms and clause 3 below, the Source Code and Compiled Code to your Derivatives may at your discretion (but without obligation) be released, copied, displayed, published, distributed and made available; and if you elect to do so, it must be under the terms of this Licence including the terms of the licence at clauses 2.2.1, 2.2.2 and clause 3 below.
+
+2.3 **Distribution of Executable Versions.** If you distribute or make available Derivatives, you must include a prominent notice in the code itself as well as in all related documentation, stating that the Source Code of the Software from which the Derivatives are based is available under the terms of this Licence, with information on how and where to obtain such Source Code.
+
+**3. Your Grant of Rights.** In consideration and as a condition to this Licence, you grant to any person or entity receiving or distributing any Derivatives, a non-exclusive, royalty free, perpetual, irrevocable license under your Applicable Patent Rights and all other intellectual property rights owned or controlled by you, to use, copy, display, publish, distribute and make available your Derivatives of the same scope and extent as XMOS’s licence under clause 2.2 above.
+
+**4. Combined Products.** You may create a combined product by combining Software, Derivatives and other code not covered by this Licence as a single application or product. In such instance, you must comply with the requirements of this Licence for any portion of the Software and/or Derivatives.
+
+**5. Additional Terms.** You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations and/or other rights consistent with the term of this Licence (“Additional Terms”) to any legitimate recipients of the Software and/or Derivatives. The terms on which you provide such Additional Terms are on your sole responsibility and you shall indemnify, defend and hold XMOS harmless against any claims asserted against XMOS.
+
+**6. New Versions.** XMOS may publish revised and/or new versions of this Licence from time to time to accommodate changes to the Licence terms, new versions, updates and bug fixes of the Software. Each version will be given a distinguishing version number. Once Software has been published under a particular version of this Licence, you may continue to use it under the terms of that version. You may also choose to use the latest version of the Software under any subsequent version published by XMOS. Only XMOS shall have the right to modify these terms.
+
+**7. IPR and Ownership**
+Any rights, including all intellectual property rights and all trademarks not expressly granted herein are reserved in full by the authors or copyright holders. Any requests for additional permissions by XMOS including any rights to use XMOS trademarks, should be made (without obligation) to XMOS at **support@xmos.com**
+
+Nothing herein shall limit any rights that XMOS is otherwise entitled to under the doctrines of patent exhaustion, implied license, or legal estoppel. Neither the name of the authors, the copyright holders or any contributors may be used to endorse or promote any Derivatives from this Software without specific written permission. Any attempt to deal with the Software which does not comply with this Licence shall be void and shall automatically terminate any rights granted under this licence (including any licence of any intellectual property rights granted herein).
+Subject to the licences granted under this Licence any Contributor retains all rights, title and interest in and to any Derivatives made by Contributor subject to the underlying rights of XMOS in the Software. XMOS shall retain all rights, title and interest in the Software and any Derivatives made by XMOS (“XMOS Derivatives”). XMOS Derivatives will not automatically be subject to this Licence and XMOS shall be entitled to licence such rights on any terms (without obligation) as it sees fit.
+
+**8. Termination**
+
+8.1 This Licence will automatically terminate immediately, without notice to you, if:
+
+(a) you fail to comply with the terms of this Licence; and/or
+
+(b) you directly or indirectly commence any action for patent or intellectual property right infringement against XMOS, or any parent, group, affiliate or subsidiary of XMOS; provided XMOS did not first commence an action or patent infringement against you in that instance; and/or
+
+(c) the terms of this Licence are held by any court of competent jurisdiction to be unenforceable in whole or in part.
+
+**9. Critical Applications.** Unless XMOS has agreed in writing with you an agreement specifically governing use of the Goods in military, aerospace, automotive or medically related functions (collectively and individually hereinafter referred to as "Special Use"), any permitted use of the Software excludes Special Use. Notwithstanding any agreement between XMOS and you for Special Use, Special Use shall be at your own risk, and you shall fully indemnify XMOS against any damages, losses, costs and claims (direct and indirect) arising out of any Special Use.
+
+**10. NO WARRANTY OR SUPPORT.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XMOS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, WARRANTY, CIVIL TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE INCLUDING GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND NOT WITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE. IN SOME JURISDICTIONS PARTIES ARE UNABLE TO LIMIT LIABILTY IN THIS WAY, IF THIS APPLIES TO YOUR JURISDICTION THIS LIABILITY CLAUSE ABOVE MAY NOT APPLY. NOTWITHSTANDING THE ABOVE, IN NO EVENT SHALL XMOS’s TOTAL LIABILITY TO YOU FOR ALL DAMAGES, LOSS OR OTHERWISE EXCEED $50.
+
+**11. Governing Law and Jurisdiction.** This Licence constitutes the entire agreement between the parties with respect to the subject matter hereof. The Licence shall be governed by the laws of England and the conflict of laws and UN Convention on Contracts for the International Sale of Goods, shall not apply.
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/Makefile b/lib_gpio/examples/app_gpio_flashing_leds/Makefile
new file mode 100644
index 0000000..773d1a3
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/Makefile
@@ -0,0 +1,26 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+APP_NAME = gpio_flashing_leds
+
+# The USED_MODULES variable lists other module used by the application.
+USED_MODULES = lib_gpio
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+XCC_FLAGS = -O2 -g
+
+# The XCORE_ARM_PROJECT variable, if set to 1, configures this
+# project to create both xCORE and ARM binaries.
+XCORE_ARM_PROJECT = 0
+
+XMOS_MAKE_PATH ?= ../..
+-include $(XMOS_MAKE_PATH)/xcommon/module_xcommon/build/Makefile.common
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/src/main.xc b/lib_gpio/examples/app_gpio_flashing_leds/src/main.xc
new file mode 100644
index 0000000..5a2c185
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/src/main.xc
@@ -0,0 +1,29 @@
+// Copyright 2014-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+
+port p_led1 = XS1_PORT_1A;
+port p_led2 = XS1_PORT_1B;
+
+void flash_leds(client output_gpio_if led1, client output_gpio_if led2)
+{
+ while (1) {
+ led1.output(1);
+ led2.output(0);
+ delay_milliseconds(200);
+ led1.output(0);
+ led2.output(1);
+ delay_milliseconds(200);
+ }
+}
+
+int main() {
+ interface output_gpio_if i_led1[1], i_led2[1];
+ par {
+ output_gpio(i_led1, 1, p_led1, null);
+ output_gpio(i_led2, 1, p_led2, null);
+ flash_leds(i_led1[0], i_led2[0]);
+ }
+ return 0;
+}
diff --git a/lib_gpio/examples/app_gpio_flashing_leds/wscript b/lib_gpio/examples/app_gpio_flashing_leds/wscript
new file mode 100644
index 0000000..2121c33
--- /dev/null
+++ b/lib_gpio/examples/app_gpio_flashing_leds/wscript
@@ -0,0 +1,14 @@
+def options(opt):
+ opt.load('xwaf.xcommon')
+
+def configure(conf):
+ conf.load('xwaf.xcommon')
+
+def build(bld):
+ bld.do_xcommon()
+
+def dist(ctx):
+ ctx.load('xwaf.xcommon')
+
+def distcheck(ctx):
+ ctx.load('xwaf.xcommon')
diff --git a/lib_gpio/lib_gpio/.cproject b/lib_gpio/lib_gpio/.cproject
new file mode 100644
index 0000000..dace2e2
--- /dev/null
+++ b/lib_gpio/lib_gpio/.cproject
@@ -0,0 +1,492 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+ -f .makefile
+ all
+ true
+ true
+ true
+
+
+ xmake
+ -f .makefile
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_gpio/lib_gpio/.project b/lib_gpio/lib_gpio/.project
new file mode 100644
index 0000000..14d4cda
--- /dev/null
+++ b/lib_gpio/lib_gpio/.project
@@ -0,0 +1,75 @@
+
+
+ lib_gpio
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_gpio/lib_gpio/api/gpio.h b/lib_gpio/lib_gpio/api/gpio.h
new file mode 100644
index 0000000..1fc94b2
--- /dev/null
+++ b/lib_gpio/lib_gpio/api/gpio.h
@@ -0,0 +1,157 @@
+// Copyright 2014-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef __gpio_h__
+#define __gpio_h__
+#include
+#include
+
+#ifdef __XC__
+
+typedef uint16_t gpio_time_t;
+
+/** This interface provides access to a GPIO that can perform input
+ operations only. All GPIOs are single bit. */
+typedef interface input_gpio_if
+{
+ /** Perform an input on a GPIO
+ *
+ * \returns The value input from the port in the least significant bit.
+ * The rest of the value will be zero extended.
+ */
+ unsigned input(void);
+
+ /** Perform an input on a GPIO and get a timestamp
+ *
+ * \param timestamp This pass-by-reference parameter will be set
+ * to the time the value was input. This timestamp
+ * is the 16-bit port timer value. The port timer is
+ * driven at the rate of the port clock.
+ *
+ * \returns The value input from the port in the least significant bit.
+ * The rest of the value will be zero extended.
+ */
+ unsigned input_and_timestamp(gpio_time_t ×tamp);
+
+ /** Request an event when the pin is a certain value.
+ *
+ * This function will cause a notification to occur when the pins
+ * match the specified value.
+ *
+ * \param val The least significant bit represents the 1-bit value to match.
+ */
+ [[clears_notification]]
+ void event_when_pins_eq(unsigned val);
+
+ /** A pin event has occurred.
+ *
+ * This notification will occur when a pin event has occurred.
+ * Events can be requested using the event_when_pins_eq() call.
+ */
+ [[notification]]
+ slave void event(void);
+
+} input_gpio_if;
+
+/** This interface provides access to a GPIO that can perform output
+ operations only. All GPIOs are single bit. */
+typedef interface output_gpio_if
+{
+ /** Perform an output on a GPIO.
+ *
+ * \param data The value to be output. The least significant bit
+ * represents the 1-bit value to be output.
+ */
+ void output(unsigned data);
+
+ /** Perform an output on a GPIO and get a timestamp of when the output
+ * occurs.
+ *
+ * \param data The value to be output. The least significant bit
+ * represents the 1-bit value to be output.
+ *
+ * \returns The time the value was input. This timestamp
+ * is the 16-bit port timer value. The port timer is driven
+ * at the rate of the port clock.
+ */
+ gpio_time_t output_and_timestamp(unsigned data);
+} output_gpio_if;
+
+
+/** Task that splits a multi-bit port into several 1-bit GPIO interfaces.
+ *
+ * This component allows other tasks to access the individual bits of
+ * a multi-bit output port.
+ *
+ * \param i The array of interfaces to connect to other tasks.
+ * \param n The number of interfaces connected.
+ * \param p The output port to be split.
+ * \param pin_map This array maps the connected interfaces to the pin
+ * of the port. For example, if 3 clients are connected
+ * to split a 8-bit port and the array {2,5,3} is supplied.
+ * Then bit 2 will go to interface 0, bit 5 to inteface 1
+ * and bit 3 to inteface 2. If null is supplied for this
+ * argument then the pin map is assumed to be {0,1,2...}.
+ */
+[[distributable]]
+void output_gpio(server output_gpio_if i[n], static const size_t n, out port p,
+ char (&?pin_map)[n]);
+
+/** Task that splits a multi-bit input port into several 1-bit GPIO interfaces
+ * (no events).
+ *
+ * This component allows other tasks to access the individual bits of
+ * a multi-bit input port. It does not support events but is distributable so
+ * requires no specific logical core to run on. If the event_when_pins_eq()
+ * function is called then the component will trap.
+ *
+ * \param i The array of interfaces to connect to other tasks.
+ * \param n The number of interfaces connected.
+ * \param p The input port to be split.
+ * \param pin_map This array maps the connected interfaces to the pin
+ * of the port. For example, if 3 clients are connected
+ * to split a 8-bit port and the array {2,5,3} is supplied.
+ * Then bit 2 will go to interface 0, bit 5 to inteface 1
+ * and bit 3 to inteface 2. If null is supplied for this
+ * argument then the pin map is assumed to be {0,1,2...}.
+ */
+[[distributable]]
+void input_gpio(server input_gpio_if i[n], static const size_t n, in port p,
+ char (&?pin_map)[n]);
+
+/* Task that splits a multi-bit input port into several 1-bit GPIO interfaces
+ * (with events).
+ *
+ * This component allows other tasks to access the individual bits of
+ * a multi-bit input port. It does support events so requires a logical
+ * core to run on (but can be combined with other tasks on the same core).
+ *
+ * \param i The array of interfaces to connect to other tasks.
+ * \param n The number of interfaces connected.
+ * \param p The input port to be split.
+ * \param pin_map This array maps the connected interfaces to the pin
+ * of the port. For example, if 3 clients are connected
+ * to split a 8-bit port and the array {2,5,3} is supplied.
+ * Then bit 2 will go to interface 0, bit 5 to inteface 1
+ * and bit 3 to inteface 2. If null is supplied for this
+ * argument then the pin map is assumed to be {0,1,2...}.
+ */
+[[combinable]]
+void input_gpio_with_events(server input_gpio_if i[n],
+ static const size_t n,
+ in port p,
+ char (&?pin_map)[n]);
+
+/** Convert a 1-bit port to a single 1-bit GPIO interface.
+ *
+ * This component allows other tasks to access a 1-bit port as a GPIO
+ * interface. It is more efficient that using input_gpio_with_events() for the
+ * restricted case where a 1-bit port is used.
+ *
+ * \param i The interface to connect to other tasks.
+ * \param p The input port.
+ */
+[[combinable]]
+void input_gpio_1bit_with_events(server input_gpio_if i, in port p);
+
+#endif
+#endif // __gpio_h__
diff --git a/lib_gpio/lib_gpio/doc/rst/images/Makefile b/lib_gpio/lib_gpio/doc/rst/images/Makefile
new file mode 100644
index 0000000..fddcef8
--- /dev/null
+++ b/lib_gpio/lib_gpio/doc/rst/images/Makefile
@@ -0,0 +1,19 @@
+ODGS = $(wildcard *.odg)
+PDFS = $(ODGS:.odg=.pdf)
+
+all: $(PDFS)
+ @echo PDFs created
+
+_uncropped:
+ mkdir _uncropped
+
+_uncropped/%.pdf: %.odg | _uncropped
+ soffice -env:UserInstallation=file:///home/$(USER)/.libreoffice-alt --headless --convert-to pdf $< --outdir _uncropped
+
+%.pdf: _uncropped/%.pdf
+ pdfcrop $< $@
+
+clean:
+ -rm $(PDFS)
+ -rm _uncropped/*.pdf
+ -rmdir _uncropped
diff --git a/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.odg b/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.odg
new file mode 100644
index 0000000..1df4a70
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.odg differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.pdf b/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.pdf
new file mode 100644
index 0000000..13fc361
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/input_gpio_task_diag.pdf differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.odg b/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.odg
new file mode 100644
index 0000000..eb144f7
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.odg differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.pdf b/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.pdf
new file mode 100644
index 0000000..af6a200
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/n_bit_input.pdf differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.odg b/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.odg
new file mode 100644
index 0000000..91f38ae
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.odg differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.pdf b/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.pdf
new file mode 100644
index 0000000..30566a7
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/n_bit_output.pdf differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.odg b/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.odg
new file mode 100644
index 0000000..a8e7d71
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.odg differ
diff --git a/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.pdf b/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.pdf
new file mode 100644
index 0000000..050446e
Binary files /dev/null and b/lib_gpio/lib_gpio/doc/rst/images/output_gpio_task_diag.pdf differ
diff --git a/lib_gpio/lib_gpio/doc/rst/index.rst b/lib_gpio/lib_gpio/doc/rst/index.rst
new file mode 100644
index 0000000..7200a52
--- /dev/null
+++ b/lib_gpio/lib_gpio/doc/rst/index.rst
@@ -0,0 +1,264 @@
+.. include:: ../../../README.rst
+
+Connecting external signals to multi-bit ports
+----------------------------------------------
+
+Multi-bit ports can be connected to independent signals in either an
+all output configuration (see :ref:`lib_gpio_n_bit_output`) or an all
+input configuration (see :ref:`lib_gpio_n_bit_input`). This implies
+two important restrictions:
+
+ * **Bi-directional signals cannot use this library**
+ * **The signals on the same port must go in the same direction**
+
+To use bi-directional signals, a dedicated 1-bit hardware port needs
+to be used.
+
+.. _lib_gpio_n_bit_input:
+
+.. figure:: images/n_bit_input.*
+
+ Input configuration
+
+.. _lib_gpio_n_bit_output:
+
+.. figure:: images/n_bit_output.*
+
+ Output configuration
+
+Performance restrictions
+........................
+
+This library allows independent access to the pins of mulit-bit ports
+by multiplexing the port output or input in software. This means that
+there are some performance implications, namely:
+
+ * The internal buffering, serializing and de-serializing features of
+ the xCORE port are not available.
+ * The software locking and multiplexing between individual bits of
+ the port limits performance. As such, toggling
+ pins at speed above 1Mhz, for example, is not achievable (on a
+ 62.5Mhz logical core). The limit may be lower depending on the other
+ code is running on the core and how the other pins of the port are being
+ driven.
+
+As such, sharing multi-bit ports is most suitable for slow I/O such as
+LEDs, buttons and reset lines.
+
+Usage
+-----
+
+Output GPIO usage
+.................
+
+Output GPIO components are instantiated as parallel tasks that run in a
+``par`` statement. These components connect to the hardware ports of
+the xCORE device. The application
+can connect via an interface connection using an array of the ``output_gpio_if``
+interface type:
+
+.. figure:: images/output_gpio_task_diag.*
+
+ Output GPIO task diagram
+
+For example, the following code instantiates an output GPIO component
+for the first 3 pins of a port and connects to it::
+
+ port p = XS1_PORT_4C;
+
+ int main(void) {
+ output_gpio_if i_gpio[3];
+ par {
+ output_gpio(i_gpio, 3, p, null);
+ task1(i_gpio[0], i_gpio[1]);
+ task2(i_gpio[2]);
+ }
+ return 0;
+ }
+
+Note that the connection is an array of interfaces, so several tasks
+can connect to the same component instance, each controlling
+different pins of the port.
+
+The application can use the client end of the interface connection to
+perform GPIO operations e.g.::
+
+ void task1(client output_gpio_if gpio1, client output_gpio_if gpio2)
+ {
+ ...
+ gpio1.output(1);
+ gpio2.output(0);
+ delay_milliseconds(200);
+ gpio1.output(0);
+ gpio2.output(1);
+ ...
+ }
+
+More information on interfaces and tasks can be be found in
+the :ref:`XMOS Programming Guide`. By default the
+output GPIO component does not use any logical cores of its
+own. It is a *distributed* task which means it will perform its
+function on the logical core of the application task connected to
+it (provided the application task is on the same tile).
+
+Input GPIO usage
+................
+
+There are two types of input GPIO component: those that support events
+and those that do not support events. In both cases,
+input GPIO components are instantiated as parallel tasks that run in a
+``par`` statement. These components connect to the hardware ports of
+the xCORE device. The application
+can connect via an interface connection using an array of the ``input_gpio_if``
+interface type:
+
+.. figure:: images/input_gpio_task_diag.*
+
+ Input GPIO task diagram
+
+For example, the following code instantiates an input GPIO component
+for the first 3 pins of a port and connects to it::
+
+ port p = XS1_PORT_4C;
+
+ int main(void) {
+ input_gpio_if i_gpio[3];
+ par {
+ input_gpio(i_gpio, 3, p, null);
+ task1(i_gpio[0], i_gpio[1]);
+ task2(i_gpio[2]);
+ }
+ return 0;
+ }
+
+Note that the connection is an array of interfaces, so several tasks
+can connect to the same component instance, each controlling
+different pins of the port.
+
+|newpage|
+
+The application can use the client end of the interface connection to
+perform GPIO operations e.g.::
+
+ void task1(client input_gpio_if gpio1, client input_gpio_if gpio2)
+ {
+ ...
+ val1 = gpio1.input();
+ val2 = gpio2.input();
+ ...
+ ...
+ val1 = gpio1.input();
+ val2 = gpio2.input();
+ ...
+ }
+
+More information on interfaces and tasks can be be found in
+the :ref:`XMOS Programming Guide`. By default the
+output GPIO component does not use any logical cores of its
+own. It is a *distributed* task which means it will perform its
+function on the logical core of the application task connected to
+it (provided the application task is on the same tile).
+
+Using events
+............
+
+The :c:func:`input_gpio_with_events` and
+:c:func:`input_gpio_1bit_with_events` functions support the event
+based functions of the input GPIO interface::
+
+ port p = XS1_PORT_4C;
+
+ int main(void) {
+ input_gpio_if i_gpio[3];
+ par {
+ input_gpio_with_events(i_gpio, 3, p, null);
+ task1(i_gpio[0], i_gpio[1]);
+ task2(i_gpio[2]);
+ }
+ return 0;
+ }
+
+In this case the application can request an event on a pin change and
+then select on the event happening e.g.::
+
+ gpio.event_when_pins_eq(1);
+ select {
+ case gpio.event():
+ // This event was caused by the pin value being 1
+ ...
+ break;
+ }
+
+|newpage|
+
+Pin maps
+........
+
+The GPIO tasks all take a ``pin_map`` argument. If this is ``null``
+then the elements of the inteface array will correspond with the a bit
+of the port based on the array element index. So the first element of
+the array will control bit 0, the second with control bit 1 and so on.
+
+Alternatively an array can be provided mapping array elements to
+pins. For example, the following will map the array indices to pins 3,
+2 and 7 of the port::
+
+ char pin_map[3] = {3, 2, 7};
+
+ int main() {
+ ...
+ par {
+ output_gpio(i_gpio, 3, p, pin_map);
+ ...
+
+Output GPIO API
+---------------
+
+All GPIO functions can be accessed via the ``gpio.h`` header::
+
+ #include
+
+You will also have to add ``lib_gpio`` to the
+``USED_MODULES`` field of your application Makefile.
+
+Output GPIO components
+......................
+
+.. doxygenfunction:: output_gpio
+
+|newpage|
+
+Output GPIO interface
+.....................
+
+.. doxygeninterface:: output_gpio_if
+
+Input GPIO API
+--------------
+
+Input GPIO components
+......................
+
+.. doxygenfunction:: input_gpio
+.. doxygenfunction:: input_gpio_with_events
+
+|newpage|
+
+.. doxygenfunction:: input_gpio_1bit_with_events
+
+|newpage|
+
+Input GPIO interface
+....................
+
+.. doxygeninterface:: input_gpio_if
+
+
+|appendix|
+
+Known Issues
+------------
+
+No known issues.
+
+.. include:: ../../../CHANGELOG.rst
diff --git a/lib_gpio/lib_gpio/doc/rst/xdoc.conf b/lib_gpio/lib_gpio/doc/rst/xdoc.conf
new file mode 100644
index 0000000..2cef5f5
--- /dev/null
+++ b/lib_gpio/lib_gpio/doc/rst/xdoc.conf
@@ -0,0 +1,2 @@
+XMOSNEWSTYLE = 1
+DOXYGEN_DIRS=../../api
\ No newline at end of file
diff --git a/lib_gpio/lib_gpio/lib_build_info.cmake b/lib_gpio/lib_gpio/lib_build_info.cmake
new file mode 100644
index 0000000..2e18051
--- /dev/null
+++ b/lib_gpio/lib_gpio/lib_build_info.cmake
@@ -0,0 +1,6 @@
+set(LIB_NAME lib_gpio)
+set(LIB_VERSION 2.2.0)
+set(LIB_INCLUDES api)
+set(LIB_COMPILER_FLAGS -Os)
+
+XMOS_REGISTER_MODULE()
diff --git a/lib_gpio/lib_gpio/module_build_info b/lib_gpio/lib_gpio/module_build_info
new file mode 100644
index 0000000..182d5bb
--- /dev/null
+++ b/lib_gpio/lib_gpio/module_build_info
@@ -0,0 +1,14 @@
+VERSION = 2.2.0
+
+DEPENDENT_MODULES = lib_xassert(>=4.0.0)
+
+MODULE_XCC_FLAGS = $(XCC_FLAGS) \
+ -O3
+
+OPTIONAL_HEADERS +=
+
+EXPORT_INCLUDE_DIRS = api
+
+INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS)
+
+SOURCE_DIRS = src
diff --git a/lib_gpio/lib_gpio/src/gpio.xc b/lib_gpio/lib_gpio/src/gpio.xc
new file mode 100644
index 0000000..c800e06
--- /dev/null
+++ b/lib_gpio/lib_gpio/src/gpio.xc
@@ -0,0 +1,163 @@
+// Copyright 2014-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+#include
+#include
+
+[[distributable]]
+void input_gpio(server input_gpio_if i[n], static const size_t n,
+ in port p, char (&?pin_map)[n])
+{
+ char *pmap;
+ char default_pmap[n];
+ if (!isnull(pin_map)) {
+ pmap = pin_map;
+ }
+ else {
+ pmap = default_pmap;
+ for (size_t i = 0; i < n; i++)
+ pmap[i] = i;
+ }
+ while (1) {
+ select {
+ case i[int j].input() -> unsigned result:
+ unsigned pos = pmap[j];
+ p :> result;
+ result = (result >> pos) & 1;
+ break;
+ case i[int j].input_and_timestamp(gpio_time_t &ts) -> unsigned result:
+ unsigned pos = pmap[j];
+ p :> result @ ts;
+ result = (result >> pos) & 1;
+ break;
+ case i[int j].event_when_pins_eq(unsigned value):
+ fail("input_gpio task does not support events.");
+ break;
+ }
+ }
+}
+
+
+#pragma unsafe arrays
+[[combinable]]
+void input_gpio_with_events(server input_gpio_if i[n],
+ static const size_t n,
+ in port p,
+ char (&?pin_map)[n])
+{
+ char *pmap;
+ char default_pmap[32];
+ if (!isnull(pin_map)) {
+ pmap = pin_map;
+ }
+ else {
+ pmap = default_pmap;
+ for (size_t i = 0; i < n; i++)
+ pmap[i] = i;
+ }
+ unsigned pval = 0;
+ char test_vals[32];
+ unsigned waiting = 0;
+ for (size_t j = 0; j < n; j++)
+ test_vals[j] = -1;
+ while (1) {
+ select {
+ case i[int j].input() -> unsigned result:
+ unsigned pos = pmap[j];
+ p :> result;
+ result = (result >> pos) & 1;
+ break;
+ case i[int j].input_and_timestamp(gpio_time_t &ts) -> unsigned result:
+ unsigned pos = pmap[j];
+ p :> result @ ts;
+ result = (result >> pos) & 1;
+ break;
+ case i[int j].event_when_pins_eq(unsigned value):
+ unsigned val;
+ p :> val;
+ unsigned pos = pmap[j];
+ unsigned bit = (val >> pos) & 1;
+ if (bit == value)
+ i[j].event();
+ else {
+ if (test_vals[j] != -1)
+ waiting++;
+ test_vals[j] = value;
+ }
+ break;
+ case waiting => p when pinsneq(pval) :> pval:
+ for (size_t j = 0; j < n; j++) {
+ unsigned pos = pmap[j];
+ unsigned bit = (pval >> pos) & 1;
+ if (bit == test_vals[j]) {
+ test_vals[j] = -1;
+ waiting--;
+ i[j].event();
+ }
+ }
+ break;
+ }
+ }
+}
+
+
+
+[[combinable]]
+void input_gpio_1bit_with_events(server input_gpio_if i, in port p)
+{
+ unsigned test_val = -1;
+ while (1) {
+ select {
+ case i.input() -> unsigned result:
+ p :> result;
+ break;
+ case i.input_and_timestamp(gpio_time_t &ts) -> unsigned result:
+ p :> result @ ts;
+ break;
+ case i.event_when_pins_eq(unsigned value):
+ test_val = value;
+ break;
+ case (test_val != -1) => p when pinseq(test_val) :> int:
+ i.event();
+ test_val = -1;
+ break;
+ }
+ }
+}
+
+
+
+[[distributable]]
+void output_gpio(server output_gpio_if i[n], static const size_t n, out port p,
+ char (&?pin_map)[n])
+{
+ char *pmap;
+ char default_pmap[n];
+ if (!isnull(pin_map)) {
+ pmap = pin_map;
+ }
+ else {
+ pmap = default_pmap;
+ for (size_t i = 0; i < n; i++)
+ pmap[i] = i;
+ }
+ unsigned current_val = 0;
+ while (1) {
+ select {
+ case i[int j].output(unsigned data):
+ unsigned pos = pmap[j];
+ current_val &= ~(1 << pos);
+ current_val |= ((data & 1) << pos);
+ p <: current_val;
+ break;
+
+ case i[int j].output_and_timestamp(unsigned data) -> gpio_time_t ts:
+ unsigned pos = pmap[j];
+ current_val &= ~(1 << pos);
+ current_val |= ((data & 1) << pos);
+ p <: current_val @ ts;
+ break;
+ }
+ }
+}
diff --git a/lib_gpio/python/setup.py b/lib_gpio/python/setup.py
new file mode 100644
index 0000000..1c63daa
--- /dev/null
+++ b/lib_gpio/python/setup.py
@@ -0,0 +1,20 @@
+# Copyright 2020-2024 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import setuptools
+
+# Another repository might depend on python code defined in this one. The
+# procedure to set up a suitable python environment for that repository may
+# pip-install this one as editable using this setup.py file. To minimise the
+# chance of version conflicts while ensuring a minimal degree of conformity,
+# the 3rd-party modules listed here require the same major version and at
+# least the same minor version as specified in the requirements.txt file.
+# The same modules should appear in the requirements.txt file as given below.
+setuptools.setup(
+ name='lib_gpio',
+ packages=setuptools.find_packages(),
+ install_requires=[
+ 'flake8~=7.0',
+ ],
+ dependency_links=[
+ ],
+)
diff --git a/lib_gpio/requirements.txt b/lib_gpio/requirements.txt
new file mode 100644
index 0000000..d65050a
--- /dev/null
+++ b/lib_gpio/requirements.txt
@@ -0,0 +1,34 @@
+# python_version 3.12
+#
+# The parse_version_from_requirements() function in the installPipfile.groovy
+# file of the Jenkins Shared Library uses the python_version comment to set
+# the version of python used.
+
+# Distributed (released) dependencies
+#
+# The python modules listed below specify a known working combination required
+# by the python code in this repository. The procedure used to set up a
+# suitable python environment for it installs the version of each module in
+# the list. Using a specific version ensures a controlled infrastructure for
+# development, testing and release of this repository.
+#
+# Another repository might depend on python code defined in this one. The
+# procedure to set up a suitable python environment for that repository may
+# pip-install this one as editable using this repository's setup.py file. The
+# same modules should appear in the setup.py list as given below.
+
+flake8==7.0.0
+
+# Development dependencies
+#
+# Each link listed below specifies the path to a setup.py file which are
+# installed in editable mode with '-e $PATH' (without the quotes).
+#
+# If python code in this repository depends on python code under development
+# in another repository, then an entry for that other respository should
+# appear in this list instead of the released dependencies list.
+#
+# If this repository uses the setup functionality (e.g., script entry points)
+# of its own setup.py file, then this list must include an entry for that
+# setup.py file, e.g., '-e .' or '-e ./python' (without the quotes).
+-e ./python
diff --git a/lib_gpio/tests/gpio_basic_checker.py b/lib_gpio/tests/gpio_basic_checker.py
new file mode 100644
index 0000000..aef460c
--- /dev/null
+++ b/lib_gpio/tests/gpio_basic_checker.py
@@ -0,0 +1,74 @@
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+
+class GPIOBasicChecker(xmostest.SimThread):
+ """
+ This simulator thread will read and write to pins.
+ """
+
+ def __init__(self, mode, test_port, expected_test_port_data, num_clients,
+ trigger_port = None):
+ self._mode = mode
+ if self._mode != 'input' and self._mode != 'output':
+ print("ERROR: Checker initialised in unsupported mode %s" %
+ (self._mode))
+ self._test_port = test_port
+ self._expected_test_port_data = expected_test_port_data
+ self._num_clients = num_clients
+ self._trigger_port = trigger_port
+
+ print("Checking %s on port %s with %d clients" % (self._mode,
+ self._test_port, self._num_clients))
+ if self._trigger_port != None:
+ print("Using port %s as trigger" % (self._trigger_port))
+
+ def drive_port(self, xsi):
+ # Check the xCORE is not trying to drive the port
+ if xsi.is_port_driving(self._test_port):
+ print("ERROR: xCORE driving port %s which expected to be input only"
+ % (self._test_port))
+ # Drive the port
+ xsi.drive_port_pins(self._test_port, self._expected_test_port_data)
+ print("Checker driving port")
+
+ def read_port(self, xsi):
+ pin_values = []
+ for client in range(0, self._num_clients):
+ pin_values.append(-1)
+
+ correct_pin_count = 0
+ while (correct_pin_count < self._num_clients):
+ # Wait for the xCORE to drive the port
+ self.wait_for_port_pins_change([self._test_port])
+ port_data = xsi.sample_port_pins(self._test_port)
+ for client in range(0, self._num_clients):
+ # Check for the updated pin
+ pin_data = ((port_data >> client) & 1)
+ if pin_values[client] == -1:
+ # Not yet seen the correct pin data yet
+ if pin_data == ((self._expected_test_port_data >>
+ client) & 1):
+ pin_values[client] = pin_data
+ correct_pin_count +=1
+ print("Checker has seen correct value on pin %d " %
+ (client))
+ else: # Check valid pin data has not been overwritten
+ if pin_values[client] != ((self._expected_test_port_data >>
+ client) & 1):
+ print("ERROR: Data on pin %d changed unexpected" %
+ (client))
+ print("Checker has seen all pins change")
+
+ # Drive trigger port to allow xCORE program to terminate
+ xsi.drive_port_pins(self._trigger_port, 1)
+ print("Checker driving termination trigger")
+
+ def run(self):
+ if self._mode == 'input':
+ # xCORE testing 'input' functionality means checker must drive port
+ self.drive_port(self.xsi)
+ elif self._mode == 'output':
+ # xCORE testing 'output' functionality means checker must read port
+ self.read_port(self.xsi)
+ print("Checker complete")
diff --git a/lib_gpio/tests/gpio_events_checker.py b/lib_gpio/tests/gpio_events_checker.py
new file mode 100644
index 0000000..968e5f0
--- /dev/null
+++ b/lib_gpio/tests/gpio_events_checker.py
@@ -0,0 +1,49 @@
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+
+class GPIOEventsChecker(xmostest.SimThread):
+ """
+ This simulator thread will write to pins to allow xCORE to event.
+ """
+
+ def __init__(self, test_port, expected_test_port_data, num_clients,
+ trigger_port):
+ self._test_port = test_port
+ self._expected_test_port_data = expected_test_port_data
+ self._num_clients = num_clients
+ self._trigger_port = trigger_port
+
+ print("Checking events on port %s with %d clients" % (self._test_port,
+ self._num_clients))
+ print("Using port %s as trigger" % (self._trigger_port))
+
+ def drive_port(self, xsi):
+ # Check the xCORE is not trying to drive the port
+ if xsi.is_port_driving(self._test_port):
+ print("ERROR: xCORE driving port %s which expected to be input only"
+ % (self._test_port))
+ # Drive the test port
+ xsi.drive_port_pins(self._test_port, self._expected_test_port_data)
+ print("Checker driving port")
+ # Flip bits of expected data for second part of test
+ self._expected_test_port_data = ~self._expected_test_port_data
+ # Delay driving new data to test port until num_client bits of
+ # trigger_port go high
+ expected_trigger_data = 0
+ for i in range(0, self._num_clients):
+ expected_trigger_data = (expected_trigger_data << 1) + 1
+ print("Checker expecting 0x%x as trigger data" % (expected_trigger_data))
+ while True:
+ self.wait_for_port_pins_change([self._trigger_port])
+ trigger_data = xsi.sample_port_pins(self._trigger_port)
+ if trigger_data == expected_trigger_data:
+ print("Checker received correct trigger")
+ break
+ # Drive the test port
+ xsi.drive_port_pins(self._test_port, self._expected_test_port_data)
+ print("Checker driving port")
+
+ def run(self):
+ self.drive_port(self.xsi)
+ print("Checker complete")
diff --git a/lib_gpio/tests/gpio_input_1bit_test/Makefile b/lib_gpio/tests/gpio_input_1bit_test/Makefile
new file mode 100644
index 0000000..ce7ec21
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_1bit_test/Makefile
@@ -0,0 +1,36 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -O2 -g -save-temps -DDEBUG_PRINT_ENABLE=1 -report
+
+XCC_FLAGS_input_basic = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0
+XCC_FLAGS_input_events = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=0
+XCC_FLAGS_input_timestamps = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=1
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_gpio lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_gpio/tests/gpio_input_1bit_test/src/main.xc b/lib_gpio/tests/gpio_input_1bit_test/src/main.xc
new file mode 100644
index 0000000..8912c7d
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_1bit_test/src/main.xc
@@ -0,0 +1,105 @@
+// Copyright 2015-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+
+#define NUM_TEST_EVENTS (2)
+#define TIMESTAMP_TEST_DELAY_MICROSECONDS (5)
+#define TIMESTAMP_TEST_DELAY_CLOCKS (TIMESTAMP_TEST_DELAY_MICROSECONDS * XS1_TIMER_MHZ)
+#define TIMESTAMP_TEST_DELAY_SLACK_CLOCKS (100)
+
+port input_port = XS1_PORT_1A;
+port trigger_port = XS1_PORT_4B;
+
+void read_port_on_event(client input_gpio_if input_port) {
+ unsigned int completed_events = 0;
+ unsigned int expected_value = 1;
+
+ /* Setup event that should trigger immediately */
+ input_port.event_when_pins_eq(expected_value);
+ debug_printf("xCORE setup pins eq event\n");
+
+ while (1) {
+ select {
+ case input_port.event():
+ debug_printf("xCORE got input port event\n");
+ completed_events++;
+ // Read value on pin to make sure it's correct
+ unsigned int pin_data = input_port.input();
+ if (pin_data != expected_value) {
+ debug_printf("ERROR: Data 0x%x read does not match expected data 0x%x\n",
+ pin_data, expected_value);
+ }
+
+ if (completed_events < NUM_TEST_EVENTS) {
+ /* Setup event that should trigger later */
+ // Flip expected_value each iteration of test
+ expected_value = !expected_value;
+ input_port.event_when_pins_eq(expected_value);
+ debug_printf("xCORE setup pins eq event\n");
+ // Trigger simulator to output new expected_value
+ debug_printf("xCORE driving trigger port\n");
+ trigger_port <: 1;
+ } else {
+ _exit(0);
+ }
+ break;
+ }
+ }
+}
+
+void read_port(client input_gpio_if input_port) {
+ unsigned int pin_data;
+ unsigned int expected_value = 1;
+
+ if (TIMESTAMPS) {
+ gpio_time_t ts1, ts2;
+ pin_data = input_port.input_and_timestamp(ts1);
+ // Wait known time before second input with timestamp
+ delay_microseconds(TIMESTAMP_TEST_DELAY_MICROSECONDS);
+ input_port.input_and_timestamp(ts2);
+ // Check that the second ts is a later time than the first
+ if (porttimeafter(ts1, ts2)) {
+ debug_printf("ERROR: Second timestamp (%d) read appears to be earlier than first (%d)\n",
+ ts2, ts1);
+ }
+ // Sanity check difference between timestamps
+ if ((ts2 - ts1) <
+ (TIMESTAMP_TEST_DELAY_CLOCKS - TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) read smaller than expected\n",
+ ts1, ts2);
+ }
+ if ((ts2 - ts1) >
+ (TIMESTAMP_TEST_DELAY_CLOCKS + TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) read larger than expected\n",
+ ts1, ts2);
+ }
+ } else {
+ pin_data = input_port.input();
+ }
+
+ if (pin_data != expected_value) {
+ debug_printf("ERROR: Data 0x%x read does not match expected data 0x%x\n",
+ pin_data, expected_value);
+ } else {
+ debug_printf("xCORE input data correctly\n");
+ }
+
+ _exit(0);
+}
+
+int main(void) {
+ interface input_gpio_if i_input_port;
+ par {
+ input_gpio_1bit_with_events(i_input_port, input_port);
+#if EVENTS
+ read_port_on_event(i_input_port);
+#else
+ read_port(i_input_port);
+#endif
+ }
+ return 0;
+}
diff --git a/lib_gpio/tests/gpio_input_1bit_test/wscript b/lib_gpio/tests/gpio_input_1bit_test/wscript
new file mode 100644
index 0000000..2121c33
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_1bit_test/wscript
@@ -0,0 +1,14 @@
+def options(opt):
+ opt.load('xwaf.xcommon')
+
+def configure(conf):
+ conf.load('xwaf.xcommon')
+
+def build(bld):
+ bld.do_xcommon()
+
+def dist(ctx):
+ ctx.load('xwaf.xcommon')
+
+def distcheck(ctx):
+ ctx.load('xwaf.xcommon')
diff --git a/lib_gpio/tests/gpio_input_basic_test/Makefile b/lib_gpio/tests/gpio_input_basic_test/Makefile
new file mode 100644
index 0000000..a4019e5
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_basic_test/Makefile
@@ -0,0 +1,40 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -O2 -g -save-temps -DDEBUG_PRINT_ENABLE=1 -report
+
+XCC_FLAGS_input_basic = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
+XCC_FLAGS_input_events = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
+XCC_FLAGS_input_timestamps = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
+XCC_FLAGS_input_events_timestamps = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=0
+XCC_FLAGS_input_supply_pin_map = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=1 -DCROSSTILE=0
+XCC_FLAGS_input_crosstile = $(COMMON_FLAGS) -DEVENTS=0 -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0 -DCROSSTILE=1
+XCC_FLAGS_input_events_timestamps_supply_pin_map_crosstile = $(COMMON_FLAGS) -DEVENTS=1 -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=1 -DCROSSTILE=1
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_gpio lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_gpio/tests/gpio_input_basic_test/src/main.xc b/lib_gpio/tests/gpio_input_basic_test/src/main.xc
new file mode 100644
index 0000000..b548ef9
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_basic_test/src/main.xc
@@ -0,0 +1,85 @@
+// Copyright 2015-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+
+#ifndef CROSSTILE
+#define CROSSTILE 0
+#endif
+
+#define NUM_CLIENTS (4)
+#define TIMESTAMP_TEST_DELAY_MICROSECONDS (5)
+#define TIMESTAMP_TEST_DELAY_CLOCKS (TIMESTAMP_TEST_DELAY_MICROSECONDS * XS1_TIMER_MHZ)
+#define TIMESTAMP_TEST_DELAY_SLACK_CLOCKS (100 + CROSSTILE?100:0)
+
+on tile[0] : port input_port = XS1_PORT_4D;
+
+void read_port(client input_gpio_if input_port, unsigned int client_num) {
+ unsigned int pin_data;
+ unsigned int expected_value = (client_num & 1);
+ if (SUPPLY_PIN_MAP) {
+ expected_value = !expected_value;
+ }
+
+ if (TIMESTAMPS) {
+ gpio_time_t ts1, ts2;
+ pin_data = input_port.input_and_timestamp(ts1);
+ // Wait known time before second input with timestamp
+ delay_microseconds(TIMESTAMP_TEST_DELAY_MICROSECONDS);
+ input_port.input_and_timestamp(ts2);
+ // Check that the second ts is a later time than the first
+ if (porttimeafter(ts1, ts2)) {
+ debug_printf("ERROR: Second timestamp (%d) read by client %d appears to be earlier than first (%d)\n",
+ ts2, client_num, ts1);
+ }
+ // Sanity check difference between timestamps
+ if ((ts2 - ts1) <
+ (TIMESTAMP_TEST_DELAY_CLOCKS - TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) read by client %d smaller than expected\n",
+ ts1, ts2, client_num);
+ }
+ if ((ts2 - ts1) >
+ (TIMESTAMP_TEST_DELAY_CLOCKS + TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) read by client %d larger than expected\n",
+ ts1, ts2, client_num);
+ }
+ } else {
+ pin_data = input_port.input();
+ }
+
+ if (pin_data != expected_value) {
+ debug_printf("ERROR: Data 0x%x read by client %d does not match expected data 0x%x\n",
+ pin_data, client_num, expected_value);
+ } else {
+ debug_printf("xCORE client %d input data correctly\n", client_num);
+ }
+
+ // Allow other cores to complete
+ delay_microseconds(5);
+ _exit(0);
+}
+
+#if SUPPLY_PIN_MAP
+static char pin_map[NUM_CLIENTS] = {1, 0, 3, 2};
+#else
+#define pin_map null
+#endif
+
+int main(void) {
+ interface input_gpio_if i_input_port[NUM_CLIENTS];
+ par {
+#if EVENTS
+ on tile[0] : input_gpio_with_events(i_input_port, NUM_CLIENTS, input_port, pin_map);
+#else
+ on tile[0] : input_gpio(i_input_port, NUM_CLIENTS, input_port, pin_map);
+#endif
+ par (int i = 0; i < NUM_CLIENTS; i++) {
+ on tile[CROSSTILE?i%2:0] : read_port(i_input_port[i], i);
+ }
+ }
+ return 0;
+}
diff --git a/lib_gpio/tests/gpio_input_basic_test/wscript b/lib_gpio/tests/gpio_input_basic_test/wscript
new file mode 100644
index 0000000..2121c33
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_basic_test/wscript
@@ -0,0 +1,14 @@
+def options(opt):
+ opt.load('xwaf.xcommon')
+
+def configure(conf):
+ conf.load('xwaf.xcommon')
+
+def build(bld):
+ bld.do_xcommon()
+
+def dist(ctx):
+ ctx.load('xwaf.xcommon')
+
+def distcheck(ctx):
+ ctx.load('xwaf.xcommon')
diff --git a/lib_gpio/tests/gpio_input_events_test/Makefile b/lib_gpio/tests/gpio_input_events_test/Makefile
new file mode 100644
index 0000000..a5ea89f
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_events_test/Makefile
@@ -0,0 +1,35 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -O2 -g -save-temps -DDEBUG_PRINT_ENABLE=1 -report -DXASSERT_ENABLE_ASSERTIONS=1 -DXASSERT_ENABLE_DEBUG=1
+
+XCC_FLAGS_input_basic = $(COMMON_FLAGS) -DEVENTS=0
+XCC_FLAGS_input_events = $(COMMON_FLAGS) -DEVENTS=1
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_gpio lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_gpio/tests/gpio_input_events_test/src/main.xc b/lib_gpio/tests/gpio_input_events_test/src/main.xc
new file mode 100644
index 0000000..9e02498
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_events_test/src/main.xc
@@ -0,0 +1,70 @@
+// Copyright 2015-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+
+#define NUM_CLIENTS (4)
+#define NUM_TEST_EVENTS (2)
+
+port input_port = XS1_PORT_4D;
+port trigger_port = XS1_PORT_4B;
+
+void read_port_on_event(client input_gpio_if input_port, unsigned int client_num,
+ client output_gpio_if trigger_port) {
+ unsigned int completed_events = 0;
+ unsigned int expected_value = (client_num & 1);
+
+ /* Setup event that should trigger immediately */
+ input_port.event_when_pins_eq(expected_value);
+ debug_printf("xCORE client %d setup pins eq event\n", client_num);
+
+ while (1) {
+ select {
+ case input_port.event():
+ debug_printf("xCORE client %d got input port event\n", client_num);
+ completed_events++;
+ // Read value on pin to make sure it's correct
+ unsigned int pin_data = input_port.input();
+ if (pin_data != expected_value) {
+ debug_printf("ERROR: Data 0x%x read by client %d does not match expected data 0x%x\n",
+ pin_data, client_num, expected_value);
+ }
+
+ if (completed_events < NUM_TEST_EVENTS) {
+ /* Setup event that should trigger later */
+ // Flip expected_value each iteration of test
+ expected_value = !expected_value;
+ input_port.event_when_pins_eq(expected_value);
+ debug_printf("xCORE client %d setup pins eq event\n", client_num);
+ // Trigger simulator to output new expected_value
+ debug_printf("xCORE client %d driving trigger port\n", client_num);
+ trigger_port.output(1);
+ } else {
+ // Allow other cores to complete
+ delay_microseconds(5);
+ _exit(0);
+ }
+ break;
+ }
+ }
+}
+
+int main(void) {
+ interface input_gpio_if i_input_port[NUM_CLIENTS];
+ interface output_gpio_if i_trigger_port[NUM_CLIENTS];
+ par {
+#if EVENTS
+ input_gpio_with_events(i_input_port, NUM_CLIENTS, input_port, null);
+#else
+ input_gpio(i_input_port, NUM_CLIENTS, input_port, null);
+#endif
+ output_gpio(i_trigger_port, NUM_CLIENTS, trigger_port, null);
+ par (int i = 0; i < NUM_CLIENTS; i++) {
+ read_port_on_event(i_input_port[i], i, i_trigger_port[i]);
+ }
+ }
+ return 0;
+}
diff --git a/lib_gpio/tests/gpio_input_events_test/wscript b/lib_gpio/tests/gpio_input_events_test/wscript
new file mode 100644
index 0000000..2121c33
--- /dev/null
+++ b/lib_gpio/tests/gpio_input_events_test/wscript
@@ -0,0 +1,14 @@
+def options(opt):
+ opt.load('xwaf.xcommon')
+
+def configure(conf):
+ conf.load('xwaf.xcommon')
+
+def build(bld):
+ bld.do_xcommon()
+
+def dist(ctx):
+ ctx.load('xwaf.xcommon')
+
+def distcheck(ctx):
+ ctx.load('xwaf.xcommon')
diff --git a/lib_gpio/tests/gpio_output_test/Makefile b/lib_gpio/tests/gpio_output_test/Makefile
new file mode 100644
index 0000000..d732995
--- /dev/null
+++ b/lib_gpio/tests/gpio_output_test/Makefile
@@ -0,0 +1,36 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -O2 -g -save-temps -DDEBUG_PRINT_ENABLE=1 -report
+
+XCC_FLAGS_output_basic = $(COMMON_FLAGS) -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=0
+XCC_FLAGS_output_timestamps = $(COMMON_FLAGS) -DTIMESTAMPS=1 -DSUPPLY_PIN_MAP=0
+XCC_FLAGS_output_supply_pin_map = $(COMMON_FLAGS) -DTIMESTAMPS=0 -DSUPPLY_PIN_MAP=1
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_gpio lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_gpio/tests/gpio_output_test/src/main.xc b/lib_gpio/tests/gpio_output_test/src/main.xc
new file mode 100644
index 0000000..0e239d8
--- /dev/null
+++ b/lib_gpio/tests/gpio_output_test/src/main.xc
@@ -0,0 +1,75 @@
+// Copyright 2015-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#include
+#include
+#include
+#include "debug_print.h"
+
+#define NUM_CLIENTS (4)
+#define TIMESTAMP_TEST_DELAY_MICROSECONDS (5)
+#define TIMESTAMP_TEST_DELAY_CLOCKS (TIMESTAMP_TEST_DELAY_MICROSECONDS * XS1_TIMER_MHZ)
+#define TIMESTAMP_TEST_DELAY_SLACK_CLOCKS (100)
+
+port output_port = XS1_PORT_4D;
+port trigger_port = XS1_PORT_4B;
+
+void wait_for_termination_signal() {
+ debug_printf("xCORE waiting for termination signal\n");
+ select {
+ case trigger_port when pinsneq(0) :> int _:
+ _exit(0);
+ break;
+ }
+}
+
+void drive_port(client output_gpio_if output_port, unsigned int client_num) {
+ unsigned int expected_pin_data = (client_num & 1);
+ if (SUPPLY_PIN_MAP) {
+ expected_pin_data = !expected_pin_data;
+ }
+
+ if (TIMESTAMPS) {
+ gpio_time_t ts1, ts2;
+ debug_printf("xCORE client %d driving port\n", client_num);
+ ts1 = output_port.output_and_timestamp(expected_pin_data);
+ // Wait known time before second input with timestamp
+ delay_microseconds(TIMESTAMP_TEST_DELAY_MICROSECONDS);
+ ts2 = output_port.output_and_timestamp(expected_pin_data);
+ // Check that the second ts is a later time than the first
+ if (porttimeafter(ts1, ts2)) {
+ debug_printf("ERROR: Second timestamp (%d) received by client %d appears to be earlier than first (%d)\n",
+ ts2, client_num, ts1);
+ }
+ // Sanity check difference between timestamps
+ if ((ts2 - ts1) <
+ (TIMESTAMP_TEST_DELAY_CLOCKS - TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) received by client %d smaller than expected\n",
+ ts1, ts2, client_num);
+ }
+ if ((ts2 - ts1) >
+ (TIMESTAMP_TEST_DELAY_CLOCKS + TIMESTAMP_TEST_DELAY_SLACK_CLOCKS)) {
+ debug_printf("ERROR: Difference between timestamps (%d, %d) received by client %d larger than expected\n",
+ ts1, ts2, client_num);
+ }
+ } else {
+ debug_printf("xCORE client %d driving port\n", client_num);
+ output_port.output(expected_pin_data);
+ }
+}
+
+int main(void) {
+ interface output_gpio_if i_output_port[NUM_CLIENTS];
+#if SUPPLY_PIN_MAP
+ char pin_map[NUM_CLIENTS] = {1, 0, 3, 2};
+#else
+#define pin_map null
+#endif
+ par {
+ output_gpio(i_output_port, NUM_CLIENTS, output_port, pin_map);
+ par (int i = 0; i < NUM_CLIENTS; i++) {
+ drive_port(i_output_port[i], i);
+ }
+ wait_for_termination_signal();
+ }
+ return 0;
+}
diff --git a/lib_gpio/tests/gpio_output_test/wscript b/lib_gpio/tests/gpio_output_test/wscript
new file mode 100644
index 0000000..2121c33
--- /dev/null
+++ b/lib_gpio/tests/gpio_output_test/wscript
@@ -0,0 +1,14 @@
+def options(opt):
+ opt.load('xwaf.xcommon')
+
+def configure(conf):
+ conf.load('xwaf.xcommon')
+
+def build(bld):
+ bld.do_xcommon()
+
+def dist(ctx):
+ ctx.load('xwaf.xcommon')
+
+def distcheck(ctx):
+ ctx.load('xwaf.xcommon')
diff --git a/lib_gpio/tests/input_1bit_basic_test.expected b/lib_gpio/tests/input_1bit_basic_test.expected
new file mode 100644
index 0000000..e4d8ffc
--- /dev/null
+++ b/lib_gpio/tests/input_1bit_basic_test.expected
@@ -0,0 +1,3 @@
+Checker driving port
+Checker complete
+xCORE input data correctly
diff --git a/lib_gpio/tests/input_1bit_events_test.expected b/lib_gpio/tests/input_1bit_events_test.expected
new file mode 100644
index 0000000..11da1f3
--- /dev/null
+++ b/lib_gpio/tests/input_1bit_events_test.expected
@@ -0,0 +1,10 @@
+Checker driving port
+Checker expecting 0x1 as trigger data
+xCORE setup pins eq event
+xCORE got input port event
+xCORE setup pins eq event
+xCORE driving trigger port
+Checker received correct trigger
+Checker driving port
+Checker complete
+xCORE got input port event
diff --git a/lib_gpio/tests/input_basic_test.expected b/lib_gpio/tests/input_basic_test.expected
new file mode 100644
index 0000000..e0b10c8
--- /dev/null
+++ b/lib_gpio/tests/input_basic_test.expected
@@ -0,0 +1,6 @@
+Checker driving port
+Checker complete
+xCORE client \d input data correctly
+xCORE client \d input data correctly
+xCORE client \d input data correctly
+xCORE client \d input data correctly
diff --git a/lib_gpio/tests/input_events_test_basic.expected b/lib_gpio/tests/input_events_test_basic.expected
new file mode 100644
index 0000000..bf0117d
--- /dev/null
+++ b/lib_gpio/tests/input_events_test_basic.expected
@@ -0,0 +1,3 @@
+Checker driving port
+Checker expecting 0x\w as trigger data
+input_gpio task does not support events.
diff --git a/lib_gpio/tests/input_events_test_events.expected b/lib_gpio/tests/input_events_test_events.expected
new file mode 100644
index 0000000..16324d4
--- /dev/null
+++ b/lib_gpio/tests/input_events_test_events.expected
@@ -0,0 +1,25 @@
+Checker driving port
+Checker expecting 0x\w as trigger data
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d got input port event
+xCORE client \d got input port event
+xCORE client \d got input port event
+xCORE client \d got input port event
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d setup pins eq event
+xCORE client \d driving trigger port
+xCORE client \d driving trigger port
+xCORE client \d driving trigger port
+xCORE client \d driving trigger port
+Checker received correct trigger
+Checker driving port
+Checker complete
+xCORE client \d got input port event
+xCORE client \d got input port event
+xCORE client \d got input port event
+xCORE client \d got input port event
diff --git a/lib_gpio/tests/output_supply_pin_map_test.expected b/lib_gpio/tests/output_supply_pin_map_test.expected
new file mode 100644
index 0000000..9523ec2
--- /dev/null
+++ b/lib_gpio/tests/output_supply_pin_map_test.expected
@@ -0,0 +1,12 @@
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE waiting for termination signal
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen all pins change
+Checker driving termination trigger
+Checker complete
diff --git a/lib_gpio/tests/output_test.expected b/lib_gpio/tests/output_test.expected
new file mode 100644
index 0000000..9523ec2
--- /dev/null
+++ b/lib_gpio/tests/output_test.expected
@@ -0,0 +1,12 @@
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE client \d driving port
+xCORE waiting for termination signal
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen correct value on pin \d
+Checker has seen all pins change
+Checker driving termination trigger
+Checker complete
diff --git a/lib_gpio/tests/runtests.py b/lib_gpio/tests/runtests.py
new file mode 100644
index 0000000..b50a149
--- /dev/null
+++ b/lib_gpio/tests/runtests.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+
+if __name__ == "__main__":
+ xmostest.init()
+
+ xmostest.register_group("lib_gpio",
+ "gpio_sim_tests",
+ "GPIO simulator tests",
+ """
+Tests are performed by running the GPIO library connected to a simulator model
+(written as a python plugin to xsim). The simulator model checks that the pins
+are driven and read by the ports as expected. Tests are run to test the
+following features:
+
+ * Inputting on a multibit port with multiple clients using the default pin map
+ * Inputting on a multibit port with multiple clients using a specified pin map
+ * Inputting on a 1bit port
+ * Inputting with timestamps
+ * Eventing on a multibit input port
+ * Eventing on a 1bit input port
+ * Outputting on a multibit port with multiple clients using the default pin map
+ * Outputting on a multibit port with multiple clients using a specified pin map
+ * Outputting with timestamps
+""")
+
+ xmostest.runtests()
+
+ xmostest.finish()
diff --git a/lib_gpio/tests/test_input_1bit_basic.py b/lib_gpio/tests/test_input_1bit_basic.py
new file mode 100644
index 0000000..7024099
--- /dev/null
+++ b/lib_gpio/tests/test_input_1bit_basic.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+from gpio_basic_checker import GPIOBasicChecker
+
+def do_input_1bit_basic_test(timestamps):
+ resources = xmostest.request_resource("xsim")
+
+ path = ''
+ if not timestamps:
+ path += '_basic'
+ else:
+ if timestamps:
+ path += '_timestamps'
+
+ binary = 'gpio_input_1bit_test/bin/input' + path + \
+ '/gpio_input_1bit_test_input' + path + '.xe'
+
+ checker = GPIOBasicChecker(mode="input",
+ test_port="tile[0]:XS1_PORT_1A",
+ expected_test_port_data=0b1,
+ num_clients=1)
+
+ tester = xmostest.ComparisonTester(open('input_1bit_basic_test.expected'),
+ 'lib_gpio', 'gpio_sim_tests',
+ 'input_1bit_basic_test',
+ {'timestamps':timestamps,},
+ regexp=False)
+
+ xmostest.run_on_simulator(resources['xsim'], binary, simthreads = [checker],
+ tester = tester)
+
+def runtest():
+ do_input_1bit_basic_test(timestamps=False)
+ do_input_1bit_basic_test(timestamps=True)
diff --git a/lib_gpio/tests/test_input_1bit_events.py b/lib_gpio/tests/test_input_1bit_events.py
new file mode 100644
index 0000000..0fb4f3a
--- /dev/null
+++ b/lib_gpio/tests/test_input_1bit_events.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+from gpio_events_checker import GPIOEventsChecker
+
+def do_input_1bit_events_test():
+ resources = xmostest.request_resource("xsim")
+
+ binary = 'gpio_input_1bit_test/bin/input_events/gpio_input_1bit_test_input_events.xe'
+
+ checker = GPIOEventsChecker(test_port="tile[0]:XS1_PORT_1A",
+ expected_test_port_data=0b1,
+ num_clients=1,
+ trigger_port="tile[0]:XS1_PORT_4B")
+
+ tester = xmostest.ComparisonTester(open('input_1bit_events_test.expected'),
+ 'lib_gpio', 'gpio_sim_tests',
+ 'input_1bit_events_test',
+ regexp=False)
+
+ xmostest.run_on_simulator(resources['xsim'], binary, simthreads = [checker],
+ tester = tester)
+
+def runtest():
+ do_input_1bit_events_test()
diff --git a/lib_gpio/tests/test_input_basic.py b/lib_gpio/tests/test_input_basic.py
new file mode 100644
index 0000000..283304a
--- /dev/null
+++ b/lib_gpio/tests/test_input_basic.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+from gpio_basic_checker import GPIOBasicChecker
+
+def do_input_basic_test(events, timestamps, supply_pin_map, crosstile):
+ resources = xmostest.request_resource("xsim")
+
+ path = ''
+ if not events and not timestamps and not supply_pin_map and not crosstile:
+ path += '_basic'
+ else:
+ if events:
+ path += '_events'
+ if timestamps:
+ path += '_timestamps'
+ if supply_pin_map:
+ path += '_supply_pin_map'
+ if crosstile:
+ path += '_crosstile'
+
+ binary = 'gpio_input_basic_test/bin/input' + path + \
+ '/gpio_input_basic_test_input' + path + '.xe'
+
+ checker = GPIOBasicChecker(mode="input",
+ test_port="tile[0]:XS1_PORT_4D",
+ expected_test_port_data=0b1010,
+ num_clients=4)
+
+ tester = xmostest.ComparisonTester(open('input_basic_test.expected'),
+ 'lib_gpio', 'gpio_sim_tests',
+ 'input_basic_test',
+ {'events':events,
+ 'timestamps':timestamps,
+ 'supply_pin_map':supply_pin_map,
+ 'crosstile':crosstile},
+ regexp=True)
+
+ xmostest.run_on_simulator(resources['xsim'], binary, simthreads = [checker],
+ tester = tester)
+
+def runtest():
+ do_input_basic_test(events=False, timestamps=False, supply_pin_map=False, crosstile=False)
+ do_input_basic_test(events=False, timestamps=False, supply_pin_map=True, crosstile=False)
+ do_input_basic_test(events=False, timestamps=True, supply_pin_map=False, crosstile=False)
+ do_input_basic_test(events=True, timestamps=False, supply_pin_map=False, crosstile=False)
+ do_input_basic_test(events=True, timestamps=True, supply_pin_map=False, crosstile=False)
+ do_input_basic_test(events=False, timestamps=False, supply_pin_map=False, crosstile=True)
+ do_input_basic_test(events=True, timestamps=True, supply_pin_map=True, crosstile=True)
diff --git a/lib_gpio/tests/test_input_events.py b/lib_gpio/tests/test_input_events.py
new file mode 100644
index 0000000..297cad5
--- /dev/null
+++ b/lib_gpio/tests/test_input_events.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+from gpio_events_checker import GPIOEventsChecker
+
+def do_input_events_test(events):
+ resources = xmostest.request_resource("xsim")
+
+ path = ''
+ if not events:
+ path += '_basic'
+ else:
+ if events:
+ path += '_events'
+
+ binary = 'gpio_input_events_test/bin/input' + path + \
+ '/gpio_input_events_test_input' + path + '.xe'
+
+ checker = GPIOEventsChecker(test_port="tile[0]:XS1_PORT_4D",
+ expected_test_port_data=0b1010,
+ num_clients=4,
+ trigger_port="tile[0]:XS1_PORT_4B")
+
+ tester = xmostest.ComparisonTester(open('input_events_test%s.expected' % path),
+ 'lib_gpio', 'gpio_sim_tests',
+ 'input_events_test',
+ {'events':events},
+ regexp=True)
+
+ xmostest.run_on_simulator(resources['xsim'], binary, simthreads = [checker],
+ tester = tester)
+
+def runtest():
+ do_input_events_test(events=False)
+ do_input_events_test(events=True)
diff --git a/lib_gpio/tests/test_output.py b/lib_gpio/tests/test_output.py
new file mode 100644
index 0000000..15c07da
--- /dev/null
+++ b/lib_gpio/tests/test_output.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Copyright 2015-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import xmostest
+from gpio_basic_checker import GPIOBasicChecker
+
+def do_output_test(timestamps, supply_pin_map):
+ resources = xmostest.request_resource("xsim")
+
+ path = ''
+ if not timestamps and not supply_pin_map:
+ path += '_basic'
+ else:
+ if timestamps:
+ path += '_timestamps'
+ if supply_pin_map:
+ path += '_supply_pin_map'
+
+ binary = 'gpio_output_test/bin/output' + path + \
+ '/gpio_output_test_output' + path + '.xe'
+
+ checker = GPIOBasicChecker(mode="output",
+ test_port="tile[0]:XS1_PORT_4D",
+ expected_test_port_data=0b1010,
+ num_clients=4,
+ trigger_port="tile[0]:XS1_PORT_4B")
+
+ if supply_pin_map:
+ expected_result = 'output_supply_pin_map_test.expected'
+ else:
+ expected_result = 'output_test.expected'
+ tester = xmostest.ComparisonTester(open(expected_result),
+ 'lib_gpio', 'gpio_sim_tests',
+ 'output_test',
+ {'timestamps':timestamps,
+ 'supply_pin_map':supply_pin_map},
+ regexp=True)
+
+ xmostest.run_on_simulator(resources['xsim'], binary, simthreads = [checker],
+ tester = tester)
+
+def runtest():
+ do_output_test(timestamps=False, supply_pin_map=False)
+ do_output_test(timestamps=False, supply_pin_map=True)
+ do_output_test(timestamps=True, supply_pin_map=False)
diff --git a/lib_src/.gitignore b/lib_src/.gitignore
new file mode 100644
index 0000000..5409e72
--- /dev/null
+++ b/lib_src/.gitignore
@@ -0,0 +1,34 @@
+**/.build*/*
+**/bin/*
+*.o
+*.xe
+*.vcd
+*.xi
+*.i
+*.a
+**/_build/
+**/run_*.log
+**/pdf/*
+*.pyc
+test_results.csv
+*.xmt
+output*.dat
+*.swp
+.*.swp
+.*.*.swp
+*.swo
+*.todo
+org.eclipse.cdt.core.prefs
+xsim.args
+tests/src_output
+*.bak
+**/.venv/**
+build/
+tests/tmp
+tests/vpu_ff3_test/autogen
+tests/vpu_rat_test/autogen
+*.csv
+python/lib_src.egg-info
+**/tmp_models/
+*.bak
+make_docs.sh
\ No newline at end of file
diff --git a/lib_src/.gitmodules b/lib_src/.gitmodules
new file mode 100644
index 0000000..6a4a0e7
--- /dev/null
+++ b/lib_src/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "xmos_cmake_toolchain"]
+ path = xmos_cmake_toolchain
+ url = git@github.com:xmos/xmos_cmake_toolchain.git
diff --git a/lib_src/.xmos_ignore_source_check b/lib_src/.xmos_ignore_source_check
new file mode 100644
index 0000000..6d5bb5f
--- /dev/null
+++ b/lib_src/.xmos_ignore_source_check
@@ -0,0 +1,32 @@
+tests/asrc_test/model/ASRC.c
+tests/asrc_test/model/ASRC.h
+tests/asrc_test/model/FIR.c
+tests/asrc_test/model/FIR.h
+tests/asrc_test/model/FilterDefs.c
+tests/asrc_test/model/FilterDefs.h
+tests/asrc_test/model/IntArithmetic.c
+tests/asrc_test/model/IntArithmetic.h
+tests/asrc_test/model/Main.c
+tests/asrc_test/model/Main.h
+tests/ds3_test/model/FIRDS3.c
+tests/ds3_test/model/FIRDS3.h
+tests/ds3_test/model/IntArithmetic.c
+tests/ds3_test/model/IntArithmetic.h
+tests/ds3_test/model/Main.c
+tests/ds3_test/model/Main.h
+tests/os3_test/model/FIROS3.c
+tests/os3_test/model/FIROS3.h
+tests/os3_test/model/IntArithmetic.c
+tests/os3_test/model/IntArithmetic.h
+tests/os3_test/model/Main.c
+tests/os3_test/model/Main.h
+tests/ssrc_test/model/FIR.c
+tests/ssrc_test/model/FIR.h
+tests/ssrc_test/model/FilterDefs.c
+tests/ssrc_test/model/FilterDefs.h
+tests/ssrc_test/model/IntArithmetic.c
+tests/ssrc_test/model/IntArithmetic.h
+tests/ssrc_test/model/Main.c
+tests/ssrc_test/model/Main.h
+tests/ssrc_test/model/SSRC.c
+tests/ssrc_test/model/SSRC.h
diff --git a/lib_src/CHANGELOG.rst b/lib_src/CHANGELOG.rst
new file mode 100644
index 0000000..5782a5d
--- /dev/null
+++ b/lib_src/CHANGELOG.rst
@@ -0,0 +1,111 @@
+lib_src change log
+==================
+
+2.5.0
+-----
+
+ * ADDED: VPU enabled ASRC and SSRC providing a 2x speed improvement
+ * ADDED: Asynchronous FIFO with phase detector and PID rate controller for
+ ASRC usage
+ * ADDED: Support for XCommon CMake build system
+ * FIXED: Function pointer annotation avoid stack corruption when using
+ multiple instances of SSRC or ASRC.
+
+ * Changes to dependencies:
+
+ - lib_logging: 3.1.1 -> 3.2.0
+
+ - lib_xassert: Removed dependency
+
+2.4.0
+-----
+
+ * ADDED: Support for building the core ASRC code in the C emulator as a
+ library
+ * ADDED: Auto-generated ASRC and SSRC performance plots in documentation
+ * ADDED: Documentation warning about overflow in XS3 optimized SRC components
+ * CHANGED: Documents built under Jenkins instead of Github Actions
+ * CHANGED: Tested against fwk_core v1.0.2 updated from v1.0.0
+
+2.3.0
+-----
+
+ * ADDED: XS3 VPU optimised voice fixed factor of 3 upsampling/downsampling
+ * ADDED: XS3 VPU optimised voice fixed factor of 3/2 upsampling/downsampling
+ * CHANGED: OS3 uses firos3_144.dat coefficients by default inline with model
+ * CHANGED: Replaced xmostest with pytest for all SRC automated tests
+ * CHANGED: Used XMOS doc builder for documentation
+ * CHANGED: Golden reference test signals now generated automatically by CI
+ * RESOLVED: Linker warning on channel ends
+ * REMOVED: AN00231 ASRC App Note. See github.com/xmos/sln_voice/examples
+ * CHANGED: Increased precision of the fFsRatioDeviation used in the C emulator
+ from float to double
+ * CHANGED: Allow for 64 bits in the rate ratio passed to asrc_process() for
+ extra precision
+
+ * Changes to dependencies:
+
+ - lib_logging: 2.0.1 -> 3.1.1
+
+ - lib_xassert: 2.0.1 -> 4.1.0
+
+2.2.0
+-----
+
+ * CHANGED: Made the FIR coefficient array that is used with the voice fixed
+ factor of 3 up and down sampling functions usable from within C files as
+ well as XC files.
+ * CHANGED: Aligned the FIR coefficient array to an 8-byte boundary. This
+ ensures that the voice fixed factor of 3 up and down sampling functions do
+ not crash with a LOAD_STORE exception.
+ * ADDED: Missing device attributes to the .xn file of the AN00231 app note.
+ * ADDED: Minimal cmake support.
+
+2.1.0
+-----
+
+ * CHANGED: Use XMOS Public License Version 1
+
+2.0.1
+-----
+
+ * CHANGED: Pin Python package versions
+ * REMOVED: not necessary cpanfile
+
+2.0.0
+-----
+
+ * CHANGED: Build files updated to support new "xcommon" behavior in xwaf.
+
+1.1.2
+-----
+
+ * CHANGED: initialisation lists to avoid warnings when building
+
+1.1.1
+-----
+
+ * RESOLVED: correct compensation factor for voice upsampling
+ * ADDED: test of voice unity gain
+
+1.1.0
+-----
+
+ * ADDED: Fixed factor of 3 conversion functions for downsampling and
+ oversampling
+ * ADDED: Fixed factor of 3 downsampling function optimised for use with voice
+ (reduced memory and compute footprint)
+ * ADDED: Fixed factor of 3 upsampling function optimised for use with voice
+ (reduced memory and compute footprint)
+
+1.0.0
+-----
+
+ * Initial version
+
+ * Changes to dependencies:
+
+ - lib_logging: Added dependency 2.0.1
+
+ - lib_xassert: Added dependency 2.0.1
+
diff --git a/lib_src/CMakeLists.txt b/lib_src/CMakeLists.txt
new file mode 100644
index 0000000..6acc102
--- /dev/null
+++ b/lib_src/CMakeLists.txt
@@ -0,0 +1,84 @@
+cmake_minimum_required(VERSION 3.21.0)
+
+project(lib_src LANGUAGES C ASM)
+
+if(PROJECT_IS_TOP_LEVEL)
+ include(FetchContent)
+ FetchContent_Declare(
+ fwk_core
+ GIT_REPOSITORY https://github.com/xmos/fwk_core.git
+ GIT_TAG v1.0.2
+ )
+ FetchContent_MakeAvailable(fwk_core)
+endif()
+
+add_subdirectory(tests)
+
+# XS3 only libraries that use the Vector Processing Unit
+if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS3A)
+ ## Source files
+ file(GLOB_RECURSE LIB_C_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.c )
+ file(GLOB_RECURSE LIB_XC_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.xc)
+ file(GLOB_RECURSE LIB_ASM_SOURCES_XS3 lib_src/src/fixed_factor_vpu_voice/*.S )
+
+ set(ADDITIONAL_INCLUDE_DIRS_XS3 lib_src/src/fixed_factor_vpu_voice
+ )
+endif()
+
+
+if((${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS3A) OR (${CMAKE_SYSTEM_PROCESSOR} STREQUAL XCORE_XS2A))
+ ## Source files
+ file(GLOB_RECURSE LIB_C_SOURCES lib_src/src/fixed_factor_of_3/*.c
+ lib_src/src/fixed_factor_of_3_voice/*.c
+ lib_src/src/multirate_hifi/*.c
+ )
+ file(GLOB LIB_C_SOURCES_FIFO lib_src/src/*.c
+ )
+ file(GLOB_RECURSE LIB_XC_SOURCES lib_src/src/fixed_factor_of_3/*.xc
+ lib_src/src/fixed_factor_of_3_voice/*.xc
+ lib_src/src/multirate_hifi/*.xc
+ )
+ file(GLOB_RECURSE LIB_ASM_SOURCES lib_src/src/fixed_factor_of_3/*.S
+ lib_src/src/fixed_factor_of_3_voice/*.S
+ lib_src/src/multirate_hifi/*.S
+ )
+
+ ## Create library target
+ add_library(lib_src STATIC EXCLUDE_FROM_ALL ${LIB_C_SOURCES}
+ ${LIB_C_SOURCES_FIFO}
+ ${LIB_C_SOURCES_XS3}
+ ${LIB_ASM_SOURCES}
+ ${LIB_XC_SOURCES_XS3}
+ ${LIB_XC_SOURCES}
+ ${LIB_ASM_SOURCES_XS3}
+ )
+
+ target_include_directories(lib_src
+ PUBLIC
+ lib_src/api
+ lib_src/src/fixed_factor_of_3
+ lib_src/src/fixed_factor_of_3/ds3
+ lib_src/src/fixed_factor_of_3/os3
+ lib_src/src/fixed_factor_of_3_voice
+ lib_src/src/fixed_factor_of_3_voice/ds3_voice
+ lib_src/src/fixed_factor_of_3_voice/us3_voice
+ lib_src/src/multirate_hifi
+ lib_src/src/multirate_hifi/asrc
+ lib_src/src/multirate_hifi/ssrc
+ ${ADDITIONAL_INCLUDE_DIRS_XS3}
+ )
+
+ target_compile_options(lib_src
+ PRIVATE
+ -O3
+ -g
+ )
+
+ target_link_libraries(lib_src
+ PUBLIC
+ # defined in fwk_core
+ framework_core_legacy_compat
+ )
+
+
+endif()
diff --git a/lib_src/Jenkinsfile b/lib_src/Jenkinsfile
new file mode 100644
index 0000000..491024f
--- /dev/null
+++ b/lib_src/Jenkinsfile
@@ -0,0 +1,178 @@
+@Library('xmos_jenkins_shared_library@v0.25.0')
+
+def runningOn(machine) {
+ println "Stage running on:"
+ println machine
+}
+
+// run pytest with common flags for project. any passed in though extra args will
+// be appended
+def localRunPytest(String extra_args="") {
+ catchError{
+ sh "python -m pytest --junitxml=pytest_result.xml -rA -v --durations=0 -o junit_logging=all ${extra_args}"
+ }
+ junit "pytest_result.xml"
+}
+
+getApproval()
+
+pipeline {
+ agent none
+ environment {
+ REPO = 'lib_src'
+ VIEW = getViewName(REPO)
+ PYTHON_VERSION = "3.10.5"
+ VENV_DIRNAME = ".venv"
+ XMOSDOC_VERSION = "v4.0"
+ }
+ options {
+ skipDefaultCheckout()
+ timestamps()
+ }
+ parameters {
+ string(
+ name: 'TOOLS_VERSION',
+ defaultValue: '15.2.1',
+ description: 'The XTC tools version'
+ )
+ }
+ stages {
+ stage('Build and Test') {
+ when {
+ expression { !env.GH_LABEL_DOC_ONLY.toBoolean() }
+ }
+ agent {
+ label 'x86_64&&docker' // These agents have 24 cores so good for parallel xsim runs
+ }
+ stages {
+ stage('Get repo') {
+ steps {
+ sh "mkdir ${REPO}"
+ // source checks require the directory
+ // name to be the same as the repo name
+ dir("${REPO}") {
+ // checkout repo
+ checkout scm
+ sh 'git submodule update --init --recursive --depth 1'
+ }
+ }
+ }
+ stage ("Create Python environment") {
+ steps {
+ dir("${REPO}") {
+ createVenv('requirements.txt')
+ withVenv {
+ sh 'pip install -r requirements.txt'
+ }
+ }
+ }
+ }
+ stage('Library checks') {
+ steps {
+ dir("${REPO}") {
+ sh 'git clone git@github.com:xmos/infr_apps.git'
+ sh 'git clone git@github.com:xmos/infr_scripts_py.git'
+ // These are needed for xmake legacy build and also changelog check
+ sh 'git clone git@github.com:xmos/lib_logging.git'
+ sh 'git clone git@github.com:xmos/lib_xassert.git'
+ withVenv {
+ sh 'pip install -e infr_scripts_py'
+ sh 'pip install -e infr_apps'
+ dir("tests") {
+ withEnv(["XMOS_ROOT=.."]) {
+ localRunPytest('-s test_lib_checks.py -vv')
+ }
+ }
+ }
+ }
+ }
+ }
+ stage('Test xmake build') {
+ steps {
+ runningOn(env.NODE_NAME)
+ dir("${REPO}") {
+ withTools(params.TOOLS_VERSION) {
+ withVenv {
+ dir("tests") {
+ localRunPytest('-k "legacy" -vv')
+ }
+ }
+ }
+ }
+ }
+ }
+ stage('Run doc python') {
+ steps {
+ runningOn(env.NODE_NAME)
+ dir("${REPO}") {
+ withTools(params.TOOLS_VERSION) {
+ withVenv {
+ sh "sh doc/build_docs_ci.sh $XMOSDOC_VERSION"
+ archiveArtifacts artifacts: "doc_build.zip", allowEmptyArchive: true
+ }
+ }
+ }
+ }
+ }
+ stage('Tests XS2') {
+ steps {
+ runningOn(env.NODE_NAME)
+ dir("${REPO}") {
+ withTools(params.TOOLS_VERSION) {
+ withVenv {
+ sh 'mkdir -p build'
+ dir("build") {
+ sh 'rm CMakeCache.txt'
+ sh 'cmake --toolchain ../xmos_cmake_toolchain/xs2a.cmake ..'
+ sh 'make test_ds3_voice test_us3_voice test_unity_gain_voice -j'
+ }
+ dir("tests") {
+ localRunPytest('-n auto -k "xs2" -vv')
+ }
+ dir("build") {
+ sh 'rm CMakeCache.txt' // Cleanup XS2 cmake cache for next stage
+ }
+ }
+ }
+ }
+ }
+ }
+ stage('Tests XS3') {
+ steps {
+ runningOn(env.NODE_NAME)
+ dir("${REPO}") {
+ withTools(params.TOOLS_VERSION) {
+ withVenv {
+ dir("tests") {
+ localRunPytest('-m prepare') // Do all pre work like building and generating golden ref where needed
+
+ // FF3 HiFi tests for OS3 and DS3
+ localRunPytest('-m main -n auto -k "hifi_ff3" -vv')
+
+ // ASRC and SSRC tests across all in/out freqs and deviations (asrc only)
+ localRunPytest('-m main -n auto -k "mrhf" -vv')
+ archiveArtifacts artifacts: "mips_report*.csv", allowEmptyArchive: true
+
+ // VPU enabled ff3 and rat tests
+ localRunPytest('-m main -k "vpu" -vv') // xdist not working yet so no -n auto
+
+ // Profile the ASRC
+ localRunPytest('-m main -k "profile_asrc" -vv')
+ sh 'tree'
+ archiveArtifacts artifacts: "gprof_results/*.png", allowEmptyArchive: true
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ post {
+ cleanup {
+ xcoreCleanSandbox()
+ }
+ }
+ }
+
+ }
+}
diff --git a/lib_src/LICENSE.rst b/lib_src/LICENSE.rst
new file mode 100644
index 0000000..ca48f20
--- /dev/null
+++ b/lib_src/LICENSE.rst
@@ -0,0 +1,84 @@
+*******************************
+XMOS PUBLIC LICENCE: Version 1
+*******************************
+
+Subject to the conditions and limitations below, permission is hereby granted by XMOS LIMITED (“XMOS”), free of charge, to any person or entity obtaining a copy of the XMOS Software.
+
+**1. Definitions**
+
+**“Applicable Patent Rights”** means: (a) where XMOS is the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to XMOS and (ii) that cover subject matter contained in the Software, but only to the extent it is necessary to use, reproduce or distribute the Software without infringement; and (b) where you are the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to you and (ii) that cover the subject matter contained in your Derivatives, taken alone or in combination with the Software.
+
+**“Compiled Code”** means any compiled, binary, machine readable or executable version of the Source Code.
+
+**“Contributor”** means any person or entity that creates or contributes to the creation of Derivatives.
+
+**“Derivatives”** means any addition to, deletion from and/or change to the substance, structure of the Software, any previous Derivatives, the combination of the Derivatives and the Software and/or any respective portions thereof.
+
+**“Source Code”** means the human readable code that is suitable for making modifications but excluding any Compiled Code.
+
+**“Software”** means the software and associated documentation files which XMOS makes available and which contain a notice identifying the software as original XMOS software and referring to the software being subject to the terms of this XMOS Public Licence.
+
+This Licence refers to XMOS Software and does not relate to any XMOS hardware or devices which are protected by intellectual property rights (including patent and trade marks) which may be sold to you under a separate agreement.
+
+
+**2. Licence**
+
+**Permitted Uses, Conditions and Restrictions.** Subject to the conditions below, XMOS grants you a worldwide, royalty free, non-exclusive licence, to the extent of any Patent Rights to do the following:
+
+2.1 **Unmodified Software.** You may use, copy, display, publish, distribute and make available unmodified copies of the Software:
+
+2.1.1 for personal or academic, non-commercial purposes; or
+
+2.1.2 for commercial purposes provided the Software is at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.1.1 and 2.1.2):
+
+(a) you must retain and reproduce in all copies of the Software the copyright and proprietary notices and disclaimers of XMOS as they appear in the Software, and keep intact all notices and disclaimers in the Software files that refer to this Licence; and
+
+(b) you must include a copy of this Licence with every copy of the Software and documentation you publish, distribute and make available and you may not offer or impose any terms on such Software that alter or restrict this Licence or the intent of such Licence, except as permitted below (Additional Terms).
+
+The licence above does not include any Compiled Code which XMOS may make available under a separate support and licence agreement.
+
+2.2 **Derivatives.** You may create and modify Derivatives and use, copy, display, publish, distribute and make available Derivatives:
+
+2.2.1 for personal or academic, non-commercial purposes; or
+
+2.2.2 for commercial purposes, provided the Derivatives are at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.2.1 and 2.2.2):
+
+(a) you must comply with the terms of clause 2.1 with respect to the Derivatives;
+
+(b) you must copy (to the extent it doesn’t already exist) the notice below in each file of the Derivatives, and ensure all the modified files carry prominent notices stating that you have changed the files and the date of any change; and
+
+(c) if you sublicence, distribute or otherwise make the Software and/or the Derivatives available for commercial purposes, you must provide that the Software and Derivatives are at all times used on a device designed, licensed or developed by XMOS.
+
+Without limitation to these terms and clause 3 below, the Source Code and Compiled Code to your Derivatives may at your discretion (but without obligation) be released, copied, displayed, published, distributed and made available; and if you elect to do so, it must be under the terms of this Licence including the terms of the licence at clauses 2.2.1, 2.2.2 and clause 3 below.
+
+2.3 **Distribution of Executable Versions.** If you distribute or make available Derivatives, you must include a prominent notice in the code itself as well as in all related documentation, stating that the Source Code of the Software from which the Derivatives are based is available under the terms of this Licence, with information on how and where to obtain such Source Code.
+
+**3. Your Grant of Rights.** In consideration and as a condition to this Licence, you grant to any person or entity receiving or distributing any Derivatives, a non-exclusive, royalty free, perpetual, irrevocable license under your Applicable Patent Rights and all other intellectual property rights owned or controlled by you, to use, copy, display, publish, distribute and make available your Derivatives of the same scope and extent as XMOS’s licence under clause 2.2 above.
+
+**4. Combined Products.** You may create a combined product by combining Software, Derivatives and other code not covered by this Licence as a single application or product. In such instance, you must comply with the requirements of this Licence for any portion of the Software and/or Derivatives.
+
+**5. Additional Terms.** You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations and/or other rights consistent with the term of this Licence (“Additional Terms”) to any legitimate recipients of the Software and/or Derivatives. The terms on which you provide such Additional Terms are on your sole responsibility and you shall indemnify, defend and hold XMOS harmless against any claims asserted against XMOS.
+
+**6. New Versions.** XMOS may publish revised and/or new versions of this Licence from time to time to accommodate changes to the Licence terms, new versions, updates and bug fixes of the Software. Each version will be given a distinguishing version number. Once Software has been published under a particular version of this Licence, you may continue to use it under the terms of that version. You may also choose to use the latest version of the Software under any subsequent version published by XMOS. Only XMOS shall have the right to modify these terms.
+
+**7. IPR and Ownership**
+Any rights, including all intellectual property rights and all trademarks not expressly granted herein are reserved in full by the authors or copyright holders. Any requests for additional permissions by XMOS including any rights to use XMOS trademarks, should be made (without obligation) to XMOS at **support@xmos.com**
+
+Nothing herein shall limit any rights that XMOS is otherwise entitled to under the doctrines of patent exhaustion, implied license, or legal estoppel. Neither the name of the authors, the copyright holders or any contributors may be used to endorse or promote any Derivatives from this Software without specific written permission. Any attempt to deal with the Software which does not comply with this Licence shall be void and shall automatically terminate any rights granted under this licence (including any licence of any intellectual property rights granted herein).
+Subject to the licences granted under this Licence any Contributor retains all rights, title and interest in and to any Derivatives made by Contributor subject to the underlying rights of XMOS in the Software. XMOS shall retain all rights, title and interest in the Software and any Derivatives made by XMOS (“XMOS Derivatives”). XMOS Derivatives will not automatically be subject to this Licence and XMOS shall be entitled to licence such rights on any terms (without obligation) as it sees fit.
+
+**8. Termination**
+
+8.1 This Licence will automatically terminate immediately, without notice to you, if:
+
+(a) you fail to comply with the terms of this Licence; and/or
+
+(b) you directly or indirectly commence any action for patent or intellectual property right infringement against XMOS, or any parent, group, affiliate or subsidiary of XMOS; provided XMOS did not first commence an action or patent infringement against you in that instance; and/or
+
+(c) the terms of this Licence are held by any court of competent jurisdiction to be unenforceable in whole or in part.
+
+**9. Critical Applications.** Unless XMOS has agreed in writing with you an agreement specifically governing use of the Goods in military, aerospace, automotive or medically related functions (collectively and individually hereinafter referred to as "Special Use"), any permitted use of the Software excludes Special Use. Notwithstanding any agreement between XMOS and you for Special Use, Special Use shall be at your own risk, and you shall fully indemnify XMOS against any damages, losses, costs and claims (direct and indirect) arising out of any Special Use.
+
+**10. NO WARRANTY OR SUPPORT.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XMOS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, WARRANTY, CIVIL TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE INCLUDING GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND NOT WITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE. IN SOME JURISDICTIONS PARTIES ARE UNABLE TO LIMIT LIABILTY IN THIS WAY, IF THIS APPLIES TO YOUR JURISDICTION THIS LIABILITY CLAUSE ABOVE MAY NOT APPLY. NOTWITHSTANDING THE ABOVE, IN NO EVENT SHALL XMOS’s TOTAL LIABILITY TO YOU FOR ALL DAMAGES, LOSS OR OTHERWISE EXCEED $50.
+
+**11. Governing Law and Jurisdiction.** This Licence constitutes the entire agreement between the parties with respect to the subject matter hereof. The Licence shall be governed by the laws of England and the conflict of laws and UN Convention on Contracts for the International Sale of Goods, shall not apply.
diff --git a/lib_src/README.rst b/lib_src/README.rst
new file mode 100644
index 0000000..09ed325
--- /dev/null
+++ b/lib_src/README.rst
@@ -0,0 +1,76 @@
+Sample Rate Conversion Library
+==============================
+
+Overview
+--------
+
+The XMOS Sample Rate Conversion (SRC) library provides both synchronous and asynchronous audio sample rate conversion functions for use on xCORE multicore micro-controllers.
+
+In systems where the rate change is exactly equal to the ratio of nominal rates, synchronous sample rate conversion (SSRC) provides efficient and high performance rate conversion. Where the input and output rates are not locked by a common clock or clocked by an exact rational frequency ratio, the Asynchronous Sample Rate Converter (ASRC) provides a way of streaming high quality audio between the two different clock domains, at the cost of higher processing resource usage. ASRC can ease interfacing in cases where there are multiple digital audio inputs or allow cost saving by removing the need for physical clock recovery using a PLL.
+
+Features
+........
+
+Multi-rate Hi-Fi functionality:
+
+ * Conversion between 44.1, 48, 88.2, 96, 176.4 and 192 KHz input and output sample rates.
+ * 32 bit PCM input and output data in Q1.31 signed format.
+ * Optional output dithering to 24 bit using Triangular Probability Density Function (TPDF).
+ * Optimized for xCORE-200 instruction set with dual-issue and compatible with XCORE-AI.
+ * Block based processing - Minimum 4 samples input per call, must be power of 2.
+ * Up to 10000 ppm sample rate ratio deviation from nominal rate (ASRC only).
+ * Very high quality - SNR greater than 135 dB (ASRC) or 140 dB (SSRC), with THD of less than 0.0001% (reference 1KHz).
+ * Configurable number of audio channels per SRC instance.
+ * Reentrant library permitting multiple instances with differing configurations and channel count.
+ * No external components (PLL or memory) required.
+
+Fixed factor functionality:
+
+ * Synchronous fixed factor of 3 downsample and oversample functions supporting either HiFi quality or reduced resource requirements for voice applications.
+ * Synchronous fixed factor of 3 and 3/2 downsample and oversample functions for voice applications optimized for the XS3 Vector Processing Unit.
+
+Building
+........
+
+The library can be built under `cmake` or `xcommon` via `xmake` offering backwards compatibility for legacy applications.
+It is recommended to use `cmake` where the library name `lib_src` is included in the cmake files. See `Related application notes`_ for example usage.
+The library has no dependencies when building under `cmake` although does require `lib_logging` and `lib_xassert` when using `xcommon`.
+
+Components
+..........
+
+ * Synchronous Sample Rate Converter function (ssrc)
+ * Asynchronous Sample Rate Converter function (asrc)
+
+ * Synchronous factor of 3 downsample function (ds3)
+ * Synchronous factor of 3 oversample function (os3)
+
+ * Synchronous factor of 3 downsample function optimized for use with voice (src_ds3_voice)
+ * Synchronous factor of 3 oversample function optimised for use with voice (src_us3_voice)
+
+ * Synchronous factor of 3 downsample function for use with voice optimized for XS3 (ff3_96t_ds)
+ * Synchronous factor of 3 oversample function for use with voice optimized for XS3 (ff3_96t_us)
+
+ * Synchronous factor of 3/2 downsample function for use with voice optimized for XS3 (rat_2_3_96t_ds)
+ * Synchronous factor of 3/2 oversample function for use with voice optimized for XS3 (rat_3_2_96t_us)
+
+There are three different component options that support fixed factor of 3 up/downsampling. To help choose which one to use follow these steps:
+
+ #. If HiFi quality (130 dB SNR) up/downsampling is required, use ds3 or os3.
+ #. If voice quality (65 dB SNR) is required running on xCORE-200, use ds3_voice or us3_voice.
+ #. If voice quality (75 dB SNR) is required running xcore-ai, use ff3_96t_ds or ff3_96t_us.
+
+.. warning::
+ Synchronous fixed factor of 3 and 3/2 downsample and oversample functions for voice applications optimized for the XS3 Vector Processing Unit
+ currently overflow rather than saturate in cases where a full scale input causes a perturbation above full scale at the output.
+ To avoid this scenario, please ensure that the input amplitude is always 3.5 dB below full scale.
+ The overflow behavior of these SRC components will be replaced by saturating behavior (to match all other SRC components) in a future release.
+
+
+Related Application Notes
+.........................
+
+An adaptive USB Audio ASRC example can be found in https://github.com/xmos/sln_voice/tree/develop/examples.
+
+Simple file-based test applications may be found in this repo under `tests/xxxx_test` where xxxx is either `asrc`, `ssrc`, `ds3`, `os3`, `ds3_voice`, `os3_voice`, `vpu_ff3` or `vpu_rat`.
+These test applications may be used as basic examples to show how these components are used in a minimal application.
\ No newline at end of file
diff --git a/lib_src/index.rst b/lib_src/index.rst
new file mode 100644
index 0000000..6d3b4a8
--- /dev/null
+++ b/lib_src/index.rst
@@ -0,0 +1,10 @@
+######################
+SAMPLE RATE CONVERSION
+######################
+
+
+.. toctree::
+ :maxdepth: 5
+
+ ./doc/programming_guide/index.rst
+ ./doc/python/_build/rst/allPlots.rst
diff --git a/lib_src/lib_src/.cproject b/lib_src/lib_src/.cproject
new file mode 100644
index 0000000..28fda5d
--- /dev/null
+++ b/lib_src/lib_src/.cproject
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_src/lib_src/.project b/lib_src/lib_src/.project
new file mode 100644
index 0000000..293603f
--- /dev/null
+++ b/lib_src/lib_src/.project
@@ -0,0 +1,42 @@
+
+
+ lib_src
+
+
+
+
+
+ com.xmos.cdt.core.LegacyProjectCheckerBuilder
+
+
+
+
+ com.xmos.cdt.core.ProjectInfoSyncBuilder
+
+
+
+
+ com.xmos.cdt.core.ModulePathBuilder
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_src/lib_src/LICENSE.rst b/lib_src/lib_src/LICENSE.rst
new file mode 100644
index 0000000..ca48f20
--- /dev/null
+++ b/lib_src/lib_src/LICENSE.rst
@@ -0,0 +1,84 @@
+*******************************
+XMOS PUBLIC LICENCE: Version 1
+*******************************
+
+Subject to the conditions and limitations below, permission is hereby granted by XMOS LIMITED (“XMOS”), free of charge, to any person or entity obtaining a copy of the XMOS Software.
+
+**1. Definitions**
+
+**“Applicable Patent Rights”** means: (a) where XMOS is the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to XMOS and (ii) that cover subject matter contained in the Software, but only to the extent it is necessary to use, reproduce or distribute the Software without infringement; and (b) where you are the grantor of the rights, (i) claims of patents that are now or in future owned by or assigned to you and (ii) that cover the subject matter contained in your Derivatives, taken alone or in combination with the Software.
+
+**“Compiled Code”** means any compiled, binary, machine readable or executable version of the Source Code.
+
+**“Contributor”** means any person or entity that creates or contributes to the creation of Derivatives.
+
+**“Derivatives”** means any addition to, deletion from and/or change to the substance, structure of the Software, any previous Derivatives, the combination of the Derivatives and the Software and/or any respective portions thereof.
+
+**“Source Code”** means the human readable code that is suitable for making modifications but excluding any Compiled Code.
+
+**“Software”** means the software and associated documentation files which XMOS makes available and which contain a notice identifying the software as original XMOS software and referring to the software being subject to the terms of this XMOS Public Licence.
+
+This Licence refers to XMOS Software and does not relate to any XMOS hardware or devices which are protected by intellectual property rights (including patent and trade marks) which may be sold to you under a separate agreement.
+
+
+**2. Licence**
+
+**Permitted Uses, Conditions and Restrictions.** Subject to the conditions below, XMOS grants you a worldwide, royalty free, non-exclusive licence, to the extent of any Patent Rights to do the following:
+
+2.1 **Unmodified Software.** You may use, copy, display, publish, distribute and make available unmodified copies of the Software:
+
+2.1.1 for personal or academic, non-commercial purposes; or
+
+2.1.2 for commercial purposes provided the Software is at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.1.1 and 2.1.2):
+
+(a) you must retain and reproduce in all copies of the Software the copyright and proprietary notices and disclaimers of XMOS as they appear in the Software, and keep intact all notices and disclaimers in the Software files that refer to this Licence; and
+
+(b) you must include a copy of this Licence with every copy of the Software and documentation you publish, distribute and make available and you may not offer or impose any terms on such Software that alter or restrict this Licence or the intent of such Licence, except as permitted below (Additional Terms).
+
+The licence above does not include any Compiled Code which XMOS may make available under a separate support and licence agreement.
+
+2.2 **Derivatives.** You may create and modify Derivatives and use, copy, display, publish, distribute and make available Derivatives:
+
+2.2.1 for personal or academic, non-commercial purposes; or
+
+2.2.2 for commercial purposes, provided the Derivatives are at all times used on a device designed, licensed or developed by XMOS and, provided that in each instance (2.2.1 and 2.2.2):
+
+(a) you must comply with the terms of clause 2.1 with respect to the Derivatives;
+
+(b) you must copy (to the extent it doesn’t already exist) the notice below in each file of the Derivatives, and ensure all the modified files carry prominent notices stating that you have changed the files and the date of any change; and
+
+(c) if you sublicence, distribute or otherwise make the Software and/or the Derivatives available for commercial purposes, you must provide that the Software and Derivatives are at all times used on a device designed, licensed or developed by XMOS.
+
+Without limitation to these terms and clause 3 below, the Source Code and Compiled Code to your Derivatives may at your discretion (but without obligation) be released, copied, displayed, published, distributed and made available; and if you elect to do so, it must be under the terms of this Licence including the terms of the licence at clauses 2.2.1, 2.2.2 and clause 3 below.
+
+2.3 **Distribution of Executable Versions.** If you distribute or make available Derivatives, you must include a prominent notice in the code itself as well as in all related documentation, stating that the Source Code of the Software from which the Derivatives are based is available under the terms of this Licence, with information on how and where to obtain such Source Code.
+
+**3. Your Grant of Rights.** In consideration and as a condition to this Licence, you grant to any person or entity receiving or distributing any Derivatives, a non-exclusive, royalty free, perpetual, irrevocable license under your Applicable Patent Rights and all other intellectual property rights owned or controlled by you, to use, copy, display, publish, distribute and make available your Derivatives of the same scope and extent as XMOS’s licence under clause 2.2 above.
+
+**4. Combined Products.** You may create a combined product by combining Software, Derivatives and other code not covered by this Licence as a single application or product. In such instance, you must comply with the requirements of this Licence for any portion of the Software and/or Derivatives.
+
+**5. Additional Terms.** You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations and/or other rights consistent with the term of this Licence (“Additional Terms”) to any legitimate recipients of the Software and/or Derivatives. The terms on which you provide such Additional Terms are on your sole responsibility and you shall indemnify, defend and hold XMOS harmless against any claims asserted against XMOS.
+
+**6. New Versions.** XMOS may publish revised and/or new versions of this Licence from time to time to accommodate changes to the Licence terms, new versions, updates and bug fixes of the Software. Each version will be given a distinguishing version number. Once Software has been published under a particular version of this Licence, you may continue to use it under the terms of that version. You may also choose to use the latest version of the Software under any subsequent version published by XMOS. Only XMOS shall have the right to modify these terms.
+
+**7. IPR and Ownership**
+Any rights, including all intellectual property rights and all trademarks not expressly granted herein are reserved in full by the authors or copyright holders. Any requests for additional permissions by XMOS including any rights to use XMOS trademarks, should be made (without obligation) to XMOS at **support@xmos.com**
+
+Nothing herein shall limit any rights that XMOS is otherwise entitled to under the doctrines of patent exhaustion, implied license, or legal estoppel. Neither the name of the authors, the copyright holders or any contributors may be used to endorse or promote any Derivatives from this Software without specific written permission. Any attempt to deal with the Software which does not comply with this Licence shall be void and shall automatically terminate any rights granted under this licence (including any licence of any intellectual property rights granted herein).
+Subject to the licences granted under this Licence any Contributor retains all rights, title and interest in and to any Derivatives made by Contributor subject to the underlying rights of XMOS in the Software. XMOS shall retain all rights, title and interest in the Software and any Derivatives made by XMOS (“XMOS Derivatives”). XMOS Derivatives will not automatically be subject to this Licence and XMOS shall be entitled to licence such rights on any terms (without obligation) as it sees fit.
+
+**8. Termination**
+
+8.1 This Licence will automatically terminate immediately, without notice to you, if:
+
+(a) you fail to comply with the terms of this Licence; and/or
+
+(b) you directly or indirectly commence any action for patent or intellectual property right infringement against XMOS, or any parent, group, affiliate or subsidiary of XMOS; provided XMOS did not first commence an action or patent infringement against you in that instance; and/or
+
+(c) the terms of this Licence are held by any court of competent jurisdiction to be unenforceable in whole or in part.
+
+**9. Critical Applications.** Unless XMOS has agreed in writing with you an agreement specifically governing use of the Goods in military, aerospace, automotive or medically related functions (collectively and individually hereinafter referred to as "Special Use"), any permitted use of the Software excludes Special Use. Notwithstanding any agreement between XMOS and you for Special Use, Special Use shall be at your own risk, and you shall fully indemnify XMOS against any damages, losses, costs and claims (direct and indirect) arising out of any Special Use.
+
+**10. NO WARRANTY OR SUPPORT.** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XMOS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, WARRANTY, CIVIL TORT (INCLUDING NEGLIGENCE), PRODUCTS LIABILITY OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE INCLUDING GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES EVEN IF SUCH PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND NOT WITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE. IN SOME JURISDICTIONS PARTIES ARE UNABLE TO LIMIT LIABILTY IN THIS WAY, IF THIS APPLIES TO YOUR JURISDICTION THIS LIABILITY CLAUSE ABOVE MAY NOT APPLY. NOTWITHSTANDING THE ABOVE, IN NO EVENT SHALL XMOS’s TOTAL LIABILITY TO YOU FOR ALL DAMAGES, LOSS OR OTHERWISE EXCEED $50.
+
+**11. Governing Law and Jurisdiction.** This Licence constitutes the entire agreement between the parties with respect to the subject matter hereof. The Licence shall be governed by the laws of England and the conflict of laws and UN Convention on Contracts for the International Sale of Goods, shall not apply.
diff --git a/lib_src/lib_src/api/asrc_timestamp_interpolation.h b/lib_src/lib_src/api/asrc_timestamp_interpolation.h
new file mode 100644
index 0000000..d158d53
--- /dev/null
+++ b/lib_src/lib_src/api/asrc_timestamp_interpolation.h
@@ -0,0 +1,41 @@
+// Copyright 2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef _asrc_timestamp_interpolation_h_
+#define _asrc_timestamp_interpolation_h_
+
+#include "src.h"
+
+#ifdef __XC__
+#define UNSAFE unsafe
+#else
+#define UNSAFE
+#endif
+
+
+/**
+ * \addtogroup src_fifo_interp src_fifo_interp
+ *
+ * The public API for using Asynchronous FIFO.
+ * @{
+ */
+
+/**
+ * Function that interpolates a timestamp for a sample generated by the ASRC.
+ * Given a measured timestamp for the sample going into the ASRC, the asrc control
+ * structure, and the expected output frequency, this function returns a timestamp
+ * for when the last sample was produced by the ASRC.
+ *
+ * @param timestamp Value of the reference clock taken when the last sample
+ * fed into the ASRC was sampled.
+ *
+ * @param asrc_ctrl ASRC control block
+ *
+ * @param ideal_freq Expected base frequency to which the ASRC is operating;
+ * eg, 48000 or 44100
+ */
+int asrc_timestamp_interpolation(int timestamp, asrc_ctrl_t * UNSAFE asrc_ctrl, int ideal_freq);
+
+/**@}*/ // END: addtogroup src_fifo_interp
+
+#endif
diff --git a/lib_src/lib_src/api/asynchronous_fifo.h b/lib_src/lib_src/api/asynchronous_fifo.h
new file mode 100644
index 0000000..19491a4
--- /dev/null
+++ b/lib_src/lib_src/api/asynchronous_fifo.h
@@ -0,0 +1,224 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef _asynchronous_fifo_h__
+#define _asynchronous_fifo_h__
+
+#include
+#include
+
+#define FREQUENCY_RATIO_EXPONENT (32)
+
+#ifdef __XC__
+#define UNSAFE unsafe
+#else
+#define UNSAFE
+#endif
+
+/**
+ * \addtogroup src_fifo src_fifo
+ *
+ * The public API for using Asynchronous FIFO.
+ * @{
+ */
+
+
+/**
+ * Data structure that holds the status of an asynchronous FIFO
+ */
+typedef struct asynchronous_fifo_t {
+ // Updated on initialisation only
+ int32_t channel_count; /* Number of audio channels */
+ int32_t copy_mask; /* Number of audio channels */
+ int32_t max_fifo_depth; /* Length of buffer[] in channel_counts */
+ int32_t ideal_phase_error_ticks; /* Ideal ticks between samples */
+ int32_t Ki; /* Ki PID coefficient */
+ int32_t Kp; /* Kp PID coefficient */
+
+ // Updated on the producer side only
+ int skip_ctr; /* Set to indicate initialisation runs */
+ int32_t write_ptr; /* Write index in the buffer */
+ int64_t last_phase_error; /* previous error, used for proportional */
+ int64_t frequency_ratio; /* Current ratio of frequencies in 64.64 */
+ int32_t stop_producing; /* In case of overflow, stops producer until consumer restarts and requests a reset */
+
+ // Updated on the consumer side only
+ uint32_t read_ptr; /* Read index in the buffer */
+
+ // Set by producer, reset by consumer
+ uint32_t reset; /* Set to 1 if consumer wants a reset */
+
+ // Updated from both sides
+ uint32_t * UNSAFE timestamps; /* Timestamps of samples */
+ int32_t buffer[0]; /* Buffer of data */
+} asynchronous_fifo_t;
+
+
+/**
+ * Function that must be called to initialise the asynchronous FIFO.
+ * The ``state`` argument should be an int64_t array of
+ * ``ASYNCHRONOUS_FIFO_INT64_ELEMENTS`` elements that is cast to
+ * ``asynchronous_fifo_t*``.
+ *
+ * That pointer should also be used for all other operations, including operations
+ * both the consumer and producer sides.
+ *
+ * After initialising, you must initialise the PID by calling one of
+ * asynchronous_fifo_init_PID_fs_codes() or
+ * asynchronous_fifo_init_PID_raw()
+ *
+ * @param state Asynchronous FIFO to be initialised
+ *
+ * @param channel_count Number of audio channels
+ *
+ * @param max_fifo_depth Length of the FIFO, delay when stable will be max_fifo_depth/2
+ */
+void asynchronous_fifo_init(asynchronous_fifo_t * UNSAFE state,
+ int channel_count,
+ int max_fifo_depth);
+
+/**
+ * Function that that initialises the PID of a FIFO. Either this function
+ * or asynchronous_fifo_init_PID_raw() should be called. This function
+ * uses frequency codes as defined in the ASRC for a quick default setup,
+ * the raw function allows full control
+ *
+ * @param state Asynchronous FIFO to be initialised
+ *
+ * @param fs_input Input FS ratio, used to pick appropriate Kp, and Ki.
+ * Must be a number less than 6.
+ *
+ * @param fs_output Input FS ratio, used to pick appropriate Kp, Ki,
+ * ideal phase. Must be a number less than 6.
+ */
+void asynchronous_fifo_init_PID_fs_codes(asynchronous_fifo_t * UNSAFE state,
+ int fs_input,
+ int fs_output);
+
+/**
+ * Function that that initialises the PID of a FIFO. Either this function
+ * or asynchronous_fifo_init_PID_raw() should be called. This function
+ * uses frequency codes as defined in the ASRC for a quick default setup,
+ * the raw function allows full control.
+ *
+ * This function may be called at any time by the producer in order to alter the PID
+ * and midpoint settings. It does not reset the error; one of the
+ * asynchronous_fifo_init_reset_producer() or
+ * asynchronous_fifo_init_reset_consumer() functions should be called for that.
+ *
+ * @param state Asynchronous FIFO to be initialised
+ *
+ * @param Kp Proportional constant for the FIFO.
+ * This gets multiplied by the differential
+ * error measured in ticks (typically -2..2)
+ * and added to the ratio_error. A typical
+ * value is 30,000,000 - 60,000,000.
+ *
+ * @param Ki Integral constant for the FIFO.
+ * This gets multiplied by the phase error
+ * measured in ticks (typically -20,000 - 20,000)
+ * and added to the ratio_error.
+ * A typical value is 200 - 300.
+ *
+ * @param ticks_between_samples The number of ticks between samples is used to
+ * estimate the expected phase error halfway down
+ * the FIFO.
+ */
+void asynchronous_fifo_init_PID_raw(asynchronous_fifo_t * UNSAFE state,
+ int Kp,
+ int Ki,
+ int ticks_between_samples);
+
+/**
+ * Function that that resets the FIFO from the producer side. Either this function should
+ * be called on the producing side, or ``asynchronous_fifo_reset_consumer``
+ * should be called on the consumer side. In both cases the whole FIFO will be reset back
+ *
+ * @param state Asynchronous FIFO to be initialised
+ */
+void asynchronous_fifo_reset_producer(asynchronous_fifo_t * UNSAFE state);
+
+/**
+ * Function that that resets the FIFO from the consumer side. Either this function should
+ * be called on the consuming side, or asynchronous_fifo_reset_producer()
+ * should be called on the producer side. In both cases the whole FIFO will be reset back
+ *
+ * @param state Asynchronous FIFO to be initialised
+ */
+void asynchronous_fifo_reset_consumer(asynchronous_fifo_t * UNSAFE state);
+
+/**
+ * Function that must be called to deinitalise the asynchronous FIFO
+ *
+ * @param state ASRC structure to be de-initialised
+ */
+void asynchronous_fifo_exit(asynchronous_fifo_t * UNSAFE state);
+
+/**
+ * Function that provides the next samples to the asynchronous FIFO.
+ *
+ * This function and asynchronous_fifo_consumer_get() function both need a timestamp,
+ * which is the time that the last sample was input (this function) or
+ * output (asynchronous_fifo_consumer_get()). The asynchronous FIFO will hand the
+ * samples across from producer to consumer through an elastic queue, and run
+ * a PID algorithm to calculate the best way to equalise the input clock relative
+ * to the output clock. Therefore, the timestamps
+ * have to be measured on either the same clock or two very similar clocks.
+ * It is probably fine to use the reference clocks on two tiles, provided
+ * the tiles came out of reset at more or less the same time. Using the
+ * clocks from two different chips would require the two chips to share an
+ * oscillator, and for them to come out of reset simultaneously.
+ *
+ * @param state ASRC structure to push the sample into
+ *
+ * @param samples The sample values.
+ *
+ * @param n The number of samples
+ *
+ * @param timestamp The number of ticks when this sample was input.
+ *
+ * @param xscope_used Set to 1 if the PID values should be output over
+ * xscope. Used for debugging. This parameter is subject to be removed in future revisions.
+ *
+ * @returns The current estimate of the mismatch of input and output frequencies.
+ * This is represented as a 32-bit signed number. Zero means no mismatch,
+ * a value less than zero means that the producer is faster than the consumer,
+ * a value greater than zero means that the producer is slower than the consumer.
+ * The value should be scaled by 2**-32. That is, the current best
+ * approximation for consumer_speed/producer_speed is 1 + (return_value * 2**-32)
+ *
+ * The output is filtered and should be applied directly as a correction factor
+ * eg, multiplied into an ASRC ratio, or multiplied into a PLL timing.
+ */
+int32_t asynchronous_fifo_producer_put(asynchronous_fifo_t * UNSAFE state,
+ int32_t * UNSAFE samples,
+ int n,
+ int32_t timestamp,
+ int xscope_used);
+
+
+/**
+ * Function that gets an output sample from the asynchronous FIFO
+ *
+ * @param state ASRC structure to read a sample out off.
+ *
+ * @param samples The array where the frame with output
+ * samples will be stored.
+ *
+ * @param timestamp A timestamp taken at the time that the
+ * last sample was output. See
+ * ``asynchronous_fifo_produce`` for requirements.
+ */
+void asynchronous_fifo_consumer_get(asynchronous_fifo_t * UNSAFE state,
+ int32_t * UNSAFE samples,
+ int32_t timestamp);
+
+
+/**
+ * macro that calculates the number of int64_t to be allocated for the fifo
+ * for a FIFO of N elements and C channels
+ */
+#define ASYNCHRONOUS_FIFO_INT64_ELEMENTS(N, C) (sizeof(asynchronous_fifo_t)/sizeof(int64_t) + (N*(C+1))/2+1)
+#endif
+
+/**@}*/ // END: addtogroup src_fifo
diff --git a/lib_src/lib_src/api/src.h b/lib_src/lib_src/api/src.h
new file mode 100644
index 0000000..57a7d39
--- /dev/null
+++ b/lib_src/lib_src/api/src.h
@@ -0,0 +1,243 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_H_
+#define _SRC_H_
+#include "src_mrhf_ssrc.h"
+#include "src_mrhf_asrc.h"
+#include "src_ff3_ds3.h"
+#include "src_ff3_os3.h"
+#include "src_ff3v_fir.h"
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+#include "src_poly.h"
+#endif // __XS3A__
+#include
+
+#if defined(__cplusplus) || defined(__XC__)
+extern "C" {
+#endif
+
+/** List of sample rate codes allowing the core SRC algorithms to use an index value */
+typedef enum fs_code_t {
+ FS_CODE_44 = 0,
+ FS_CODE_48 = 1,
+ FS_CODE_88 = 2,
+ FS_CODE_96 = 3,
+ FS_CODE_176 = 4,
+ FS_CODE_192 = 5
+} fs_code_t;
+
+/** Flag to switch dither processing to 24b (from 32b) on or off */
+typedef enum dither_flag_t {
+ OFF = 0,
+ ON = 1
+} dither_flag_t;
+
+/**
+ * \addtogroup src_ssrc src_ssrc
+ *
+ * The public API for using SSRC.
+ * @{
+ */
+
+/** initializes synchronous sample rate conversion instance.
+ * \param sr_in Nominal sample rate code of input stream
+ * \param sr_out Nominal sample rate code of output stream
+ * \param ssrc_ctrl Reference to array of SSRC control stuctures
+ * \param n_channels_per_instance Number of channels handled by this instance of SSRC
+ * \param n_in_samples Number of input samples per SSRC call
+ * \param dither_on_off Dither to 24b on/off
+ */
+void ssrc_init(const fs_code_t sr_in, const fs_code_t sr_out, ssrc_ctrl_t ssrc_ctrl[],
+ const unsigned n_channels_per_instance, const unsigned n_in_samples,
+ const dither_flag_t dither_on_off);
+
+/** Perform synchronous sample rate conversion processing on block of input samples using previously initialized settings.
+ *
+ * \param in_buff Reference to input sample buffer array
+ * \param out_buff Reference to output sample buffer array
+ * \param ssrc_ctrl Reference to array of SSRC control stuctures
+ * \returns The number of output samples produced by the SRC operation
+ */
+unsigned ssrc_process(int in_buff[], int out_buff[], ssrc_ctrl_t ssrc_ctrl[]);
+
+/**@}*/ // END: addtogroup src_ssrc
+
+/**
+ * \addtogroup src_asrc src_asrc
+ *
+ * The public API for using ASRC.
+ * @{
+ */
+
+/** initializes asynchronous sample rate conversion instance.
+ *
+ * \param sr_in Nominal sample rate code of input stream
+ * \param sr_out Nominal sample rate code of output stream
+ * \param asrc_ctrl Reference to array of ASRC control structures
+ * \param n_channels_per_instance Number of channels handled by this instance of SSRC
+ * \param n_in_samples Number of input samples per SSRC call
+ * \param dither_on_off Dither to 24b on/off
+ * \returns The nominal sample rate ratio of in to out in Q4.60 format
+ */
+uint64_t asrc_init(const fs_code_t sr_in, const fs_code_t sr_out,
+ asrc_ctrl_t asrc_ctrl[], const unsigned n_channels_per_instance,
+ const unsigned n_in_samples, const dither_flag_t dither_on_off);
+
+/** Perform asynchronous sample rate conversion processing on block of input samples using previously initialized settings.
+ *
+ * \param in_buff Reference to input sample buffer array
+ * \param out_buff Reference to output sample buffer array
+ * \param fs_ratio Fixed point ratio of in/out sample rates in Q4.60 format
+ * \param asrc_ctrl Reference to array of ASRC control structures
+ * \returns The number of output samples produced by the SRC operation.
+ */
+unsigned asrc_process(int in_buff[], int out_buff[], uint64_t fs_ratio,
+ asrc_ctrl_t asrc_ctrl[]);
+
+/**@}*/ // END: addtogroup src_asrc
+
+
+// To avoid C type definitions when including this file from assembler
+#ifndef INCLUDE_FROM_ASM
+
+/** Fixed factor of 3 return codes
+ *
+ * This type describes the possible error status states from calls to the DS3
+ * and OS3 API.
+ */
+typedef enum src_ff3_return_code_t
+{
+ SRC_FF3_NO_ERROR = 0,
+ SRC_FF3_ERROR = 1
+} src_ff3_return_code_t;
+
+/** Downsample by 3 control structure */
+typedef struct src_ds3_ctrl_t
+{
+ int* in_data; //!< Pointer to input data (3 samples)
+ int* out_data; //!< Pointer to output data (1 sample)
+ int* delay_base; //!< Pointer to delay line base
+ unsigned int delay_len; //!< Total length of delay line
+ int* delay_pos; //!< Pointer to current position in delay line
+ int* delay_wrap; //!< Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int delay_offset; //!< Delay line offset for second write (for circular buffer simulation)
+ unsigned int inner_loops; //!< Number of inner loop iterations
+ unsigned int num_coeffs; //!< Number of coefficients
+ int* coeffs; //!< Pointer to coefficients
+} src_ds3_ctrl_t;
+
+/** This function initializes the decimate by 3 function for a given instance
+ *
+ * \param src_ds3_ctrl DS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_ds3_init(src_ds3_ctrl_t* src_ds3_ctrl);
+
+/** This function clears the decimate by 3 delay line for a given instance
+ *
+ * \param src_ds3_ctrl DS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_ds3_sync(src_ds3_ctrl_t* src_ds3_ctrl);
+
+/** This function performs the decimation on three input samples and outputs one sample.
+ * The input and output buffers are pointed to by members of the src_ds3_ctrl structure
+ *
+ * \param src_ds3_ctrl DS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_ds3_proc(src_ds3_ctrl_t* src_ds3_ctrl);
+
+/** Oversample by 3 control structure */
+typedef struct src_os3_ctrl_t
+{
+ int in_data; //!< Input data (to be updated every 3 output samples, i.e. when iPhase == 0)
+ int out_data; //!< Output data (1 sample)
+ int phase; //!< Current output phase (when reaching '0', a new input sample is required)
+ int* delay_base; //!< Pointer to delay line base
+ unsigned int delay_len; //!< Total length of delay line
+ int* delay_pos; //!< Pointer to current position in delay line
+ int* delay_wrap; //!< Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int delay_offset; //!< Delay line offset for second write (for circular buffer simulation)
+ unsigned int inner_loops; //!< Number of inner loop iterations
+ unsigned int num_coeffs; //!< Number of coefficients
+ int* coeffs; //!< Pointer to coefficients
+} src_os3_ctrl_t;
+
+/** This function initializes the oversample by 3 function for a given instance
+ *
+ * \param src_os3_ctrl OS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_os3_init(src_os3_ctrl_t* src_os3_ctrl);
+
+/** This function clears the oversample by 3 delay line for a given instance
+ *
+ * \param src_os3_ctrl OS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_os3_sync(src_os3_ctrl_t* src_os3_ctrl);
+
+/** This function pushes a single input sample into the filter.
+ * It should be called three times for each FIROS3_proc call
+ *
+ * \param src_os3_ctrl OS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_os3_input(src_os3_ctrl_t* src_os3_ctrl);
+
+/** This function performs the oversampling by 3 and outputs one sample.
+ * The input and output buffers are pointed to by members of the src_os3_ctrl structure
+ *
+ * \param src_os3_ctrl OS3 control structure
+ * \returns SRC_FF3_NO_ERROR on success, SRC_FF3_ERROR on failure
+ */
+src_ff3_return_code_t src_os3_proc(src_os3_ctrl_t* src_os3_ctrl);
+
+#endif // INCLUDE_FROM_ASM
+
+#if defined(__cplusplus) || defined(__XC__)
+}
+#endif
+
+/** This function performs the first two iterations of the downsampling process
+ *
+ * \param sum Partially accumulated value returned during previous cycle
+ * \param data Data delay line
+ * \param coefs FIR filter coefficients
+ * \param sample The newest sample
+ * \returns Partially accumulated value, passed as ``sum`` parameter next cycle
+ */
+int64_t src_ds3_voice_add_sample(int64_t sum, int32_t data[],
+ const int32_t coefs[], int32_t sample);
+
+/** This function performs the final iteration of the downsampling process
+ *
+ * \param sum Partially accumulated value returned during previous cycle
+ * \param data Data delay line
+ * \param coefs FIR filter coefficients
+ * \param sample The newest sample
+ * \returns The decimated sample
+ */
+int64_t src_ds3_voice_add_final_sample(int64_t sum, int32_t data[],
+ const int32_t coefs[], int32_t sample);
+
+/** This function performs the initial iteration of the upsampling process
+ *
+ * \param data Data delay line
+ * \param coefs FIR filter coefficients
+ * \param sample The newest sample
+ * \returns A decimated sample
+ */
+int32_t src_us3_voice_input_sample(int32_t data[], const int32_t coefs[],
+ int32_t sample);
+
+/** This function performs the final two iterations of the upsampling process
+ *
+ * \param data Data delay line
+ * \param coefs FIR filter coefficients
+ * \returns A decimated sample
+ */
+int32_t src_us3_voice_get_next_sample(int32_t data[], const int32_t coefs[]);
+
+#endif // _SRC_H_
diff --git a/lib_src/lib_src/lib_build_info.cmake b/lib_src/lib_src/lib_build_info.cmake
new file mode 100644
index 0000000..c5ca248
--- /dev/null
+++ b/lib_src/lib_src/lib_build_info.cmake
@@ -0,0 +1,21 @@
+set(LIB_NAME lib_src)
+set(LIB_VERSION 2.5.0)
+
+set(LIB_DEPENDENT_MODULES "lib_logging(3.2.0)")
+
+set(LIB_COMPILER_FLAGS -Wno-missing-braces -O3)
+
+set(LIB_OPTIONAL_HEADERS src_conf.h)
+
+set(LIB_INCLUDES api
+ src/fixed_factor_of_3
+ src/fixed_factor_of_3/ds3
+ src/fixed_factor_of_3/os3
+ src/fixed_factor_of_3_voice
+ src/multirate_hifi
+ src/multirate_hifi/asrc
+ src/multirate_hifi/ssrc
+ src/fixed_factor_vpu_voice)
+
+XMOS_REGISTER_MODULE()
+
diff --git a/lib_src/lib_src/module_build_info b/lib_src/lib_src/module_build_info
new file mode 100644
index 0000000..c38608c
--- /dev/null
+++ b/lib_src/lib_src/module_build_info
@@ -0,0 +1,23 @@
+VERSION = 2.5.0
+
+DEPENDENT_MODULES = lib_logging(>=3.2.0)
+
+MODULE_XCC_FLAGS = $(XCC_FLAGS) \
+ -Wno-missing-braces \
+ -O3
+
+OPTIONAL_HEADERS += src_conf.h
+
+EXPORT_INCLUDE_DIRS = api \
+ src/fixed_factor_of_3 \
+ src/fixed_factor_of_3/ds3 \
+ src/fixed_factor_of_3/os3 \
+ src/fixed_factor_of_3_voice \
+ src/multirate_hifi \
+ src/multirate_hifi/asrc \
+ src/multirate_hifi/ssrc \
+ src/fixed_factor_vpu_voice \
+ src/asrc_task
+
+INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS)
+
diff --git a/lib_src/lib_src/src/asrc_timestamp_interpolation.c b/lib_src/lib_src/src/asrc_timestamp_interpolation.c
new file mode 100644
index 0000000..23b2edd
--- /dev/null
+++ b/lib_src/lib_src/src/asrc_timestamp_interpolation.c
@@ -0,0 +1,18 @@
+// Copyright 2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#include
+#include "asrc_timestamp_interpolation.h"
+
+// TODO: replace TODO with BASE and 8/24 with division with MAX
+
+// TODO: check with 88200 and other input frequencies
+
+int asrc_timestamp_interpolation(int timestamp, asrc_ctrl_t *asrc_ctrl, int interpolation_ticks) {
+ // iTimeInt is an 8-bit number; fract a 32 bit number, with the two we make a 16-bit
+ // fraction that we multiply with and then shift down by 16 bits.
+ uint32_t fraction_away_from_final_ts = (((asrc_ctrl->iTimeInt - 128) << 8) |
+ ((asrc_ctrl->uiTimeFract >> 24) & 0xff));
+ int32_t left_over_ticks = (fraction_away_from_final_ts * interpolation_ticks) >> 16;
+ return timestamp + left_over_ticks;
+}
diff --git a/lib_src/lib_src/src/asynchronous_fifo.c b/lib_src/lib_src/src/asynchronous_fifo.c
new file mode 100644
index 0000000..a50e0d1
--- /dev/null
+++ b/lib_src/lib_src/src/asynchronous_fifo.c
@@ -0,0 +1,217 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#include
+#include "asynchronous_fifo.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "src.h"
+
+
+// TODO: Make fifo offset from N/2 a very small component in PID,
+
+/**
+ * Function that resets the producing side of the ASRC; called on initialisation, and
+ * and called during reset by the producer after the consumer is known to have thrown
+ * in the towel
+ */
+static void asynchronous_fifo_init_producing_side(asynchronous_fifo_t *state) {
+ state->skip_ctr = state->max_fifo_depth / 2 + 2;
+ state->write_ptr = (state->read_ptr + state->max_fifo_depth/2) % state->max_fifo_depth;
+ state->last_phase_error = 0;
+ state->frequency_ratio = 0; // Assume perfect match
+ state->stop_producing = 0;
+}
+
+/**
+ * Function that resets the consuming side of the ASRC; called on initialisation, and
+ * and called during reset by the consumer before it notifies the producer that a reset
+ * is needed.
+ */
+static void asynchronous_fifo_reset_consumer_flags(asynchronous_fifo_t *state) {
+ state->reset = 0; // This has to be the last one
+}
+
+#define K_SHIFT 16
+
+static int ticks_between_samples_1D[6] = {
+ 2268,2083,1134,1042, 567, 521
+};
+
+static int Ki_2D[6][6] = {
+ { 422, 422, 422, 422, 422, 422 },
+ { 422, 422, 422, 422, 422, 422 },
+ { 211, 211, 211, 211, 211, 211 },
+ { 211, 211, 211, 211, 211, 211 },
+ { 105, 105, 105, 105, 105, 105 },
+ { 105, 105, 105, 105, 105, 105 }
+};
+
+static int Kp_2D[6][6] = {
+ { 28147498, 28147498, 56294996, 56294996, 112589992, 112589992 },
+ { 28147498, 28147498, 56294996, 56294996, 112589992, 112589992 },
+ { 14073749, 14073749, 28147498, 28147498, 56294996, 56294996 },
+ { 14073749, 14073749, 28147498, 28147498, 56294996, 56294996 },
+ { 7036874, 7036874, 14073749, 14073749, 28147498, 28147498 },
+ { 7036874, 7036874, 14073749, 14073749, 28147498, 28147498 }
+};
+
+void asynchronous_fifo_init_PID_fs_codes(asynchronous_fifo_t *state,
+ int fs_input, int fs_output) {
+ int max_fifo_depth = state->max_fifo_depth;
+ state->Kp = Kp_2D[fs_input][fs_output];
+ state->Ki = Ki_2D[fs_input][fs_output];
+ state->ideal_phase_error_ticks = ticks_between_samples_1D[fs_output] * (max_fifo_depth/2 + 1);
+}
+
+void asynchronous_fifo_init_PID_raw(asynchronous_fifo_t *state,
+ int Kp, int Ki, int ticks_between_samples) {
+ int max_fifo_depth = state->max_fifo_depth;
+ state->Kp = Kp;
+ state->Ki = Ki;
+ state->ideal_phase_error_ticks = ticks_between_samples * (max_fifo_depth/2 + 1);
+}
+
+void asynchronous_fifo_init(asynchronous_fifo_t *state, int channel_count,
+ int max_fifo_depth) {
+ state->max_fifo_depth = max_fifo_depth;
+ state->timestamps = (uint32_t *)state->buffer + max_fifo_depth * channel_count;
+ state->channel_count = channel_count;
+ state->copy_mask = (1 << (4*channel_count)) - 1;
+
+ // First initialise shared variables, or those that shouldn't reset on a RESET.
+ state->read_ptr = 0;
+ // Now clear the buffer.
+ memset(state->buffer, 0, channel_count * max_fifo_depth * sizeof(int));
+ // Finally initialise those parts that are reset on a RESET
+ asynchronous_fifo_init_producing_side(state); // uses read_ptr
+ asynchronous_fifo_reset_consumer_flags(state);
+}
+
+void asynchronous_fifo_exit(asynchronous_fifo_t *state) {
+}
+
+int async_resets = 0;
+
+void asynchronous_fifo_reset_producer(asynchronous_fifo_t *state) {
+ state->stop_producing = 1;
+}
+
+void asynchronous_fifo_reset_consumer(asynchronous_fifo_t *state) {
+ state->reset = 1;
+}
+
+int32_t asynchronous_fifo_producer_put(asynchronous_fifo_t *state, int32_t *samples,
+ int n,
+ int32_t timestamp,
+ int xscope_used) {
+ int read_ptr = state->read_ptr;
+ int write_ptr = state->write_ptr;
+ int max_fifo_depth = state->max_fifo_depth;
+ int channel_count = state->channel_count;
+ int copy_mask = state->copy_mask;
+ int len = (write_ptr - read_ptr + max_fifo_depth) % max_fifo_depth;
+ if (state->reset) {
+ async_resets++;
+ asynchronous_fifo_init_producing_side(state); // uses read_ptr
+ asynchronous_fifo_reset_consumer_flags(state); // Last step - clears reset
+ } else if (len >= max_fifo_depth - 2 - n) {
+ state->stop_producing = 1;
+ } else if (!state->stop_producing && n) {
+ for(int j = 0; j < n; j++) {
+
+#ifdef __XS2A__
+ memcpy(state->buffer + write_ptr * channel_count, samples, channel_count * sizeof(int));
+ (void)copy_mask; // Remove unused var warning
+#else
+ register int32_t *ptr asm("r11") = samples;
+ asm("vldr %0[0]" :: "r" (ptr));
+ asm("vstrpv %0[0], %1" :: "r" (state->buffer + write_ptr * channel_count), "r" (copy_mask));
+#endif
+ samples += channel_count;
+ write_ptr = (write_ptr + 1);
+ if (write_ptr >= max_fifo_depth) {
+ write_ptr = 0;
+ }
+ }
+
+ /* Difference between timestamp recorded by consumer and current timestamp */
+ state->write_ptr = write_ptr;
+ int32_t phase_error = state->timestamps[write_ptr] - timestamp;
+
+ /* Ideal phase error is the middle of the fifo measured in ticks */
+ phase_error += state->ideal_phase_error_ticks;
+
+ /* Don't try and use timestamps that haven't been recorded yet! */
+ if (state->skip_ctr != 0) {
+ state->skip_ctr--;
+ } else {
+ // Now that we have a phase error, calculate the proportional error
+ // and use that and the integral error to correct the ASRC factor
+ int32_t diff_error = phase_error - state->last_phase_error;
+
+ state->frequency_ratio +=
+ (diff_error * (int64_t) (state->Kp / n)) + // TODO: make this lookup table
+ (phase_error * (int64_t) state->Ki);
+ if (xscope_used) {
+#if defined(ASYNC_FIFO_XSCOPE_INSTRUMENTATION)
+ xscope_int(1, phase_error);
+ xscope_int(2, diff_error);
+#endif
+ }
+ }
+ state->last_phase_error = phase_error;
+ }
+ if (xscope_used) {
+#if defined(ASYNC_FIFO_XSCOPE_INSTRUMENTATION)
+ xscope_int(3, len);
+ xscope_int(4, state->frequency_ratio >> K_SHIFT);
+#endif
+ }
+ return (state->frequency_ratio + (1<<(K_SHIFT-1))) >> K_SHIFT;
+}
+
+/**
+ * Function that implements the consumer interface. Control communication
+ * happens through two variables: reset and sample_data_valid. These shall
+ * only be set as the last action, as they signify to the production side
+ * that the datastructure can now be read on that side.
+ *
+ * Note that the samples are filled in regardless of whether the FIFO is
+ * operating or not; the consumer will repeatedly get the same sample if
+ * the producer fails. The producer side is reset exactly once on reset.
+ */
+void asynchronous_fifo_consumer_get(asynchronous_fifo_t *state, int32_t *samples, int32_t timestamp) {
+ int read_ptr = state->read_ptr;
+ int write_ptr = state->write_ptr;
+ int max_fifo_depth = state->max_fifo_depth;
+ int channel_count = state->channel_count;
+ int copy_mask = state->copy_mask;
+ int len = (write_ptr - read_ptr + max_fifo_depth) % max_fifo_depth;
+#ifdef __XS2A__
+ memcpy(samples, state->buffer + read_ptr * channel_count, channel_count * sizeof(int));
+ (void)copy_mask; // Remove unused var warning
+#else
+ register int32_t *ptr asm("r11") = state->buffer + read_ptr * channel_count;
+ asm("vldr %0[0]" :: "r" (ptr));
+ asm("vstrpv %0[0], %1" :: "r" (samples), "r" (copy_mask));
+#endif
+ if (state->reset) {
+ return;
+ }
+ if (len > 2) {
+ // TODO: use IF not %
+ read_ptr = (read_ptr + 1) % state->max_fifo_depth;
+ state->read_ptr = read_ptr;
+ state->timestamps[read_ptr] = timestamp;
+ } else {
+ state->reset = 1; // The rest must happen in the other thread
+ }
+}
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.dat b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.dat
new file mode 100644
index 0000000..fd2db00
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.dat
@@ -0,0 +1,145 @@
+ 5169,
+ 30344,
+ 92411,
+ 193562,
+ 296359,
+ 325691,
+ 212464,
+ -32886,
+ -281088,
+ -341418,
+ -112035,
+ 285533,
+ 533339,
+ 349745,
+ -224229,
+ -754969,
+ -713889,
+ 29781,
+ 954818,
+ 1207943,
+ 354407,
+ -1069372,
+ -1818145,
+ -983285,
+ 1015273,
+ 2503639,
+ 1899873,
+ -695136,
+ -3195220,
+ -3129965,
+ 335,
+ 3791335,
+ 4673522,
+ 1182741,
+ -4156430,
+ -6496184,
+ -2964398,
+ 4122422,
+ 8523843,
+ 5445729,
+ -3488536,
+ -10636309,
+ -8712433,
+ 2021617,
+ 12663339,
+ 12833767,
+ 549205,
+ -14379818,
+ -17869463,
+ -4551004,
+ 15495107,
+ 23889760,
+ 10412643,
+ -15628264,
+ -31023908,
+ -18775924,
+ 14241822,
+ 39569514,
+ 30769234,
+ -10463371,
+ -50268906,
+ -48765805,
+ 2543209,
+ 65155547,
+ 78974912,
+ 14229267,
+ -91131385,
+ -144396240,
+ -60382423,
+ 169204108,
+ 453172545,
+ 648273655,
+ 648273655,
+ 453172545,
+ 169204108,
+ -60382423,
+ -144396240,
+ -91131385,
+ 14229267,
+ 78974912,
+ 65155547,
+ 2543209,
+ -48765805,
+ -50268906,
+ -10463371,
+ 30769234,
+ 39569514,
+ 14241822,
+ -18775924,
+ -31023908,
+ -15628264,
+ 10412643,
+ 23889760,
+ 15495107,
+ -4551004,
+ -17869463,
+ -14379818,
+ 549205,
+ 12833767,
+ 12663339,
+ 2021617,
+ -8712433,
+ -10636309,
+ -3488536,
+ 5445729,
+ 8523843,
+ 4122422,
+ -2964398,
+ -6496184,
+ -4156430,
+ 1182741,
+ 4673522,
+ 3791335,
+ 335,
+ -3129965,
+ -3195220,
+ -695136,
+ 1899873,
+ 2503639,
+ 1015273,
+ -983285,
+ -1818145,
+ -1069372,
+ 354407,
+ 1207943,
+ 954818,
+ 29781,
+ -713889,
+ -754969,
+ -224229,
+ 349745,
+ 533339,
+ 285533,
+ -112035,
+ -341418,
+ -281088,
+ -32886,
+ 212464,
+ 325691,
+ 296359,
+ 193562,
+ 92411,
+ 30344,
+ 5169
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.sfp b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.sfp
new file mode 100644
index 0000000..807fe6f
Binary files /dev/null and b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_144.sfp differ
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.dat b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.dat
new file mode 100644
index 0000000..d61a8cc
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.dat
@@ -0,0 +1,145 @@
+ -2395,
+ -5393,
+ -335,
+ 30919,
+ 106000,
+ 220880,
+ 330830,
+ 356898,
+ 231633,
+ -34118,
+ -315114,
+ -418758,
+ -215874,
+ 223879,
+ 613143,
+ 611221,
+ 97230,
+ -651552,
+ -1069755,
+ -703606,
+ 360079,
+ 1408013,
+ 1539614,
+ 397969,
+ -1370661,
+ -2411112,
+ -1652446,
+ 690618,
+ 2986814,
+ 3260739,
+ 821767,
+ -2843947,
+ -4868873,
+ -3175486,
+ 1562920,
+ 5923006,
+ 6109316,
+ 1141587,
+ -5743394,
+ -9044604,
+ -5277235,
+ 3660474,
+ 11106677,
+ 10454985,
+ 809636,
+ -11221065,
+ -15824164,
+ -7781762,
+ 8274286,
+ 20081265,
+ 16848614,
+ -1306239,
+ -21547610,
+ -26990688,
+ -10324408,
+ 18264917,
+ 36552074,
+ 26888413,
+ -7970879,
+ -43212641,
+ -48496417,
+ -12420624,
+ 43678793,
+ 75992810,
+ 49227770,
+ -31884005,
+ -114708797,
+ -124890019,
+ -13609494,
+ 203956546,
+ 446378886,
+ 605431990,
+ 605431990,
+ 446378886,
+ 203956546,
+ -13609494,
+ -124890019,
+ -114708797,
+ -31884005,
+ 49227770,
+ 75992810,
+ 43678793,
+ -12420624,
+ -48496417,
+ -43212641,
+ -7970879,
+ 26888413,
+ 36552074,
+ 18264917,
+ -10324408,
+ -26990688,
+ -21547610,
+ -1306239,
+ 16848614,
+ 20081265,
+ 8274286,
+ -7781762,
+ -15824164,
+ -11221065,
+ 809636,
+ 10454985,
+ 11106677,
+ 3660474,
+ -5277235,
+ -9044604,
+ -5743394,
+ 1141587,
+ 6109316,
+ 5923006,
+ 1562920,
+ -3175486,
+ -4868873,
+ -2843947,
+ 821767,
+ 3260739,
+ 2986814,
+ 690618,
+ -1652446,
+ -2411112,
+ -1370661,
+ 397969,
+ 1539614,
+ 1408013,
+ 360079,
+ -703606,
+ -1069755,
+ -651552,
+ 97230,
+ 611221,
+ 613143,
+ 223879,
+ -215874,
+ -418758,
+ -315114,
+ -34118,
+ 231633,
+ 356898,
+ 330830,
+ 220880,
+ 106000,
+ 30919,
+ -335,
+ -5393,
+ -2395
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.sfp b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.sfp
new file mode 100644
index 0000000..e6ff458
Binary files /dev/null and b/lib_src/lib_src/src/fixed_factor_of_3/ds3/FilterData/firds3_b_144.sfp differ
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.c b/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.c
new file mode 100644
index 0000000..a91f456
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.c
@@ -0,0 +1,142 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// FIRDS3 functions implementation file
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+#include "src.h"
+#include "src_ff3_ds3.h"
+#include "src_ff3_fir_inner_loop_asm.h"
+
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+// State init value
+#define SRC_FF3_DS3_STATE_INIT 0
+
+
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+int src_ds3_coeffs[SRC_FF3_DS3_N_COEFS] = {
+ #include SRC_FF3_DS3_COEFS_FILE
+};
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+src_ff3_return_code_t src_ds3_init(src_ds3_ctrl_t* src_ds3_ctrl)
+{
+ // Check that delay line base has been set
+ if (src_ds3_ctrl->delay_base == 0) {
+ return SRC_FF3_ERROR;
+ }
+
+ // Setup from FIRDS2 descriptor
+ src_ds3_ctrl->delay_len = SRC_FF3_DS3_N_COEFS<<1; // Double length for circular buffer simulation
+ src_ds3_ctrl->delay_wrap = src_ds3_ctrl->delay_base + SRC_FF3_DS3_N_COEFS;
+ src_ds3_ctrl->delay_offset = SRC_FF3_DS3_N_COEFS;
+ src_ds3_ctrl->inner_loops = (SRC_FF3_DS3_N_COEFS>>1) / SRC_FF3_N_LOOPS_PER_ASM; // Right shift to 2 x 32bits read for coefs per inner loop
+ src_ds3_ctrl->num_coeffs = SRC_FF3_DS3_N_COEFS;
+ src_ds3_ctrl->coeffs = src_ds3_coeffs;
+
+ // Sync the FIRDS3
+ if (src_ds3_sync(src_ds3_ctrl) != SRC_FF3_NO_ERROR) {
+ return SRC_FF3_ERROR;
+ }
+
+ return SRC_FF3_NO_ERROR;
+}
+
+src_ff3_return_code_t src_ds3_sync(src_ds3_ctrl_t* src_ds3_ctrl)
+{
+ // Set delay line index back to base
+ src_ds3_ctrl->delay_pos = src_ds3_ctrl->delay_base;
+
+ // Clear delay line
+ for (unsigned int ui = 0; ui < src_ds3_ctrl->delay_len; ui++) {
+ src_ds3_ctrl->delay_base[ui] = SRC_FF3_DS3_STATE_INIT;
+ }
+
+ return SRC_FF3_NO_ERROR;
+}
+
+src_ff3_return_code_t src_ds3_proc(src_ds3_ctrl_t* src_ds3_ctrl)
+{
+ int* data;
+ int* coeffs;
+ int data0;
+ __int64_t accumulator;
+
+ // Get three new data samples to delay line (double write for circular buffer simulation)
+ data0 = *src_ds3_ctrl->in_data;
+ *src_ds3_ctrl->delay_pos = data0;
+ *(src_ds3_ctrl->delay_pos + src_ds3_ctrl->delay_offset) = data0;
+
+ data0 = *(src_ds3_ctrl->in_data + 1);
+ *(src_ds3_ctrl->delay_pos + 1) = data0;
+ *(src_ds3_ctrl->delay_pos + src_ds3_ctrl->delay_offset + 1) = data0;
+
+ data0 = *(src_ds3_ctrl->in_data + 2);
+ *(src_ds3_ctrl->delay_pos + 2) = data0;
+ *(src_ds3_ctrl->delay_pos + src_ds3_ctrl->delay_offset + 2) = data0;
+
+ // Step delay with circular simulation (will also rewrite to control structure for next round)
+ // Note as delay line length is a multiple of 3 (because filter coefficients length is a multiple of 3)
+ // we only have to do the wrap around check after having written 3 input samples
+ src_ds3_ctrl->delay_pos += 3;
+ if (src_ds3_ctrl->delay_pos >= src_ds3_ctrl->delay_wrap) {
+ src_ds3_ctrl->delay_pos = src_ds3_ctrl->delay_base;
+ }
+
+ // Clear accumulator and set access pointers
+ data = src_ds3_ctrl->delay_pos;
+ coeffs = src_ds3_ctrl->coeffs;
+ accumulator = 0;
+ if ((unsigned)data & 0b0100) {
+ src_ff3_fir_inner_loop_asm_odd(data, coeffs, &data0, src_ds3_ctrl->inner_loops);
+ } else {
+ src_ff3_fir_inner_loop_asm(data, coeffs, &data0, src_ds3_ctrl->inner_loops);
+ }
+
+ *src_ds3_ctrl->out_data = data0;
+
+ return SRC_FF3_NO_ERROR;
+}
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.h b/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.h
new file mode 100644
index 0000000..55340d2
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/ds3/src_ff3_ds3.h
@@ -0,0 +1,22 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_FF3_DS3_H_
+#define _SRC_FF3_DS3_H_
+
+#ifdef __XC__
+extern "C" {
+#endif
+
+#define SRC_FF3_DS3_N_COEFS 144 // Number of coefficients must be a multiple of 6
+
+/* Filters with "_b_" in their filenames have higher attenuation at
+ * Nyquist (> 60dB compared with 20dB ) but with an earlier cutoff.
+ */
+#define SRC_FF3_DS3_COEFS_FILE "FilterData/firds3_b_144.dat"
+//#define SRC_FF3_DS3_COEFS_FILE "FilterData/firds3_144.dat"
+
+#ifdef __XC__
+}
+#endif
+
+#endif // _SRC_FF3_DS3_H_
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.dat b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.dat
new file mode 100644
index 0000000..96a62d0
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.dat
@@ -0,0 +1,145 @@
+ 277234,
+ 977073,
+-843263,
+ 856598,
+-672686,
+ 89343,
+ 1063222,
+-2949854,
+ 5699618,
+-9389894,
+ 14020565,
+-19488553,
+ 25571530,
+-31908927,
+ 37990018,
+-43139454,
+ 46485321,
+-46884792,
+ 42725465,
+-31390114,
+ 7629628,
+ 42687800,
+-181147269,
+ 1944820965,
+ 507612325,
+-273394154,
+ 195466641,
+-150806718,
+ 118708541,
+-93071724,
+ 71669280,
+-53608390,
+ 38501300,
+-26137299,
+ 16337186,
+-8893195,
+ 3548222,
+ 1006,
+-2085407,
+ 3045819,
+-3208116,
+ 2864453,
+-2264906,
+ 1600018,
+-1024255,
+ 637393,
+ 580686,
+ 15508,
+ 91031,
+ 889077,
+-98659,
+-336105,
+ 1049234,
+-2141667,
+ 3623829,
+-5454434,
+ 7510918,
+-9585659,
+ 11374005,
+-12469289,
+ 12367266,
+-10465607,
+ 6064852,
+ 1647616,
+-13653011,
+ 31237928,
+-56327772,
+ 92307702,
+-146297414,
+ 236924736,
+-433188720,
+ 1359517635,
+ 1359517635,
+-433188720,
+ 236924736,
+-146297414,
+ 92307702,
+-56327772,
+ 31237928,
+-13653011,
+ 1647616,
+ 6064852,
+-10465607,
+ 12367266,
+-12469289,
+ 11374005,
+-9585659,
+ 7510918,
+-5454434,
+ 3623829,
+-2141667,
+ 1049234,
+-336105,
+-98659,
+ 889077,
+ 91031,
+ 15508,
+ 580686,
+ 637393,
+-1024255,
+ 1600018,
+-2264906,
+ 2864453,
+-3208116,
+ 3045819,
+-2085407,
+ 1006,
+ 3548222,
+-8893195,
+ 16337186,
+-26137299,
+ 38501300,
+-53608390,
+ 71669280,
+-93071724,
+ 118708541,
+-150806718,
+ 195466641,
+-273394154,
+ 507612325,
+ 1944820965,
+-181147269,
+ 42687800,
+ 7629628,
+-31390114,
+ 42725465,
+-46884792,
+ 46485321,
+-43139454,
+ 37990018,
+-31908927,
+ 25571530,
+-19488553,
+ 14020565,
+-9389894,
+ 5699618,
+-2949854,
+ 1063222,
+ 89343,
+-672686,
+ 856598,
+-843263,
+ 977073,
+ 277234
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.sfp b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.sfp
new file mode 100644
index 0000000..6f5df30
Binary files /dev/null and b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_144.sfp differ
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.dat b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.dat
new file mode 100644
index 0000000..ff34529
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.dat
@@ -0,0 +1,144 @@
+-1004,
+ 662641,
+ 694900,
+-1256274,
+ 1839429,
+-1954657,
+ 1080237,
+ 1193906,
+-4957339,
+ 9782217,
+-14606619,
+ 17769018,
+-17230183,
+ 10981423,
+ 2428909,
+-23345286,
+ 50545842,
+-80972064,
+ 109656222,
+-129637924,
+ 131036378,
+-95652015,
+-40828481,
+ 1816295970,
+ 611869637,
+-344126390,
+ 227978430,
+-145489250,
+ 80665240,
+-30973225,
+-3918718,
+ 24822859,
+-33663194,
+ 33320030,
+-27133813,
+ 18327949,
+-9526458,
+ 2465302,
+ 2071853,
+-4111983,
+ 4224039,
+-3209264,
+ 1833664,
+-647622,
+-102355,
+ 992489,
+ 92757,
+-7186,
+-16178,
+ 317999,
+ 1070693,
+-945343,
+ 671637,
+ 291690,
+-2110817,
+ 4618841,
+-7233336,
+ 8960442,
+-8531840,
+ 4688761,
+ 3424760,
+-15831706,
+ 31364955,
+-47472492,
+ 60243796,
+-64642830,
+ 54794752,
+-23912637,
+-37261872,
+ 147683310,
+-374670058,
+ 1339136657,
+ 1339136657,
+-374670058,
+ 147683310,
+-37261872,
+-23912637,
+ 54794752,
+-64642830,
+ 60243796,
+-47472492,
+ 31364955,
+-15831706,
+ 3424760,
+ 4688761,
+-8531840,
+ 8960442,
+-7233336,
+ 4618841,
+-2110817,
+ 291690,
+ 671637,
+-945343,
+ 1070693,
+ 317999,
+-16178,
+-7186,
+ 92757,
+ 992489,
+-102355,
+-647622,
+ 1833664,
+-3209264,
+ 4224039,
+-4111983,
+ 2071853,
+ 2465302,
+-9526458,
+ 18327949,
+-27133813,
+ 33320030,
+-33663194,
+ 24822859,
+-3918718,
+-30973225,
+ 80665240,
+-145489250,
+ 227978430,
+-344126390,
+ 611869637,
+ 1816295970,
+-40828481,
+-95652015,
+ 131036378,
+-129637924,
+ 109656222,
+-80972064,
+ 50545842,
+-23345286,
+ 2428909,
+ 10981423,
+-17230183,
+ 17769018,
+-14606619,
+ 9782217,
+-4957339,
+ 1193906,
+ 1080237,
+-1954657,
+ 1839429,
+-1256274,
+ 694900,
+ 662641,
+-1004
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.sfp b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.sfp
new file mode 100644
index 0000000..d8e5e87
Binary files /dev/null and b/lib_src/lib_src/src/fixed_factor_of_3/os3/FilterData/firos3_b_144.sfp differ
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.c b/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.c
new file mode 100644
index 0000000..c88dae5
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.c
@@ -0,0 +1,135 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// FIROS3 functions implementation file
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+#include "src.h"
+#include "src_ff3_os3.h"
+#include "src_ff3_fir_inner_loop_asm.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+// State init value
+#define SRC_OS3_STATE_INIT 0
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+int src_os3_coeffs[SRC_FF3_OS3_N_COEFS] = {
+ #include SRC_FF3_OS3_COEFS_FILE
+};
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+src_ff3_return_code_t src_os3_init(src_os3_ctrl_t* src_os3_ctrl)
+{
+ // Check that delay line base has been set
+ if (src_os3_ctrl->delay_base == 0) {
+ return SRC_FF3_ERROR;
+ }
+
+ // Setup from FIROS2 descriptor
+ src_os3_ctrl->delay_len = (SRC_FF3_OS3_N_COEFS/SRC_FF3_OS3_N_PHASES)<<1; // Double length for circular buffer simulation. x3 over-sampler, so only 1/3rd of coefs length needed
+ src_os3_ctrl->delay_wrap = src_os3_ctrl->delay_base + (SRC_FF3_OS3_N_COEFS/SRC_FF3_OS3_N_PHASES);
+ src_os3_ctrl->delay_offset = (SRC_FF3_OS3_N_COEFS/SRC_FF3_OS3_N_PHASES);
+ src_os3_ctrl->inner_loops = ((SRC_FF3_OS3_N_COEFS/SRC_FF3_OS3_N_PHASES)>>1) / SRC_FF3_N_LOOPS_PER_ASM; // Right shift due to 2 x 32bits read for coefs per inner loop and x3 over-sampler, so only 1/3rd of coefs length needed
+ src_os3_ctrl->num_coeffs = SRC_FF3_OS3_N_COEFS;
+ src_os3_ctrl->coeffs = src_os3_coeffs;
+
+ // Sync the FIROS3
+ if (src_os3_sync(src_os3_ctrl) != SRC_FF3_NO_ERROR) {
+ return SRC_FF3_ERROR;
+ }
+
+ return SRC_FF3_NO_ERROR;
+}
+
+src_ff3_return_code_t src_os3_sync(src_os3_ctrl_t* src_os3_ctrl)
+{
+ // Set delay line index back to base
+ src_os3_ctrl->delay_pos = src_os3_ctrl->delay_base;
+
+ // Clear delay line
+ for (unsigned int ui = 0; ui < src_os3_ctrl->delay_len; ui++) {
+ src_os3_ctrl->delay_base[ui] = SRC_OS3_STATE_INIT;
+ }
+
+ // Set phase to '0' to indicate that a new input sample is needed
+ src_os3_ctrl->phase = 0;
+
+ return SRC_FF3_NO_ERROR;
+}
+
+src_ff3_return_code_t src_os3_input(src_os3_ctrl_t* src_os3_ctrl)
+{
+ // Write new input sample from control structure to delay line
+ // at both positions for circular buffer simulation
+ *src_os3_ctrl->delay_pos = src_os3_ctrl->in_data;
+ *(src_os3_ctrl->delay_pos + src_os3_ctrl->delay_offset) = src_os3_ctrl->in_data;
+
+ // Step delay index with circular buffer simulation
+ src_os3_ctrl->delay_pos += 1;
+ if (src_os3_ctrl->delay_pos >= src_os3_ctrl->delay_wrap) {
+ src_os3_ctrl->delay_pos = src_os3_ctrl->delay_base;
+ }
+
+ return SRC_FF3_NO_ERROR;
+}
+
+src_ff3_return_code_t src_os3_proc(src_os3_ctrl_t* src_os3_ctrl)
+{
+ int* data;
+ int* coeffs;
+ int data0;
+ __int64_t accumulator;
+
+ // Clear accumulator and set data/coefs access pointers
+ data = src_os3_ctrl->delay_pos;
+ coeffs = src_os3_ctrl->coeffs + src_os3_ctrl->phase;
+ accumulator = 0;
+
+ if ((unsigned)data & 0b0100) {
+ src_ff3_fir_inner_loop_asm_odd(data, coeffs, &data0, src_os3_ctrl->inner_loops);
+ } else {
+ src_ff3_fir_inner_loop_asm(data, coeffs, &data0, src_os3_ctrl->inner_loops);
+ }
+
+ // Write output
+ src_os3_ctrl->out_data = data0;
+
+ // Step phase
+ src_os3_ctrl->phase += (SRC_FF3_OS3_N_COEFS/SRC_FF3_OS3_N_PHASES);
+ if (src_os3_ctrl->phase == SRC_FF3_OS3_N_COEFS) {
+ src_os3_ctrl->phase = 0;
+ }
+
+ return SRC_FF3_NO_ERROR;
+}
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.h b/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.h
new file mode 100644
index 0000000..b891879
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/os3/src_ff3_os3.h
@@ -0,0 +1,23 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_FF3_OS3_H_
+#define _SRC_FF3_OS3_H_
+
+#ifdef __XC__
+extern "C" {
+#endif
+
+#define SRC_FF3_OS3_N_COEFS 144 // Number of coefficients must be a multiple of 6
+#define SRC_FF3_OS3_N_PHASES 3 // Number of output phases (3 as OS3 over-sample by 3)
+
+/* Filters with "_b_" in their filenames have higher attenuation at
+ * 8kHz (> 60dB compared with 20dB ) but with an earlier cutoff.
+ */
+// #define SRC_FF3_OS3_COEFS_FILE "FilterData/firos3_b_144.dat"
+#define SRC_FF3_OS3_COEFS_FILE "FilterData/firos3_144.dat"
+
+#ifdef __XC__
+}
+#endif
+
+#endif // _SRC_FF3_OS3_H_
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.S b/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.S
new file mode 100644
index 0000000..8bf06ec
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.S
@@ -0,0 +1,290 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_ff3_fir_inner_loop_asm.function
+ .globl src_ff3_fir_inner_loop_asm
+ .align 8
+ .type src_ff3_fir_inner_loop_asm,@function
+
+src_ff3_fir_inner_loop_asm:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ stw iDataRet_p, sp[6]
+ //Constant for adding onto stuff. Gets updated later
+ ldc step, 0x60
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+
+ bf counter, done
+main_loop:
+ sub counter, counter, 1
+
+ ldd iData0, iData1, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[1]
+ ldd iCoef0, iCoef1, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[2]
+ ldd iCoef0, iCoef1, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[3]
+ ldd iCoef0, iCoef1, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[4]
+ ldd iCoef0, iCoef1, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[5]
+ ldd iCoef0, iCoef1, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[6]
+ ldd iCoef0, iCoef1, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[7]
+ ldd iCoef0, iCoef1, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[8]
+ ldd iCoef0, iCoef1, piCoefs_p[8]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[9]
+ ldd iCoef0, iCoef1, piCoefs_p[9]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[10]
+ ldd iCoef0, iCoef1, piCoefs_p[10]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[11]
+ ldd iCoef0, iCoef1, piCoefs_p[11]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ //Decrement loop counter and increment pointers and branch if still running
+ {add piData_p, piData_p, step; add piCoefs_p, piCoefs_p, step}
+
+ bt counter, main_loop
+
+done:
+ //pop return value pointer from stack so we can use it to write back
+ //Write back the two return values
+ {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3)
+
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp:
+ .size src_ff3_fir_inner_loop_asm, .atmp-src_ff3_fir_inner_loop_asm
+ .align 8
+ .cc_bottom src_ff3_fir_inner_loop_asm.function
+
+ .set src_ff3_fir_inner_loop_asm.nstackwords, stack_size
+ .globl src_ff3_fir_inner_loop_asm.nstackwords
+ .set src_ff3_fir_inner_loop_asm.maxcores, 1
+ .globl src_ff3_fir_inner_loop_asm.maxcores
+ .set src_ff3_fir_inner_loop_asm.maxtimers,0
+ .globl src_ff3_fir_inner_loop_asm.maxtimers
+ .set src_ff3_fir_inner_loop_asm.maxchanends,0
+ .globl src_ff3_fir_inner_loop_asm.maxchanends
+
+
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_ff3_fir_inner_loop_asm_odd.function
+ .globl src_ff3_fir_inner_loop_asm_odd
+ .align 8
+ .type src_ff3_fir_inner_loop_asm_odd,@function
+
+src_ff3_fir_inner_loop_asm_odd:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ stw iDataRet_p, sp[6]
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+ ldc step, 0x60
+ bf counter, done
+main_loop_odd:
+
+ {sub counter, counter, 1; sub step, step, 8} //Sub gets loaded with 0x60 at end of loop
+ //We actually want 0x58 so this is good
+
+ //Constant for adding onto stuff. Gets updated later
+
+ {ldw iData0, piData_p[0]; add piData_p, piData_p, 4} //Now 64b aligned
+
+ ldd iCoef1, iCoef0, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[0]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[1]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[2]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[3]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[4]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[5]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[6]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[7]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[8]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[8]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[9]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[9]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[10]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[10]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[11]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+
+ add piData_p, piData_p, step
+
+ {ldw iData1, piData_p[0]; add piData_p, piData_p, 4} //0x4 + 0x58 + 0x4 = 0x60)
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ //Increment pointers and branch if still running
+ ldc step, 0x60
+ {bt counter, main_loop_odd; add piCoefs_p, piCoefs_p, step}
+
+done_odd:
+ //pop return value pointer from stack so we can use it to write back
+ {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3)
+
+ //Write back the return value
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp_odd:
+ .size src_ff3_fir_inner_loop_asm_odd, .atmp-src_ff3_fir_inner_loop_asm_odd
+ .align 8
+ .cc_bottom src_ff3_fir_inner_loop_asm_odd.function
+
+ .set src_ff3_fir_inner_loop_asm_odd.nstackwords, stack_size
+ .globl src_ff3_fir_inner_loop_asm_odd.nstackwords
+ .set src_ff3_fir_inner_loop_asm_odd.maxcores, 1
+ .globl src_ff3_fir_inner_loop_asm_odd.maxcores
+ .set src_ff3_fir_inner_loop_asm_odd.maxtimers,0
+ .globl src_ff3_fir_inner_loop_asm_odd.maxtimers
+ .set src_ff3_fir_inner_loop_asm_odd.maxchanends,0
+ .globl src_ff3_fir_inner_loop_asm_odd.maxchanends
diff --git a/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.h b/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.h
new file mode 100644
index 0000000..de9ae84
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3/src_ff3_fir_inner_loop_asm.h
@@ -0,0 +1,12 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_FF3_FIR_INNER_LOOP_ASM_H_
+#define _SRC_FF3_FIR_INNER_LOOP_ASM_H_
+
+#define SRC_FF3_N_LOOPS_PER_ASM 12
+
+void src_ff3_fir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count);
+void src_ff3_fir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count);
+
+
+#endif // _SRC_FF3_FIR_INNER_LOOP_ASM_H_
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/ds3_voice/src_ff3v_ds3_voice.S b/lib_src/lib_src/src/fixed_factor_of_3_voice/ds3_voice/src_ff3v_ds3_voice.S
new file mode 100644
index 0000000..b618f23
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/ds3_voice/src_ff3v_ds3_voice.S
@@ -0,0 +1,94 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+.section .dp.data,"awd",@progbits
+.text
+
+#define STACKWORDS 4
+
+#define c0 r4
+#define c1 r5
+#define d0 r6
+
+#define s r11
+
+.cc_top src_ds3_voice_add_sample.function
+.globl src_ds3_voice_add_sample
+.align 4
+.type src_ds3_voice_add_sample,@function
+src_ds3_voice_add_sample://(int64_t sum, int32_t data[], int32_t coefs[], int32_t sample);
+
+.issue_mode dual
+ DUALENTSP_lu6 STACKWORDS
+
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+
+ ldw s, sp[STACKWORDS+1]
+
+ bl src_ff3v_fir_impl
+
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ retsp STACKWORDS
+
+.src_ds3_voice_add_sample_tmp:
+ .size src_ds3_voice_add_sample, .src_ds3_voice_add_sample_tmp-src_ds3_voice_add_sample
+ .align 4
+ .cc_bottom src_ds3_voice_add_sample.function
+
+ .set src_ds3_voice_add_sample.nstackwords, STACKWORDS
+ .globl src_ds3_voice_add_sample.nstackwords
+ .set src_ds3_voice_add_sample.maxcores,1
+ .globl src_ds3_voice_add_sample.maxcores
+ .set src_ds3_voice_add_sample.maxtimers,0
+ .globl src_ds3_voice_add_sample.maxtimers
+ .set src_ds3_voice_add_sample.maxchanends,0
+ .globl src_ds3_voice_add_sample.maxchanends
+
+.cc_top src_ds3_voice_add_final_sample.function
+.globl src_ds3_voice_add_final_sample
+.align 4
+.type src_ds3_voice_add_final_sample,@function
+src_ds3_voice_add_final_sample://(int64_t sum, int32_t data[], int32_t coefs[], int32_t sample);
+
+.issue_mode dual
+ DUALENTSP_lu6 STACKWORDS
+
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+
+ ldw s, sp[STACKWORDS+1]
+
+ bl src_ff3v_fir_impl
+
+ {ldc d0, 31; nop}
+ lextract r0, r1, r0, d0, 32
+
+ ldaw s, cp[src_ff3v_fir_comp_ds]
+ ldw s, s[0]
+ {ldc c0, 0; ldc c1, 0}
+ maccs c0, c1, r0, s
+
+ ldaw s, cp[src_ff3v_fir_comp_q_ds]
+ ldw s, s[0]
+
+ lsats c0, c1, s
+ lextract r0, c0, c1, s, 32
+
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ {retsp STACKWORDS; ldc r1, 0}
+
+.src_ds3_voice_add_final_sample_tmp:
+ .size src_ds3_voice_add_final_sample, .src_ds3_voice_add_final_sample_tmp-src_ds3_voice_add_final_sample
+ .align 4
+ .cc_bottom src_ds3_voice_add_final_sample.function
+
+ .set src_ds3_voice_add_final_sample.nstackwords, STACKWORDS
+ .globl src_ds3_voice_add_final_sample.nstackwords
+ .set src_ds3_voice_add_final_sample.maxcores,1
+ .globl src_ds3_voice_add_final_sample.maxcores
+ .set src_ds3_voice_add_final_sample.maxtimers,0
+ .globl src_ds3_voice_add_final_sample.maxtimers
+ .set src_ds3_voice_add_final_sample.maxchanends,0
+ .globl src_ds3_voice_add_final_sample.maxchanends
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.S b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.S
new file mode 100644
index 0000000..8df83f6
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.S
@@ -0,0 +1,63 @@
+// Copyright 2017-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+.section .dp.data,"awd",@progbits
+.text
+
+#define sum_l r0
+#define sum_h r1
+#define data r2
+#define coefs r3
+
+#define c0 r4
+#define c1 r5
+#define d0 r6
+#define d1 r7
+
+#define s r11
+
+#define EVEN_STEP(N) \
+ ldd c1, c0, coefs[N];\
+ maccs sum_h, sum_l, c0, s;\
+ ldd d1, d0, data[N];\
+ maccs sum_h, sum_l, c1, d0;\
+ std d0, s, data[N];
+
+#define ODD_STEP(N) \
+ ldd c1, c0, coefs[N];\
+ maccs sum_h, sum_l, c0, d1;\
+ ldd s, d0, data[N];\
+ maccs sum_h, sum_l, c1, d0;\
+ std d0, d1, data[N];
+
+.cc_top src_ff3v_fir_impl.function
+.globl src_ff3v_fir_impl
+.align 8
+.type src_ff3v_fir_impl,@function
+.issue_mode dual
+src_ff3v_fir_impl:
+ EVEN_STEP(0);
+ ODD_STEP(1);
+ EVEN_STEP(2);
+ ODD_STEP(3);
+ EVEN_STEP(4);
+ ODD_STEP(5);
+ EVEN_STEP(6);
+ ODD_STEP(7);
+ EVEN_STEP(8);
+ ODD_STEP(9);
+ EVEN_STEP(10);
+ ODD_STEP(11);
+ {retsp 0; nop}
+.src_ff3v_fir_impl_tmp:
+ .size src_ff3v_fir_impl, .src_ff3v_fir_impl_tmp-src_ff3v_fir_impl
+ .align 4
+ .cc_bottom src_ff3v_fir_impl.function
+
+ .set src_ff3v_fir_impl.nstackwords, 0
+ .globl src_ff3v_fir_impl.nstackwords
+ .set src_ff3v_fir_impl.maxcores,1
+ .globl src_ff3v_fir_impl.maxcores
+ .set src_ff3v_fir_impl.maxtimers,0
+ .globl src_ff3v_fir_impl.maxtimers
+ .set src_ff3v_fir_impl.maxchanends,0
+ .globl src_ff3v_fir_impl.maxchanends
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.h b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.h
new file mode 100644
index 0000000..3ad213e
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.h
@@ -0,0 +1,33 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+//
+// This file is generated using src_ff3v_fir_generator.py
+//
+// Do not modify it directly, changes may be overwritten!
+//
+
+#ifndef _SRC_FF3V_FIR_H_
+#define _SRC_FF3V_FIR_H_
+
+#include
+
+#define SRC_FF3V_FIR_NUM_PHASES (3)
+#define SRC_FF3V_FIR_TAPS_PER_PHASE (24)
+
+extern const unsigned src_ff3v_fir_comp_q_ds;
+extern const int32_t src_ff3v_fir_comp_ds;
+
+extern const unsigned src_ff3v_fir_comp_q_us;
+extern const int32_t src_ff3v_fir_comp_us;
+
+extern int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE];
+
+#if defined(__XC__)
+extern const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE];
+#define src_ff3v_fir_coefs src_ff3v_fir_coefs_xc
+#else
+extern const int32_t (*src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE];
+#define src_ff3v_fir_coefs src_ff3v_fir_coefs_c
+#endif
+
+#endif // _SRC_FF3V_FIR_H_
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.xc b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.xc
new file mode 100644
index 0000000..99a1f64
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir.xc
@@ -0,0 +1,67 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+//
+// This file is generated using src_ff3v_fir_generator.py
+//
+// Do not modify it directly, changes may be overwritten!
+//
+
+#include "src_ff3v_fir.h"
+#include
+
+/** Used for FIR compensation for decimation*/
+const unsigned src_ff3v_fir_comp_q_ds = 29;
+
+/** Used for FIR compensation for decimation*/
+const int32_t src_ff3v_fir_comp_ds = 1112549167;
+
+/** Used for FIR compensation for upsampling*/
+const unsigned src_ff3v_fir_comp_q_us = 27;
+
+/** Used for FIR compensation for upsampling*/
+const int32_t src_ff3v_fir_comp_us = 834411870;
+
+/** Used for self testing src_ds3_voice and src_us3_voice functionality */
+int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE] = {
+ 1005142, 1367390, 29412, -4146838, -10154637, -14619962,
+ -13776186, -6744830, 2692812, 8121360, 5508436, -2814524,
+ -9285443, -7351357, 2193307, 10930750, 9953155, -1338213,
+ -13227624, -13683020, -123797, 16201217, 19008511, 2582573,
+ -20205295, -27041699, -6837031, 26249516, 40760231, 15085431,
+ -37763299, -71330011, -37235961, 74585089, 219245690, 320542055,
+ 320542055, 219245690, 74585089, -37235961, -71330011, -37763299,
+ 15085431, 40760231, 26249516, -6837031, -27041699, -20205295,
+ 2582573, 19008511, 16201217, -123797, -13683020, -13227624,
+ -1338213, 9953155, 10930750, 2193307, -7351357, -9285443,
+ -2814524, 5508436, 8121360, 2692812, -6744830, -13776186,
+ -14619962, -10154637, -4146838, 29412, 1367390, 1005142,
+
+};
+
+/** Coefficients for use with src_ds3_voice and src_us3_voice functions */
+static const int32_t [[aligned(8)]] src_ff3v_fir_coefs_i[SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE] = {
+ {
+ 29412, -14619962, 2692812, -2814524, 2193307, -1338213,
+ -123797, 2582573, -6837031, 15085431, -37235961, 320542055,
+ 74585089, -37763299, 26249516, -20205295, 16201217, -13227624,
+ 10930750, -9285443, 8121360, -13776186, -4146838, 1005142,
+ },
+ {
+ 1367390, -10154637, -6744830, 5508436, -7351357, 9953155,
+ -13683020, 19008511, -27041699, 40760231, -71330011, 219245690,
+ 219245690, -71330011, 40760231, -27041699, 19008511, -13683020,
+ 9953155, -7351357, 5508436, -6744830, -10154637, 1367390,
+ },
+ {
+ 1005142, -4146838, -13776186, 8121360, -9285443, 10930750,
+ -13227624, 16201217, -20205295, 26249516, -37763299, 74585089,
+ 320542055, -37235961, 15085431, -6837031, 2582573, -123797,
+ -1338213, 2193307, -2814524, 2692812, -14619962, 29412,
+ },
+};
+
+unsafe {
+ const int32_t (* unsafe src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i;
+}
+
+const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i;
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir_generator.py b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir_generator.py
new file mode 100644
index 0000000..885bd41
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/src_ff3v_fir_generator.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+# Copyright 2016-2021 XMOS LIMITED.
+# This Software is subject to the terms of the XMOS Public Licence: Version 1.
+import os.path
+import numpy as np
+from scipy import signal
+import matplotlib.pyplot as plt
+
+
+def plot_response(fs, w, h, title):
+ plt.figure()
+ plt.plot(0.5*fs*w/np.pi, 20*np.log10(np.abs(h)))
+
+ plt.xlim(0, 0.5*fs)
+ plt.grid(True)
+ plt.xlabel('Frequency (Hz)')
+ plt.ylabel('Gain (dB)')
+ plt.title(title)
+ plt.show()
+
+def plot_response_passband(fs, w, h, title):
+ plt.figure()
+ plt.plot(0.5*fs*w/np.pi, 20*np.log10(np.abs(h)))
+ plt.ylim(-1, 1)
+ plt.xlim(0, 0.25*fs)
+ plt.grid(True)
+ plt.xlabel('Frequency (Hz)')
+ plt.ylabel('Gain (dB)')
+ plt.title(title)
+ plt.show()
+
+def generate_header_file(num_taps_per_phase, num_phases):
+ header_template = """\
+// Copyright (c) 2016-2021, XMOS Ltd, All rights reserved
+//
+// This file is generated using src_ff3v_fir_generator.py
+//
+// Do not modify it directly, changes may be overwritten!
+//
+
+#ifndef _SRC_FF3V_FIR_H_
+#define _SRC_FF3V_FIR_H_
+
+#include
+
+#define SRC_FF3V_FIR_NUM_PHASES (%(phases)s)
+#define SRC_FF3V_FIR_TAPS_PER_PHASE (%(taps_per_phase)s)
+
+extern const unsigned src_ff3v_fir_comp_q_ds;
+extern const int32_t src_ff3v_fir_comp_ds;
+
+extern const unsigned src_ff3v_fir_comp_q_us;
+extern const int32_t src_ff3v_fir_comp_us;
+
+extern int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE];
+
+#if defined(__XC__)
+extern const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE];
+#define src_ff3v_fir_coefs src_ff3v_fir_coefs_xc
+#else
+extern const int32_t (*src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE];
+#define src_ff3v_fir_coefs src_ff3v_fir_coefs_c
+#endif
+
+#endif // _SRC_FF3V_FIR_H_
+"""
+
+ header_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ 'src_ff3v_fir.h')
+ with open(header_path, "w") as header_file:
+ header_file.writelines(header_template % {'taps_per_phase':num_taps_per_phase,
+ 'phases':num_phases})
+
+def generate_xc_file(q_ds, q_us, comp_ds, comp_us, taps):
+ xc_template = """\
+// Copyright (c) 2016-2021, XMOS Ltd, All rights reserved
+//
+// This file is generated using src_ff3v_fir_generator.py
+//
+// Do not modify it directly, changes may be overwritten!
+//
+
+#include "src_ff3v_fir.h"
+#include
+
+/** Used for FIR compensation for decimation*/
+const unsigned src_ff3v_fir_comp_q_ds = %(comp_q_ds)s;
+
+/** Used for FIR compensation for decimation*/
+const int32_t src_ff3v_fir_comp_ds = %(comp_ds)s;
+
+/** Used for FIR compensation for upsampling*/
+const unsigned src_ff3v_fir_comp_q_us = %(comp_q_us)s;
+
+/** Used for FIR compensation for upsampling*/
+const int32_t src_ff3v_fir_comp_us = %(comp_us)s;
+
+/** Used for self testing src_ds3_voice and src_us3_voice functionality */
+int32_t src_ff3v_fir_coefs_debug[SRC_FF3V_FIR_NUM_PHASES * SRC_FF3V_FIR_TAPS_PER_PHASE] = {
+%(coefs_debug)s
+};
+
+/** Coefficients for use with src_ds3_voice and src_us3_voice functions */
+static const int32_t [[aligned(8)]] src_ff3v_fir_coefs_i[SRC_FF3V_FIR_NUM_PHASES][SRC_FF3V_FIR_TAPS_PER_PHASE] = {
+%(coefs)s};
+
+unsafe {
+ const int32_t (* unsafe src_ff3v_fir_coefs_c)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i;
+}
+
+const int32_t (*src_ff3v_fir_coefs_xc)[SRC_FF3V_FIR_TAPS_PER_PHASE] = src_ff3v_fir_coefs_i;
+"""
+
+ coefs_debug = ''
+ i = 1
+ for c in taps:
+ coefs_debug += (' ' + str(int(c*(2**31 - 1))).rjust(12) + ',')
+ if ((i % 6) == 0):
+ coefs_debug += '\n'
+ i+=1
+
+ coefs = ''
+
+ for step in range(num_phases-1, -1, -1):
+ i = 1
+ coefs += ' {\n '
+ for j in range(step, len(taps), num_phases):
+ coefs += ' ' + str(int(taps[j]*(2**31 - 1))).rjust(12) + ','
+ if ((i % 6) == 0):
+ coefs += '\n '
+ i+=1
+ coefs += '},\n'
+
+ xc_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),
+ 'src_ff3v_fir.xc')
+ with open(xc_path, "w") as xc_file:
+
+ xc_file.writelines(xc_template % {'comp_q_ds':str(q_ds),
+ 'comp_ds':str(comp_ds),
+ 'comp_q_us':str(q_us),
+ 'comp_us':str(comp_us),
+ 'coefs_debug':coefs_debug,
+ 'coefs':coefs})
+
+# Low-pass filter design parameters
+fs = 48000.0 # Sample rate, Hz
+num_phases = 3
+num_taps_per_phase = 2*12
+
+taps = signal.remez((num_phases*num_taps_per_phase), [0, 7300, 8700, 0.5*fs], [1, 0], [.008, 1], Hz=fs)
+w, h = signal.freqz(taps)
+
+pass_band_atten = sum(abs(taps))
+upsampling_atten = num_phases
+taps = taps / pass_band_atten # Guarantee no overflow
+
+# generate the compensation factors
+q_ds = 30 - int(np.log2(pass_band_atten) + 0.5)
+q_us = 30 - int(np.log2(pass_band_atten * upsampling_atten) + 0.5)
+comp_ds = int(((2**q_ds)-1) * pass_band_atten)
+comp_us = int(((2**q_us)-1) * pass_band_atten * upsampling_atten)
+
+if __name__ == "__main__":
+ # plot_response(fs, w, h, "Low-pass Filter")
+ # plot_response_passband(fs, w, h, "Low-pass Filter")
+ generate_header_file(num_taps_per_phase, num_phases)
+ generate_xc_file(q_ds, q_us, comp_ds, comp_us, taps)
+
diff --git a/lib_src/lib_src/src/fixed_factor_of_3_voice/us3_voice/src_ff3v_us3_voice.S b/lib_src/lib_src/src/fixed_factor_of_3_voice/us3_voice/src_ff3v_us3_voice.S
new file mode 100644
index 0000000..46506e6
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_of_3_voice/us3_voice/src_ff3v_us3_voice.S
@@ -0,0 +1,137 @@
+// Copyright 2017-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+#define STACKWORDS 4
+
+#define sum_l r0
+#define sum_h r1
+#define data r2
+#define coefs r3
+
+#define c0 r4
+#define c1 r5
+#define d0 r6
+#define d1 r7
+
+#define s r11
+
+#define TWO_TAPS_NO_STORE(N) \
+ ldd c1, c0, coefs[N];\
+ ldd d1, d0, data[N];\
+ maccs sum_h, sum_l, c0, d0;\
+ maccs sum_h, sum_l, c1, d1;
+
+.cc_top src_us3_voice_input_sample.function
+.globl src_us3_voice_input_sample
+.align 4
+.type src_us3_voice_input_sample,@function
+src_us3_voice_input_sample://(int32_t data[], int32_t coefs[], int32_t sample);
+
+.issue_mode dual
+ DUALENTSP_lu6 STACKWORDS
+
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+
+
+ // TODO: fix this by renaming the registers
+ mov s, r2
+ {mov r2, r0; mov r3, r1}
+ {ldc r0, 0; ldc r1, 0}
+
+ bl src_ff3v_fir_impl
+
+ {ldc d0, 31; nop}
+ lextract r0, r1, r0, d0, 32
+
+ ldaw s, cp[src_ff3v_fir_comp_us]
+ ldw s, s[0]
+ {ldc c0, 0; ldc c1, 0}
+ maccs c0, c1, r0, s
+
+ ldaw s, cp[src_ff3v_fir_comp_q_us]
+ ldw s, s[0]
+
+ lsats c0, c1, s
+ lextract r0, c0, c1, s, 32
+
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ retsp STACKWORDS
+
+.src_us3_voice_input_sample_tmp:
+ .size src_us3_voice_input_sample, .src_us3_voice_input_sample_tmp-src_us3_voice_input_sample
+ .align 4
+ .cc_bottom src_us3_voice_input_sample.function
+
+ .set src_us3_voice_input_sample.nstackwords, STACKWORDS
+ .globl src_us3_voice_input_sample.nstackwords
+ .set src_us3_voice_input_sample.maxcores,1
+ .globl src_us3_voice_input_sample.maxcores
+ .set src_us3_voice_input_sample.maxtimers,0
+ .globl src_us3_voice_input_sample.maxtimers
+ .set src_us3_voice_input_sample.maxchanends,0
+ .globl src_us3_voice_input_sample.maxchanends
+
+.cc_top src_us3_voice_get_next_sample.function
+.globl src_us3_voice_get_next_sample
+.align 4
+.type src_us3_voice_get_next_sample,@function
+src_us3_voice_get_next_sample://(int32_t data[], int32_t coefs[], int32_t sample);
+
+.issue_mode dual
+ DUALENTSP_lu6 STACKWORDS
+
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+
+ // TODO: fix this by renaming the registers
+ {mov r2, r0; mov r3, r1}
+ {ldc r0, 0; ldc r1, 0}
+
+ TWO_TAPS_NO_STORE(0)
+ TWO_TAPS_NO_STORE(1)
+ TWO_TAPS_NO_STORE(2)
+ TWO_TAPS_NO_STORE(3)
+ TWO_TAPS_NO_STORE(4)
+ TWO_TAPS_NO_STORE(5)
+ TWO_TAPS_NO_STORE(6)
+ TWO_TAPS_NO_STORE(7)
+ TWO_TAPS_NO_STORE(8)
+ TWO_TAPS_NO_STORE(9)
+ TWO_TAPS_NO_STORE(10)
+ TWO_TAPS_NO_STORE(11)
+
+ {ldc d0, 31; nop}
+ lextract r0, r1, r0, d0, 32
+
+ ldaw s, cp[src_ff3v_fir_comp_us]
+ ldw s, s[0]
+ {ldc c0, 0; ldc c1, 0}
+ maccs c0, c1, r0, s
+
+ ldaw s, cp[src_ff3v_fir_comp_q_us]
+ ldw s, s[0]
+
+ lsats c0, c1, s
+ lextract r0, c0, c1, s, 32
+
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ retsp STACKWORDS
+
+.src_us3_voice_get_next_sample_tmp:
+ .size src_us3_voice_get_next_sample, .src_us3_voice_get_next_sample_tmp-src_us3_voice_get_next_sample
+ .align 4
+ .cc_bottom src_us3_voice_get_next_sample.function
+
+ .set src_us3_voice_get_next_sample.nstackwords, STACKWORDS
+ .globl src_us3_voice_get_next_sample.nstackwords
+ .set src_us3_voice_get_next_sample.maxcores,1
+ .globl src_us3_voice_get_next_sample.maxcores
+ .set src_us3_voice_get_next_sample.maxtimers,0
+ .globl src_us3_voice_get_next_sample.maxtimers
+ .set src_us3_voice_get_next_sample.maxchanends,0
+ .globl src_us3_voice_get_next_sample.maxchanends
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_24t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_24t.S
new file mode 100644
index 0000000..91d03d0
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_24t.S
@@ -0,0 +1,66 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME conv_s32_24t
+
+#define NSTACKWORDS (8)
+#define STACK_VEC_TMP (NSTACKWORDS - 8)
+
+#define state r0
+#define coef r1
+#define buff r2
+#define _32 r3
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t * coef)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+ // r4 - r10 are not used here
+
+ // Setting up the vpu and some constants
+ { ldaw buff, sp[STACK_VEC_TMP] ; ldc r11, 0 }
+ { ldc _32, 32 ; vsetc r11 }
+ { vclrdr ; mov r11, state }
+
+ // Do convolution
+ { ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { ; vlmaccr coef[0] }
+ // vR [0 - 2] has 3 macc results, store them
+ { ; vstr buff[0] }
+
+#undef state
+#define out r0
+
+#undef coef
+#define tmp0 r1
+
+#undef _32
+#define tmp1 r3
+
+ // Load all the results and add them together
+ ldd out, tmp1, buff[0]
+
+ { add out, out, tmp1 ; ldw tmp0, buff[2] }
+ { add out, out, tmp0 ; }
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_32t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_32t.S
new file mode 100644
index 0000000..6c21abf
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/conv_s32_32t.S
@@ -0,0 +1,71 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME conv_s32_32t
+
+#define NSTACKWORDS (8)
+#define STACK_VEC_TMP (NSTACKWORDS - 8)
+
+#define state r0
+#define coef r1
+#define buff r2
+#define _32 r3
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t * coef)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+ // r4 - r10 are not used here
+
+ // Setting up the vpu and some constants
+ { ldaw buff, sp[STACK_VEC_TMP] ; ldc r11, 0 }
+ { ldc _32, 32 ; vsetc r11 }
+ { vclrdr ; mov r11, state }
+
+ // Do convolution
+ { ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { ; vlmaccr coef[0] }
+ // vR [0 - 3] has 4 macc results, store them
+ { ; vstr buff[0] }
+
+#undef state
+#define out r0
+
+#undef coef
+#define tmp0 r1
+
+#undef _32
+#define tmp1 r3
+
+ // Load all the results and add them together
+ ldd out, tmp1, buff[0]
+
+ { add out, out, tmp1 ; ldw tmp0, buff[2] }
+ { add out, out, tmp0 ; ldw tmp1, buff[3] }
+ { add out, out, tmp1 ; }
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_24t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_24t.S
new file mode 100644
index 0000000..cae044d
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_24t.S
@@ -0,0 +1,88 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME fir_s32_24t
+
+#define NSTACKWORDS (1 + 8)
+#define STACK_VEC_TMP (NSTACKWORDS - 8)
+
+#define state r0
+#define coef r1
+#define new_samp r2
+#define indx r3
+#define _32 r4
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t * coef, int32_t new_samp)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+ // r5 - r10 are not used here
+
+ // Setting up the vpu and a poiter to the state[15]
+ { ldc r11, 0 ; stw r4, sp[0] }
+ { ldc indx, 15 ; vsetc r11 }
+ { ldc _32, 32 ; }
+
+ ldaw r11, state[indx] // r11 -> st[15 - 23]
+ // It's possible to undef "state" and reuse r0 for "_32" to reduce stack but it does not bring much value
+
+#undef indx
+#define buff r3
+
+ // It will shift the whole array with just 3 vldr + 3 vstr
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[16 - 24] // vR has st[15 - 23]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[7 - 15] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[8 - 16] // vR has st[7 - 15]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[-1 - 7] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[0 - 8] // vR has st[-1 - 7]
+ { ; vstr buff[0] } // buff has vR
+
+ // Bring r11 back to state[0], clear the vector unit
+ { add r11, r11, 4 ; vclrdr } // r11 -> st[0]
+
+ { ldaw buff, sp[STACK_VEC_TMP] ; stw new_samp, state[0] } // buff -> sp[10] // put new_samp in state[0]
+
+ // Do convolution
+ { ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { ; vlmaccr coef[0] }
+ // vR [0 - 2] has 3 macc results, store them
+ { ; vstr buff[0] }
+
+#undef state
+#define out r0
+
+#undef coef
+#define tmp0 r1
+
+#undef new_samp
+#define tmp1 r2
+
+ // Load all the results and add them together
+ ldd out, tmp1, buff[0]
+
+ { add out, out, tmp1 ; ldw tmp0, buff[2] }
+ { add out, out, tmp0 ; ldw r4, sp[0] }
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_32t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_32t.S
new file mode 100644
index 0000000..c2591a3
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_32t.S
@@ -0,0 +1,96 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME fir_s32_32t
+
+#define NSTACKWORDS (1 + 8)
+#define STACK_VEC_TMP (NSTACKWORDS - 8)
+
+#define state r0
+#define coef r1
+#define new_samp r2
+#define indx r3
+#define _32 r4
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t * coef, int32_t new_samp)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+
+ // r5 - r10 are not used here
+
+ // Setting up the vpu and a poiter to the state[23]
+ { ldc r11, 0 ; stw r4, sp[0] }
+ { ldc indx, 23 ; vsetc r11 }
+ { ldc _32, 32 ; }
+
+ ldaw r11, state[indx] // r11 -> st[23 - 31]
+ // It's possible to undef "state" and reuse r0 for "_32" to reduce stack but it does not bring much value
+
+#undef indx
+#define buff r3
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[24 - 32] // vR has st[23 - 31]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[15 - 23] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[16 - 24] // vR has st[15 - 23]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[7 - 15] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[8 - 16] // vR has st[7 - 15]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[-1 - 7] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[0 - 8] // vR has st[-1 - 7]
+ { ; vstr buff[0] } // buff has vR
+
+ // Bring r11 back to state[0], clear the vector unit
+ { add r11, r11, 4 ; vclrdr } // r11 -> st[0]
+
+ { ldaw buff, sp[STACK_VEC_TMP] ; stw new_samp, state[0] } // buff -> sp[10] // put new_samp in state[0]
+
+ // Do convolution
+ { ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { ; vlmaccr coef[0] }
+ // vR [0 - 3] has 4 macc results, store them
+ { ; vstr buff[0] }
+
+#undef state
+#define out r0
+
+#undef coef
+#define tmp0 r1
+
+#undef new_samp
+#define tmp1 r2
+
+ // Load all the results and add them together
+ ldd out, tmp1, buff[0]
+
+ { add out, out, tmp1 ; ldw tmp0, buff[2] }
+ { add out, out, tmp0 ; ldw tmp1, buff[3] }
+ { add out, out, tmp1 ; ldw r4, sp[0] }
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_48t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_48t.S
new file mode 100644
index 0000000..3036f04
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/fir_s32_48t.S
@@ -0,0 +1,109 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME fir_s32_48t
+
+#define NSTACKWORDS (1 + 8)
+#define STACK_VEC_TMP (NSTACKWORDS - 8)
+
+#define state r0
+#define coef r1
+#define new_samp r2
+#define indx r3
+#define _32 r4
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t * coef, int32_t new_samp)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+ // r5 - r10 are not used here
+
+ // Setting up the vpu and a poiter to the state[39]
+ { ldc r11, 0 ; stw r4, sp[0] }
+ { ldc indx, 39 ; vsetc r11 }
+ { ldc _32, 32 ; }
+
+ ldaw r11, state[indx] // r11 -> st[39 - 47]
+ // It's possible to undef "state" and reuse r0 for "_32" to reduce stack but it does not bring much value
+
+#undef indx
+#define buff r3
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[40 - 48] // vR has st[39 - 47]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[31 - 39] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[32 - 40] // vR has st[31 - 39]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[23 - 31] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[24 - 32] // vR has st[23 - 31]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[15 - 23] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[16 - 24] // vR has st[15 - 23]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[7 - 15] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[8 - 16] // vR has st[7 - 15]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[-1 - 7] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[0 - 8] // vR has st[-1 - 7]
+ { ; vstr buff[0] } // buff has vR
+
+ // Bring r11 back to state[0], clear the vector unit
+ { add r11, r11, 4 ; vclrdr } // r11 -> st[0]
+
+ { ldaw buff, sp[STACK_VEC_TMP] ; stw new_samp, state[0] } // buff -> sp[10] // put new_samp in state[0]
+
+ // Do convolution
+ { ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { add r11, r11, _32 ; vlmaccr coef[0] }
+
+ { add coef, coef, _32 ; vldc r11[0] }
+ { ; vlmaccr coef[0] }
+ // vR [0 - 5] has 6 macc results, store them
+ { ; vstr buff[0] }
+
+#undef state
+#define out r0
+
+#undef coef
+#define tmp0 r1
+
+#undef new_samp
+#define tmp1 r2
+
+ // Load all the results and add them together
+ ldd out, tmp1, buff[0]
+
+ { add out, out, tmp1 ; ldw tmp0, buff[2] }
+ { add out, out, tmp0 ; ldw tmp1, buff[3] }
+ { add out, out, tmp1 ; ldw tmp0, buff[4] }
+ { add out, out, tmp0 ; ldw tmp1, buff[5] }
+ { add out, out, tmp1 ; ldw r4, sp[0] }
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/push_s32_48t.S b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/push_s32_48t.S
new file mode 100644
index 0000000..9a945b6
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/asm/push_s32_48t.S
@@ -0,0 +1,65 @@
+// Copyright 2023-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FUNCTION_NAME push_s32_48t
+
+#define NSTACKWORDS (0)
+
+#define state r0
+#define new_samp r1
+#define indx r2
+#define _32 r3
+
+.text
+.issue_mode dual
+.globl FUNCTION_NAME;
+.type FUNCTION_NAME,@function
+.align 16
+.cc_top FUNCTION_NAME.function,FUNCTION_NAME
+
+FUNCTION_NAME: // (int32_t * state, int32_t new_samp)
+ dualentsp NSTACKWORDS
+#if (defined(__XS3A__)) // Only available for XS3 with VPU
+
+ // r4 - r10 are not used here
+
+ // Setting up the vpu and a poiter to the state[39]
+ { ldc _32, 32 ; ldc r11, 0 }
+ { ldc indx, 39 ; vsetc r11 }
+ { ldaw r11, state[indx] ; } // r11 -> st[39 - 47]
+
+#undef indx
+#define buff r2
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[40 - 48] // vR has st[39 - 47]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[31 - 39] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[32 - 40] // vR has st[31 - 39]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[23 - 31] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[24 - 32] // vR has st[23 - 31]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[15 - 23] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[16 - 24] // vR has st[15 - 23]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[7 - 15] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[8 - 16] // vR has st[7 - 15]
+ { sub r11, r11, _32 ; vstr buff[0] } // r11 -> st[-1 - 7] // buff has vR
+
+ { add buff, r11, 4 ; vldr r11[0] } // buff -> st[0 - 8] // vR has st[-1 - 7]
+ { ; vstr buff[0] } // buff has vR
+
+ // put new_samp in state[0]
+ { ; stw new_samp, state[0] }
+
+#endif // Only available for XS3 with VPU
+ retsp NSTACKWORDS
+
+.cc_bottom FUNCTION_NAME.function;
+.set FUNCTION_NAME.nstackwords,NSTACKWORDS; .global FUNCTION_NAME.nstackwords;
+.set FUNCTION_NAME.maxcores,1; .global FUNCTION_NAME.maxcores;
+.set FUNCTION_NAME.maxtimers,0; .global FUNCTION_NAME.maxtimers;
+.set FUNCTION_NAME.maxchanends,0; .global FUNCTION_NAME.maxchanends;
+
+#undef FUNCTION_NAME
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.c b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.c
new file mode 100644
index 0000000..dcef970
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.c
@@ -0,0 +1,59 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/*********************************/
+/* AUTOGENERATED. DO NOT MODIFY! */
+/*********************************/
+
+// Use src_ff3_fir_gen.py script to regenare this file
+// python src_ff3_fir_gen.py -gc True -ntp 32 -np 3
+
+#include "src_ff3_fir_coefs.h"
+#include
+
+/** q31 coefficients to use for debugging ff3 sample rate conversion */
+const int32_t ALIGNMENT(8) src_ff3_fir_coefs_debug[SRC_FF3_FIR_NUM_PHASES * SRC_FF3_FIR_TAPS_PER_PHASE] = {
+ -132660, -391256, -272653, 294018, 790734, 513772,
+ -561508, -1423266, -881735, 972885, 2366363, 1416412,
+ -1572615, -3711773, -2165391, 2413069, 5568888, 3186277,
+ -3557131, -8071663, -4551171, 5083569, 11392367, 6355363,
+ -7097804, -15768801, -8734511, 9753621, 21559523, 11899941,
+ -13298806, -29362449, -16216509, 18178957, 40294588, 22394094,
+ -25305013, -56753765, -32043220, 36887788, 85009440, 49769829,
+ -60002604, -148154004, -96041427, 135812786, 454448559, 683203534,
+ 683203534, 454448559, 135812786, -96041427, -148154004, -60002604,
+ 49769829, 85009440, 36887788, -32043220, -56753765, -25305013,
+ 22394094, 40294588, 18178957, -16216509, -29362449, -13298806,
+ 11899941, 21559523, 9753621, -8734511, -15768801, -7097804,
+ 6355363, 11392367, 5083569, -4551171, -8071663, -3557131,
+ 3186277, 5568888, 2413069, -2165391, -3711773, -1572615,
+ 1416412, 2366363, 972885, -881735, -1423266, -561508,
+ 513772, 790734, 294018, -272653, -391256, -132660,
+
+};
+
+/** q30 coefficients to use for the ff3 48 - 16 kHz polyphase FIR filtering */
+const int32_t ALIGNMENT(8) src_ff3_fir_coefs[SRC_FF3_FIR_NUM_PHASES][SRC_FF3_FIR_TAPS_PER_PHASE] = {
+ {
+ -136326, 256886, -440867, 708206, -1082695, 1593138,
+ -2275585, 3177682, -4367255, 5949971, -8108254, 11197047,
+ -16021610, 24884914, -48020712, 341601760, 67906392, -30001302,
+ 18443894, -12652507, 9089479, -6649403, 4876810, -3548902,
+ 2541785, -1778566, 1206534, -786307, 486442, -280754,
+ 147009, -66330,},
+ {
+ -195628, 395367, -711633, 1183181, -1855886, 2784444,
+ -4035831, 5696184, -7884400, 10779762, -14681225, 20147294,
+ -28376882, 42504720, -74077000, 227224272, 227224272, -74077000,
+ 42504720, -28376882, 20147294, -14681225, 10779762, -7884400,
+ 5696184, -4035831, 2784444, -1855886, 1183181, -711633,
+ 395367, -195628,},
+ {
+ -66330, 147009, -280754, 486442, -786307, 1206534,
+ -1778566, 2541785, -3548902, 4876810, -6649403, 9089479,
+ -12652507, 18443894, -30001302, 67906392, 341601760, -48020712,
+ 24884914, -16021610, 11197047, -8108254, 5949971, -4367255,
+ 3177682, -2275585, 1593138, -1082695, 708206, -440867,
+ 256886, -136326,},
+};
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.h b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.h
new file mode 100644
index 0000000..e5e40b2
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_ff3_fir_coefs.h
@@ -0,0 +1,34 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/*********************************/
+/* AUTOGENERATED. DO NOT MODIFY! */
+/*********************************/
+
+// Use src_ff3_fir_gen.py script to regenare this file
+// python src_ff3_fir_gen.py -gc True -ntp 32 -np 3
+
+#ifndef _SRC_FF3_COEFS_H_
+#define _SRC_FF3_COEFS_H_
+
+#include
+
+#ifndef ALIGNMENT
+# ifdef __xcore__
+# define ALIGNMENT(N) __attribute__((aligned (N)))
+# else
+# define ALIGNMENT(N)
+# endif
+#endif
+
+#define SRC_FF3_FIR_NUM_PHASES (3)
+#define SRC_FF3_FIR_TAPS_PER_PHASE (32)
+
+/** q31 coefficients to use for debugging ff3 sample rate conversion */
+extern const int32_t src_ff3_fir_coefs_debug[SRC_FF3_FIR_NUM_PHASES * SRC_FF3_FIR_TAPS_PER_PHASE];
+
+/** q30 coefficients to use for the ff3 48 - 16 kHz polyphase FIR filtering */
+extern const int32_t src_ff3_fir_coefs[SRC_FF3_FIR_NUM_PHASES][SRC_FF3_FIR_TAPS_PER_PHASE];
+
+#endif // _SRC_FF3_COEFS_H_
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_low_level.h b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_low_level.h
new file mode 100644
index 0000000..f87e31d
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_low_level.h
@@ -0,0 +1,70 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef _SRC_LOW_LEVEL_H_
+#define _SRC_LOW_LEVEL_H_
+
+/**
+ * @brief Perfoms VPU-optimised convolution for s32 type integers
+ *
+ * @param samples Samples array
+ * @param coef FIR coefficients array
+ * @note Both samples and coef has to have 24 values int32_t in them
+ * @note Both samples and coef have to be 8 bit aligned
+ */
+int32_t conv_s32_24t(const int32_t * samples, const int32_t * coef);
+
+/**
+ * @brief Perforns VPU-optimised FIR filtering for s32 type integers
+ *
+ * @param state State that keep previous samples
+ * @param coef FIR coefficients array
+ * @param new_samp New sample to put in the state
+ * @note Both state and coef has to have 24 values int32_t in them
+ * @note Both state and coef have to be 8 bit aligned
+ */
+int32_t fir_s32_24t(int32_t * state, const int32_t * coef, int32_t new_samp);
+
+/**
+ * @brief Perfoms VPU-optimised convolution for s32 type integers
+ *
+ * @param samples Samples array
+ * @param coef FIR coefficients array
+ * @note Both samples and coef has to have 32 values int32_t in them
+ * @note Both samples and coef have to be 8 bit aligned
+ */
+int32_t conv_s32_32t(const int32_t * samples, const int32_t * coef);
+
+/**
+ * @brief Perforns VPU-optimised FIR filtering for s32 type integers
+ *
+ * @param state State that keep previous samples
+ * @param coef FIR coefficients array
+ * @param new_samp New sample to put in the state
+ * @note Both state and coef has to have 32 values int32_t in them
+ * @note Both state and coef have to be 8 bit aligned
+ */
+int32_t fir_s32_32t(int32_t * state, const int32_t * coef, int32_t new_samp);
+
+/**
+ * @brief Perforns VPU-optimised ring buffer shift for s32 type integers
+ *
+ * @param state State that keep previous samples
+ * @param new_samp New sample to put in the state
+ * @note Both state and coef has to have 48 values int32_t in them
+ * @note Both state and coef have to be 8 bit aligned
+ */
+void push_s32_48t(int32_t * state, int32_t new_samp);
+
+/**
+ * @brief Perforns VPU-optimised FIR filtering for s32 type integers
+ *
+ * @param state State that keep previous samples
+ * @param coef FIR coefficients array
+ * @param new_samp New sample to put in the state
+ * @note Both state and coef has to have 48 values int32_t in them
+ * @note Both state and coef have to be 8 bit aligned
+ */
+int32_t fir_s32_48t(int32_t * state, const int32_t * coef, int32_t new_samp);
+
+#endif // _SRC_LOW_LEVEL_H_
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_poly.h b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_poly.h
new file mode 100644
index 0000000..14549e7
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_poly.h
@@ -0,0 +1,154 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#ifndef _SRC_POLY_VPU_H_
+#define _SRC_POLY_VPU_H_
+
+#include "stdint.h"
+#include "src_low_level.h"
+
+// If you want to undestand any of this better,
+// read Richard G. Lyons "Understanding digital signal processing"
+// capters 10.1 - 10.7, 10.10 - 10.11
+
+
+
+/**
+ * @brief Performs VPU-optimised 72 taps polyphase fixed-factor-of-3 downsampling
+ *
+ * @param samp_in Values to be downsampled
+ * @param samp_out Downsampled output
+ * @param coefs_ff3 Three-phase FIR coefficients array with [3][24] dimensions
+ * @param state_ds Three-phase FIR state array with [3][24] dimensions
+ */
+static inline void src_ff3_72t_ds(int32_t samp_in[3], int32_t samp_out[1], const int32_t coefs_ff3[3][24], int32_t state_ds[3][24])
+{
+ int64_t acc = 0;
+ acc += fir_s32_24t(state_ds[0], coefs_ff3[0], samp_in[0]);
+ acc += fir_s32_24t(state_ds[1], coefs_ff3[1], samp_in[1]);
+ acc += fir_s32_24t(state_ds[2], coefs_ff3[2], samp_in[2]);
+
+ samp_out[0] = (int32_t)acc;
+}
+
+/**
+ * @brief Performs VPU-optimised 72 taps polyphase fixed-factor-of-3 upsampling
+ *
+ * @param samp_in Value to be upsampled
+ * @param samp_out Upsampled output
+ * @param coefs_ff3 Three-phase FIR coefficients array with [3][24] dimensions
+ * @param state_us FIR state array with 24 elements in it
+ * @note samp_in and samp_out have to be different memory locations
+ */
+static inline void src_ff3_72t_us(int32_t samp_in[1], int32_t samp_out[3], const int32_t coefs_ff3[3][24], int32_t state_us[24])
+{
+ samp_out[0] = fir_s32_24t(state_us, coefs_ff3[2], samp_in[0]) * 3;
+ samp_out[1] = conv_s32_24t(state_us, coefs_ff3[1]) * 3;
+ samp_out[2] = conv_s32_24t(state_us, coefs_ff3[0]) * 3;
+}
+
+
+/**
+ * \addtogroup src_ff3_96t_ds src_ff3_96t_ds
+ *
+ * The public API for using SRC.
+ * @{
+ */
+
+/**
+ * @brief Performs VPU-optimised 96 taps polyphase fixed-factor-of-3 downsampling
+ *
+ * @param samp_in Values to be downsampled
+ * @param samp_out Downsampled output
+ * @param coefs_ff3 Three-phase FIR coefficients array with [3][32] dimensions
+ * @param state_ds Three-phase FIR state array with [3][32] dimensions
+ */
+static inline void src_ff3_96t_ds(int32_t samp_in[3], int32_t samp_out[1], const int32_t coefs_ff3[3][32], int32_t state_ds[3][32])
+{
+ int64_t acc = 0;
+ acc += fir_s32_32t(state_ds[0], coefs_ff3[0], samp_in[0]);
+ acc += fir_s32_32t(state_ds[1], coefs_ff3[1], samp_in[1]);
+ acc += fir_s32_32t(state_ds[2], coefs_ff3[2], samp_in[2]);
+
+ samp_out[0] = (int32_t)acc;
+}
+
+/**@}*/ // END: addtogroup src_ff3_96t_ds
+
+/**
+ * \addtogroup src_ff3_96t_us src_ff3_96t_us
+ *
+ * The public API for using SRC.
+ * @{
+ */
+
+/**
+ * @brief Performs VPU-optimised 96 taps polyphase fixed-factor-of-3 upsampling
+ *
+ * @param samp_in Value to be upsampled
+ * @param samp_out Upsampled output
+ * @param coefs_ff3 Three-phase FIR coefficients array with [3][32] dimensions
+ * @param state_us FIR state array with 32 elements in it
+ * @note samp_in and samp_out have to be different memory locations
+ */
+static inline void src_ff3_96t_us(int32_t samp_in[1], int32_t samp_out[3], const int32_t coefs_ff3[3][32], int32_t state_us[32])
+{
+ samp_out[0] = fir_s32_32t(state_us, coefs_ff3[2], samp_in[0]) * 3;
+ samp_out[1] = conv_s32_32t(state_us, coefs_ff3[1]) * 3;
+ samp_out[2] = conv_s32_32t(state_us, coefs_ff3[0]) * 3;
+}
+
+/**@}*/ // END: addtogroup src_ff3_96t_us
+
+
+/**
+ * \addtogroup src_rat_2_3_96t_ds src_rat_2_3_96t_ds
+ *
+ * The public API for using SRC.
+ * @{
+ */
+
+/**
+ * @brief Performs VPU-optimised 96 taps polyphase rational factor 2/3 downsampling
+ *
+ * @param samp_in Values to be downsampled
+ * @param samp_out Downsampled output
+ * @param coefs_ds Two-phase FIR coefficients array with [2][48] dimensions
+ * @param state_ds FIR state array with 48 elements in it
+ */
+static inline void src_rat_2_3_96t_ds(int32_t samp_in[3], int32_t samp_out[2], const int32_t coefs_ds[2][48], int32_t state_ds[48])
+{
+ push_s32_48t(state_ds, samp_in[0]);
+ samp_out[0] = fir_s32_48t(state_ds, coefs_ds[0], samp_in[1]) * 2;
+ samp_out[1] = fir_s32_48t(state_ds, coefs_ds[1], samp_in[2]) * 2;
+}
+
+/**@}*/ // END: addtogroup src_rat_2_3_96t_ds
+
+
+/**
+ * \addtogroup src_rat_3_2_96t_us src_rat_3_2_96t_us
+ *
+ * The public API for using SRC.
+ * @{
+ */
+
+/**
+ * @brief Performs VPU-optimised 96 taps polyphase rational factor 3/2 upsampling
+ *
+ * @param samp_in Values to be upsampled
+ * @param samp_out Upsampled output
+ * @param coefs_us Three-phase FIR coefficients array with [3][32] dimensions
+ * @param state_us FIR state array with 32 elements in it
+ * @note samp_in and samp_out have to be different memory locations
+ */
+static inline void src_rat_3_2_96t_us(int32_t samp_in[2], int32_t samp_out[3], const int32_t coefs_us[3][32], int32_t state_us[32])
+{
+ samp_out[0] = fir_s32_32t(state_us, coefs_us[0], samp_in[0]) * 3;
+ samp_out[1] = conv_s32_32t(state_us, coefs_us[2]) * 3;
+ samp_out[2] = fir_s32_32t(state_us, coefs_us[1], samp_in[1]) * 3;
+}
+
+/**@}*/ // END: addtogroup src_rat_3_2_96t_us
+
+#endif // _SRC_POLY_VPU_H_
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.c b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.c
new file mode 100644
index 0000000..e1d3882
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.c
@@ -0,0 +1,64 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/*********************************/
+/* AUTOGENERATED. DO NOT MODIFY! */
+/*********************************/
+
+// Use src_rat_fir_gen.py script to regenare this file
+// python src_rat_fir_gen.py -gc True -nt 96
+
+#include "src_rat_fir_coefs.h"
+#include
+
+/** q30 coefficients to use for the 48 -> 32 kHz polyphase rational factor downsampling */
+const int32_t ALIGNMENT(8) src_rat_fir_ds_coefs[SRC_RAT_FIR_NUM_PHASES_DS][SRC_RAT_FIR_TAPS_PER_PHASE_DS] = {
+ {
+ -37518, -12954, 215278, -239478, -263107, 939176,
+ -724308, -879964, 2499126, -1681211, -2092592, 5401196,
+ -3401730, -4251005, 10510310, -6447506, -8092907, 19936433,
+ -12408241, -16117127, 42378484, -29745967, -48209846, 227198230,
+ 341824286, 67661646, -73999660, 25030944, 18189153, -28205672,
+ 11237632, 8863615, -14437276, 5881230, 4701938, -7597786,
+ 3022648, 2420957, -3741363, 1394185, 1128882, -1587718,
+ 513087, 436331, -497504, 103937, 112484, -52024,
+ },
+ {
+ -52024, 112484, 103937, -497504, 436331, 513087,
+ -1587718, 1128882, 1394185, -3741363, 2420957, 3022648,
+ -7597786, 4701938, 5881230, -14437276, 8863615, 11237632,
+ -28205672, 18189153, 25030944, -73999660, 67661646, 341824286,
+ 227198230, -48209846, -29745967, 42378484, -16117127, -12408241,
+ 19936433, -8092907, -6447506, 10510310, -4251005, -3401730,
+ 5401196, -2092592, -1681211, 2499126, -879964, -724308,
+ 939176, -263107, -239478, 215278, -12954, -37518,
+ },
+
+};
+
+/** q30 coefficients to use for the 32 -> 48 kHz polyphase rational factor upsampling */
+const int32_t ALIGNMENT(8) src_rat_fir_us_coefs[SRC_RAT_FIR_NUM_PHASES_US][SRC_RAT_FIR_TAPS_PER_PHASE_US] = {
+ {
+ -37518, 112484, -239478, 436331, -724308, 1128882,
+ -1681211, 2420957, -3401730, 4701938, -6447506, 8863615,
+ -12408241, 18189153, -29745967, 67661646, 341824286, -48209846,
+ 25030944, -16117127, 11237632, -8092907, 5881230, -4251005,
+ 3022648, -2092592, 1394185, -879964, 513087, -263107,
+ 103937, -12954,},
+ {
+ -52024, 215278, -497504, 939176, -1587718, 2499126,
+ -3741363, 5401196, -7597786, 10510310, -14437276, 19936433,
+ -28205672, 42378484, -73999660, 227198230, 227198230, -73999660,
+ 42378484, -28205672, 19936433, -14437276, 10510310, -7597786,
+ 5401196, -3741363, 2499126, -1587718, 939176, -497504,
+ 215278, -52024,},
+ {
+ -12954, 103937, -263107, 513087, -879964, 1394185,
+ -2092592, 3022648, -4251005, 5881230, -8092907, 11237632,
+ -16117127, 25030944, -48209846, 341824286, 67661646, -29745967,
+ 18189153, -12408241, 8863615, -6447506, 4701938, -3401730,
+ 2420957, -1681211, 1128882, -724308, 436331, -239478,
+ 112484, -37518,},
+
+};
+
diff --git a/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.h b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.h
new file mode 100644
index 0000000..730a94e
--- /dev/null
+++ b/lib_src/lib_src/src/fixed_factor_vpu_voice/src_rat_fir_coefs.h
@@ -0,0 +1,37 @@
+// Copyright 2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+/*********************************/
+/* AUTOGENERATED. DO NOT MODIFY! */
+/*********************************/
+
+// Use src_rat_fir_gen.py script to regenare this file
+// python src_rat_fir_gen.py -gc True -nt 96
+
+#ifndef _SRC_RAT_COEFS_H_
+#define _SRC_RAT_COEFS_H_
+
+#include
+
+#ifndef ALIGNMENT
+# ifdef __xcore__
+# define ALIGNMENT(N) __attribute__((aligned (N)))
+# else
+# define ALIGNMENT(N)
+# endif
+#endif
+
+#define SRC_RAT_FIR_NUM_TAPS (96)
+#define SRC_RAT_FIR_NUM_PHASES_DS (2)
+#define SRC_RAT_FIR_TAPS_PER_PHASE_DS (48)
+#define SRC_RAT_FIR_NUM_PHASES_US (3)
+#define SRC_RAT_FIR_TAPS_PER_PHASE_US (32)
+
+/** q30 coefficients to use for the 48 -> 32 kHz polyphase rational factor downsampling */
+extern const int32_t src_rat_fir_ds_coefs[SRC_RAT_FIR_NUM_PHASES_DS][SRC_RAT_FIR_TAPS_PER_PHASE_DS];
+
+/** q30 coefficients to use for the 32 -> 48 kHz polyphase rational factor upsampling */
+extern const int32_t src_rat_fir_us_coefs[SRC_RAT_FIR_NUM_PHASES_US][SRC_RAT_FIR_TAPS_PER_PHASE_US];
+
+#endif // _SRC_RAT_COEFS_H_
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.dat
new file mode 100644
index 0000000..6946336
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.dat
@@ -0,0 +1,1922 @@
+ 506,
+ 160,
+ 186,
+ 213,
+ 244,
+ 278,
+ 314,
+ 354,
+ 398,
+ 445,
+ 497,
+ 551,
+ 612,
+ 678,
+ 748,
+ 824,
+ 905,
+ 993,
+ 1088,
+ 1189,
+ 1297,
+ 1413,
+ 1537,
+ 1669,
+ 1811,
+ 1961,
+ 2122,
+ 2293,
+ 2475,
+ 2667,
+ 2872,
+ 3089,
+ 3319,
+ 3563,
+ 3821,
+ 4094,
+ 4383,
+ 4688,
+ 5010,
+ 5350,
+ 5707,
+ 6085,
+ 6483,
+ 6900,
+ 7340,
+ 7802,
+ 8289,
+ 8799,
+ 9335,
+ 9897,
+ 10487,
+ 11104,
+ 11751,
+ 12429,
+ 13138,
+ 13879,
+ 14654,
+ 15466,
+ 16312,
+ 17196,
+ 18119,
+ 19082,
+ 20086,
+ 21133,
+ 22224,
+ 23360,
+ 24543,
+ 25774,
+ 27055,
+ 28388,
+ 29772,
+ 31212,
+ 32707,
+ 34260,
+ 35871,
+ 37544,
+ 39279,
+ 41078,
+ 42943,
+ 44875,
+ 46877,
+ 48950,
+ 51096,
+ 53317,
+ 55614,
+ 57990,
+ 60446,
+ 62985,
+ 65607,
+ 68316,
+ 71113,
+ 74000,
+ 76978,
+ 80051,
+ 83220,
+ 86485,
+ 89852,
+ 93320,
+ 96892,
+ 100570,
+ 104356,
+ 108252,
+ 112260,
+ 116381,
+ 120618,
+ 124974,
+ 129448,
+ 134046,
+ 138766,
+ 143612,
+ 148585,
+ 153688,
+ 158923,
+ 164291,
+ 169792,
+ 175431,
+ 181208,
+ 187125,
+ 193184,
+ 199385,
+ 205733,
+ 212226,
+ 218867,
+ 225657,
+ 232598,
+ 239690,
+ 246936,
+ 254335,
+ 261891,
+ 269602,
+ 277470,
+ 285496,
+ 293682,
+ 302027,
+ 310531,
+ 319195,
+ 328022,
+ 337009,
+ 346156,
+ 355466,
+ 364937,
+ 374568,
+ 384361,
+ 394313,
+ 404426,
+ 414697,
+ 425125,
+ 435712,
+ 446454,
+ 457350,
+ 468400,
+ 479601,
+ 490952,
+ 502450,
+ 514093,
+ 525880,
+ 537807,
+ 549871,
+ 562070,
+ 574401,
+ 586861,
+ 599445,
+ 612150,
+ 624971,
+ 637906,
+ 650949,
+ 664096,
+ 677342,
+ 690681,
+ 704107,
+ 717617,
+ 731203,
+ 744859,
+ 758580,
+ 772357,
+ 786185,
+ 800056,
+ 813962,
+ 827895,
+ 841849,
+ 855813,
+ 869780,
+ 883740,
+ 897684,
+ 911603,
+ 925487,
+ 939324,
+ 953105,
+ 966820,
+ 980456,
+ 994002,
+ 1007448,
+ 1020778,
+ 1033984,
+ 1047050,
+ 1059964,
+ 1072712,
+ 1085281,
+ 1097656,
+ 1109823,
+ 1121768,
+ 1133474,
+ 1144927,
+ 1156111,
+ 1167009,
+ 1177604,
+ 1187882,
+ 1197822,
+ 1207409,
+ 1216625,
+ 1225451,
+ 1233870,
+ 1241861,
+ 1249405,
+ 1256484,
+ 1263078,
+ 1269166,
+ 1274727,
+ 1279742,
+ 1284189,
+ 1288047,
+ 1291293,
+ 1293907,
+ 1295866,
+ 1297147,
+ 1297728,
+ 1297585,
+ 1296696,
+ 1295037,
+ 1292582,
+ 1289310,
+ 1285197,
+ 1280216,
+ 1274343,
+ 1267555,
+ 1259825,
+ 1251128,
+ 1241438,
+ 1230732,
+ 1218982,
+ 1206163,
+ 1192249,
+ 1177213,
+ 1161030,
+ 1143673,
+ 1125116,
+ 1105333,
+ 1084297,
+ 1061981,
+ 1038361,
+ 1013408,
+ 987096,
+ 959400,
+ 930292,
+ 899746,
+ 867737,
+ 834239,
+ 799225,
+ 762671,
+ 724548,
+ 684833,
+ 643502,
+ 600528,
+ 555887,
+ 509555,
+ 461506,
+ 411719,
+ 360168,
+ 306832,
+ 251686,
+ 194710,
+ 135881,
+ 75177,
+ 12577,
+ -51937,
+ -118387,
+ -186793,
+ -257173,
+ -329544,
+ -403926,
+ -480333,
+ -558783,
+ -639291,
+ -721872,
+ -806541,
+ -893309,
+ -982189,
+ -1073194,
+ -1166332,
+ -1261615,
+ -1359052,
+ -1458649,
+ -1560414,
+ -1664353,
+ -1770470,
+ -1878769,
+ -1989253,
+ -2101924,
+ -2216780,
+ -2333823,
+ -2453049,
+ -2574456,
+ -2698038,
+ -2823791,
+ -2951706,
+ -3081776,
+ -3213990,
+ -3348336,
+ -3484803,
+ -3623375,
+ -3764038,
+ -3906773,
+ -4051563,
+ -4198387,
+ -4347223,
+ -4498046,
+ -4650835,
+ -4805558,
+ -4962189,
+ -5120698,
+ -5281052,
+ -5443218,
+ -5607161,
+ -5772842,
+ -5940225,
+ -6109265,
+ -6279922,
+ -6452150,
+ -6625903,
+ -6801133,
+ -6977789,
+ -7155819,
+ -7335167,
+ -7515780,
+ -7697597,
+ -7880559,
+ -8064602,
+ -8249665,
+ -8435679,
+ -8622577,
+ -8810288,
+ -8998740,
+ -9187859,
+ -9377567,
+ -9567787,
+ -9758437,
+ -9949435,
+ -10140696,
+ -10332135,
+ -10523660,
+ -10715182,
+ -10906607,
+ -11097842,
+ -11288789,
+ -11479348,
+ -11669418,
+ -11858897,
+ -12047679,
+ -12235658,
+ -12422724,
+ -12608767,
+ -12793673,
+ -12977327,
+ -13159614,
+ -13340414,
+ -13519608,
+ -13697073,
+ -13872685,
+ -14046319,
+ -14217846,
+ -14387139,
+ -14554066,
+ -14718496,
+ -14880294,
+ -15039324,
+ -15195449,
+ -15348533,
+ -15498434,
+ -15645011,
+ -15788123,
+ -15927624,
+ -16063371,
+ -16195217,
+ -16323015,
+ -16446616,
+ -16565872,
+ -16680631,
+ -16790743,
+ -16896057,
+ -16996420,
+ -17091677,
+ -17181675,
+ -17266260,
+ -17345276,
+ -17418570,
+ -17485983,
+ -17547361,
+ -17602548,
+ -17651386,
+ -17693721,
+ -17729395,
+ -17758253,
+ -17780139,
+ -17794898,
+ -17802374,
+ -17802413,
+ -17794860,
+ -17779564,
+ -17756370,
+ -17725127,
+ -17685686,
+ -17637895,
+ -17581607,
+ -17516674,
+ -17442951,
+ -17360293,
+ -17268557,
+ -17167602,
+ -17057290,
+ -16937482,
+ -16808042,
+ -16668838,
+ -16519739,
+ -16360615,
+ -16191339,
+ -16011790,
+ -15821844,
+ -15621384,
+ -15410293,
+ -15188460,
+ -14955775,
+ -14712131,
+ -14457426,
+ -14191560,
+ -13914437,
+ -13625965,
+ -13326057,
+ -13014625,
+ -12691592,
+ -12356880,
+ -12010417,
+ -11652134,
+ -11281971,
+ -10899866,
+ -10505769,
+ -10099626,
+ -9681397,
+ -9251042,
+ -8808525,
+ -8353820,
+ -7886901,
+ -7407754,
+ -6916364,
+ -6412725,
+ -5896837,
+ -5368705,
+ -4828341,
+ -4275761,
+ -3710990,
+ -3134059,
+ -2545001,
+ -1943863,
+ -1330692,
+ -705546,
+ -68486,
+ 580415,
+ 1241083,
+ 1913433,
+ 2597372,
+ 3292804,
+ 3999622,
+ 4717715,
+ 5446959,
+ 6187229,
+ 6938387,
+ 7700292,
+ 8472792,
+ 9255728,
+ 10048935,
+ 10852237,
+ 11665452,
+ 12488390,
+ 13320854,
+ 14162636,
+ 15013522,
+ 15873290,
+ 16741710,
+ 17618542,
+ 18503540,
+ 19396448,
+ 20297004,
+ 21204936,
+ 22119963,
+ 23041799,
+ 23970147,
+ 24904703,
+ 25845154,
+ 26791179,
+ 27742450,
+ 28698630,
+ 29659373,
+ 30624326,
+ 31593129,
+ 32565412,
+ 33540798,
+ 34518902,
+ 35499331,
+ 36481685,
+ 37465555,
+ 38450527,
+ 39436175,
+ 40422071,
+ 41407776,
+ 42392843,
+ 43376821,
+ 44359249,
+ 45339662,
+ 46317586,
+ 47292541,
+ 48264040,
+ 49231589,
+ 50194690,
+ 51152836,
+ 52105515,
+ 53052211,
+ 53992399,
+ 54925550,
+ 55851131,
+ 56768601,
+ 57677415,
+ 58577025,
+ 59466875,
+ 60346407,
+ 61215058,
+ 62072260,
+ 62917443,
+ 63750030,
+ 64569446,
+ 65375106,
+ 66166428,
+ 66942824,
+ 67703704,
+ 68448475,
+ 69176543,
+ 69887313,
+ 70580186,
+ 71254564,
+ 71909846,
+ 72545433,
+ 73160722,
+ 73755113,
+ 74328003,
+ 74878792,
+ 75406881,
+ 75911667,
+ 76392556,
+ 76848948,
+ 77280249,
+ 77685868,
+ 78065214,
+ 78417699,
+ 78742738,
+ 79039752,
+ 79308162,
+ 79547397,
+ 79756886,
+ 79936067,
+ 80084379,
+ 80201270,
+ 80286192,
+ 80338605,
+ 80357971,
+ 80343762,
+ 80295457,
+ 80212542,
+ 80094512,
+ 79940868,
+ 79751121,
+ 79524791,
+ 79261405,
+ 78960502,
+ 78621632,
+ 78244350,
+ 77828229,
+ 77372847,
+ 76877794,
+ 76342676,
+ 75767107,
+ 75150714,
+ 74493138,
+ 73794033,
+ 73053066,
+ 72269916,
+ 71444279,
+ 70575865,
+ 69664397,
+ 68709616,
+ 67711275,
+ 66669145,
+ 65583014,
+ 64452685,
+ 63277978,
+ 62058729,
+ 60794796,
+ 59486048,
+ 58132379,
+ 56733697,
+ 55289928,
+ 53801019,
+ 52266939,
+ 50687671,
+ 49063221,
+ 47393614,
+ 45678896,
+ 43919136,
+ 42114418,
+ 40264855,
+ 38370572,
+ 36431725,
+ 34448485,
+ 32421050,
+ 30349637,
+ 28234486,
+ 26075861,
+ 23874049,
+ 21629360,
+ 19342126,
+ 17012702,
+ 14641471,
+ 12228834,
+ 9775221,
+ 7281083,
+ 4746896,
+ 2173162,
+ -439597,
+ -3090828,
+ -5779958,
+ -8506390,
+ -11269497,
+ -14068632,
+ -16903121,
+ -19772266,
+ -22675342,
+ -25611601,
+ -28580268,
+ -31580547,
+ -34611611,
+ -37672614,
+ -40762679,
+ -43880909,
+ -47026380,
+ -50198144,
+ -53395225,
+ -56616629,
+ -59861330,
+ -63128282,
+ -66416414,
+ -69724631,
+ -73051811,
+ -76396813,
+ -79758468,
+ -83135586,
+ -86526952,
+ -89931330,
+ -93347459,
+ -96774055,
+ -100209815,
+ -103653409,
+ -107103489,
+ -110558683,
+ -114017598,
+ -117478823,
+ -120940920,
+ -124402436,
+ -127861896,
+ -131317806,
+ -134768651,
+ -138212900,
+ -141648998,
+ -145075378,
+ -148490452,
+ -151892614,
+ -155280244,
+ -158651702,
+ -162005334,
+ -165339471,
+ -168652426,
+ -171942501,
+ -175207982,
+ -178447140,
+ -181658237,
+ -184839517,
+ -187989219,
+ -191105563,
+ -194186764,
+ -197231024,
+ -200236533,
+ -203201478,
+ -206124032,
+ -209002362,
+ -211834629,
+ -214618986,
+ -217353579,
+ -220036550,
+ -222666036,
+ -225240169,
+ -227757080,
+ -230214895,
+ -232611738,
+ -234945733,
+ -237215003,
+ -239417669,
+ -241551856,
+ -243615688,
+ -245607294,
+ -247524801,
+ -249366345,
+ -251130064,
+ -252814099,
+ -254416602,
+ -255935727,
+ -257369639,
+ -258716508,
+ -259974513,
+ -261141847,
+ -262216708,
+ -263197308,
+ -264081873,
+ -264868637,
+ -265555850,
+ -266141778,
+ -266624699,
+ -267002910,
+ -267274721,
+ -267438463,
+ -267492483,
+ -267435147,
+ -267264843,
+ -266979977,
+ -266578977,
+ -266060294,
+ -265422402,
+ -264663797,
+ -263783000,
+ -262778558,
+ -261649043,
+ -260393054,
+ -259009218,
+ -257496188,
+ -255852647,
+ -254077310,
+ -252168920,
+ -250126248,
+ -247948104,
+ -245633323,
+ -243180778,
+ -240589374,
+ -237858051,
+ -234985783,
+ -231971581,
+ -228814491,
+ -225513601,
+ -222068028,
+ -218476935,
+ -214739521,
+ -210855024,
+ -206822722,
+ -202641937,
+ -198312028,
+ -193832400,
+ -189202494,
+ -184421801,
+ -179489851,
+ -174406220,
+ -169170528,
+ -163782439,
+ -158241662,
+ -152547953,
+ -146701115,
+ -140700995,
+ -134547489,
+ -128240539,
+ -121780136,
+ -115166319,
+ -108399175,
+ -101478840,
+ -94405498,
+ -87179383,
+ -79800781,
+ -72270024,
+ -64587495,
+ -56753629,
+ -48768910,
+ -40633874,
+ -32349109,
+ -23915247,
+ -15332980,
+ -6603046,
+ 2273764,
+ 11296608,
+ 20464593,
+ 29776774,
+ 39232156,
+ 48829690,
+ 58568278,
+ 68446769,
+ 78463961,
+ 88618604,
+ 98909392,
+ 109334971,
+ 119893935,
+ 130584829,
+ 141406148,
+ 152356333,
+ 163433779,
+ 174636828,
+ 185963778,
+ 197412872,
+ 208982307,
+ 220670230,
+ 232474744,
+ 244393897,
+ 256425699,
+ 268568104,
+ 280819025,
+ 293176327,
+ 305637831,
+ 318201312,
+ 330864498,
+ 343625078,
+ 356480693,
+ 369428944,
+ 382467388,
+ 395593540,
+ 408804877,
+ 422098832,
+ 435472799,
+ 448924135,
+ 462450157,
+ 476048143,
+ 489715337,
+ 503448946,
+ 517246138,
+ 531104052,
+ 545019789,
+ 558990419,
+ 573012979,
+ 587084475,
+ 601201882,
+ 615362147,
+ 629562186,
+ 643798888,
+ 658069116,
+ 672369707,
+ 686697471,
+ 701049197,
+ 715421648,
+ 729811567,
+ 744215675,
+ 758630674,
+ 773053244,
+ 787480051,
+ 801907741,
+ 816332944,
+ 830752279,
+ 845162347,
+ 859559737,
+ 873941027,
+ 888302786,
+ 902641572,
+ 916953933,
+ 931236413,
+ 945485549,
+ 959697871,
+ 973869907,
+ 987998183,
+ 1002079222,
+ 1016109546,
+ 1030085680,
+ 1044004151,
+ 1057861485,
+ 1071654216,
+ 1085378883,
+ 1099032031,
+ 1112610213,
+ 1126109990,
+ 1139527933,
+ 1152860627,
+ 1166104665,
+ 1179256658,
+ 1192313227,
+ 1205271013,
+ 1218126672,
+ 1230876878,
+ 1243518325,
+ 1256047727,
+ 1268461820,
+ 1280757364,
+ 1292931139,
+ 1304979953,
+ 1316900639,
+ 1328690059,
+ 1340345100,
+ 1351862682,
+ 1363239753,
+ 1374473291,
+ 1385560311,
+ 1396497859,
+ 1407283015,
+ 1417912897,
+ 1428384658,
+ 1438695487,
+ 1448842617,
+ 1458823316,
+ 1468634895,
+ 1478274705,
+ 1487740141,
+ 1497028641,
+ 1506137687,
+ 1515064808,
+ 1523807576,
+ 1532363614,
+ 1540730591,
+ 1548906224,
+ 1556888280,
+ 1564674578,
+ 1572262987,
+ 1579651427,
+ 1586837873,
+ 1593820351,
+ 1600596943,
+ 1607165785,
+ 1613525070,
+ 1619673043,
+ 1625608011,
+ 1631328336,
+ 1636832437,
+ 1642118794,
+ 1647185945,
+ 1652032487,
+ 1656657078,
+ 1661058437,
+ 1665235343,
+ 1669186637,
+ 1672911223,
+ 1676408067,
+ 1679676197,
+ 1682714705,
+ 1685522746,
+ 1688099540,
+ 1690444367,
+ 1692556578,
+ 1694435582,
+ 1696080858,
+ 1697491948,
+ 1698668456,
+ 1699610057,
+ 1700316486,
+ 1700787550,
+ 1701023114,
+ 1701023114,
+ 1700787550,
+ 1700316486,
+ 1699610057,
+ 1698668456,
+ 1697491948,
+ 1696080858,
+ 1694435582,
+ 1692556578,
+ 1690444367,
+ 1688099540,
+ 1685522746,
+ 1682714705,
+ 1679676197,
+ 1676408067,
+ 1672911223,
+ 1669186637,
+ 1665235343,
+ 1661058437,
+ 1656657078,
+ 1652032487,
+ 1647185945,
+ 1642118794,
+ 1636832437,
+ 1631328336,
+ 1625608011,
+ 1619673043,
+ 1613525070,
+ 1607165785,
+ 1600596943,
+ 1593820351,
+ 1586837873,
+ 1579651427,
+ 1572262987,
+ 1564674578,
+ 1556888280,
+ 1548906224,
+ 1540730591,
+ 1532363614,
+ 1523807576,
+ 1515064808,
+ 1506137687,
+ 1497028641,
+ 1487740141,
+ 1478274705,
+ 1468634895,
+ 1458823316,
+ 1448842617,
+ 1438695487,
+ 1428384658,
+ 1417912897,
+ 1407283015,
+ 1396497859,
+ 1385560311,
+ 1374473291,
+ 1363239753,
+ 1351862682,
+ 1340345100,
+ 1328690059,
+ 1316900639,
+ 1304979953,
+ 1292931139,
+ 1280757364,
+ 1268461820,
+ 1256047727,
+ 1243518325,
+ 1230876878,
+ 1218126672,
+ 1205271013,
+ 1192313227,
+ 1179256658,
+ 1166104665,
+ 1152860627,
+ 1139527933,
+ 1126109990,
+ 1112610213,
+ 1099032031,
+ 1085378883,
+ 1071654216,
+ 1057861485,
+ 1044004151,
+ 1030085680,
+ 1016109546,
+ 1002079222,
+ 987998183,
+ 973869907,
+ 959697871,
+ 945485549,
+ 931236413,
+ 916953933,
+ 902641572,
+ 888302786,
+ 873941027,
+ 859559737,
+ 845162347,
+ 830752279,
+ 816332944,
+ 801907741,
+ 787480051,
+ 773053244,
+ 758630674,
+ 744215675,
+ 729811567,
+ 715421648,
+ 701049197,
+ 686697471,
+ 672369707,
+ 658069116,
+ 643798888,
+ 629562186,
+ 615362147,
+ 601201882,
+ 587084475,
+ 573012979,
+ 558990419,
+ 545019789,
+ 531104052,
+ 517246138,
+ 503448946,
+ 489715337,
+ 476048143,
+ 462450157,
+ 448924135,
+ 435472799,
+ 422098832,
+ 408804877,
+ 395593540,
+ 382467388,
+ 369428944,
+ 356480693,
+ 343625078,
+ 330864498,
+ 318201312,
+ 305637831,
+ 293176327,
+ 280819025,
+ 268568104,
+ 256425699,
+ 244393897,
+ 232474744,
+ 220670230,
+ 208982307,
+ 197412872,
+ 185963778,
+ 174636828,
+ 163433779,
+ 152356333,
+ 141406148,
+ 130584829,
+ 119893935,
+ 109334971,
+ 98909392,
+ 88618604,
+ 78463961,
+ 68446769,
+ 58568278,
+ 48829690,
+ 39232156,
+ 29776774,
+ 20464593,
+ 11296608,
+ 2273764,
+ -6603046,
+ -15332980,
+ -23915247,
+ -32349109,
+ -40633874,
+ -48768910,
+ -56753629,
+ -64587495,
+ -72270024,
+ -79800781,
+ -87179383,
+ -94405498,
+ -101478840,
+ -108399175,
+ -115166319,
+ -121780136,
+ -128240539,
+ -134547489,
+ -140700995,
+ -146701115,
+ -152547953,
+ -158241662,
+ -163782439,
+ -169170528,
+ -174406220,
+ -179489851,
+ -184421801,
+ -189202494,
+ -193832400,
+ -198312028,
+ -202641937,
+ -206822722,
+ -210855024,
+ -214739521,
+ -218476935,
+ -222068028,
+ -225513601,
+ -228814491,
+ -231971581,
+ -234985783,
+ -237858051,
+ -240589374,
+ -243180778,
+ -245633323,
+ -247948104,
+ -250126248,
+ -252168920,
+ -254077310,
+ -255852647,
+ -257496188,
+ -259009218,
+ -260393054,
+ -261649043,
+ -262778558,
+ -263783000,
+ -264663797,
+ -265422402,
+ -266060294,
+ -266578977,
+ -266979977,
+ -267264843,
+ -267435147,
+ -267492483,
+ -267438463,
+ -267274721,
+ -267002910,
+ -266624699,
+ -266141778,
+ -265555850,
+ -264868637,
+ -264081873,
+ -263197308,
+ -262216708,
+ -261141847,
+ -259974513,
+ -258716508,
+ -257369639,
+ -255935727,
+ -254416602,
+ -252814099,
+ -251130064,
+ -249366345,
+ -247524801,
+ -245607294,
+ -243615688,
+ -241551856,
+ -239417669,
+ -237215003,
+ -234945733,
+ -232611738,
+ -230214895,
+ -227757080,
+ -225240169,
+ -222666036,
+ -220036550,
+ -217353579,
+ -214618986,
+ -211834629,
+ -209002362,
+ -206124032,
+ -203201478,
+ -200236533,
+ -197231024,
+ -194186764,
+ -191105563,
+ -187989219,
+ -184839517,
+ -181658237,
+ -178447140,
+ -175207982,
+ -171942501,
+ -168652426,
+ -165339471,
+ -162005334,
+ -158651702,
+ -155280244,
+ -151892614,
+ -148490452,
+ -145075378,
+ -141648998,
+ -138212900,
+ -134768651,
+ -131317806,
+ -127861896,
+ -124402436,
+ -120940920,
+ -117478823,
+ -114017598,
+ -110558683,
+ -107103489,
+ -103653409,
+ -100209815,
+ -96774055,
+ -93347459,
+ -89931330,
+ -86526952,
+ -83135586,
+ -79758468,
+ -76396813,
+ -73051811,
+ -69724631,
+ -66416414,
+ -63128282,
+ -59861330,
+ -56616629,
+ -53395225,
+ -50198144,
+ -47026380,
+ -43880909,
+ -40762679,
+ -37672614,
+ -34611611,
+ -31580547,
+ -28580268,
+ -25611601,
+ -22675342,
+ -19772266,
+ -16903121,
+ -14068632,
+ -11269497,
+ -8506390,
+ -5779958,
+ -3090828,
+ -439597,
+ 2173162,
+ 4746896,
+ 7281083,
+ 9775221,
+ 12228834,
+ 14641471,
+ 17012702,
+ 19342126,
+ 21629360,
+ 23874049,
+ 26075861,
+ 28234486,
+ 30349637,
+ 32421050,
+ 34448485,
+ 36431725,
+ 38370572,
+ 40264855,
+ 42114418,
+ 43919136,
+ 45678896,
+ 47393614,
+ 49063221,
+ 50687671,
+ 52266939,
+ 53801019,
+ 55289928,
+ 56733697,
+ 58132379,
+ 59486048,
+ 60794796,
+ 62058729,
+ 63277978,
+ 64452685,
+ 65583014,
+ 66669145,
+ 67711275,
+ 68709616,
+ 69664397,
+ 70575865,
+ 71444279,
+ 72269916,
+ 73053066,
+ 73794033,
+ 74493138,
+ 75150714,
+ 75767107,
+ 76342676,
+ 76877794,
+ 77372847,
+ 77828229,
+ 78244350,
+ 78621632,
+ 78960502,
+ 79261405,
+ 79524791,
+ 79751121,
+ 79940868,
+ 80094512,
+ 80212542,
+ 80295457,
+ 80343762,
+ 80357971,
+ 80338605,
+ 80286192,
+ 80201270,
+ 80084379,
+ 79936067,
+ 79756886,
+ 79547397,
+ 79308162,
+ 79039752,
+ 78742738,
+ 78417699,
+ 78065214,
+ 77685868,
+ 77280249,
+ 76848948,
+ 76392556,
+ 75911667,
+ 75406881,
+ 74878792,
+ 74328003,
+ 73755113,
+ 73160722,
+ 72545433,
+ 71909846,
+ 71254564,
+ 70580186,
+ 69887313,
+ 69176543,
+ 68448475,
+ 67703704,
+ 66942824,
+ 66166428,
+ 65375106,
+ 64569446,
+ 63750030,
+ 62917443,
+ 62072260,
+ 61215058,
+ 60346407,
+ 59466875,
+ 58577025,
+ 57677415,
+ 56768601,
+ 55851131,
+ 54925550,
+ 53992399,
+ 53052211,
+ 52105515,
+ 51152836,
+ 50194690,
+ 49231589,
+ 48264040,
+ 47292541,
+ 46317586,
+ 45339662,
+ 44359249,
+ 43376821,
+ 42392843,
+ 41407776,
+ 40422071,
+ 39436175,
+ 38450527,
+ 37465555,
+ 36481685,
+ 35499331,
+ 34518902,
+ 33540798,
+ 32565412,
+ 31593129,
+ 30624326,
+ 29659373,
+ 28698630,
+ 27742450,
+ 26791179,
+ 25845154,
+ 24904703,
+ 23970147,
+ 23041799,
+ 22119963,
+ 21204936,
+ 20297004,
+ 19396448,
+ 18503540,
+ 17618542,
+ 16741710,
+ 15873290,
+ 15013522,
+ 14162636,
+ 13320854,
+ 12488390,
+ 11665452,
+ 10852237,
+ 10048935,
+ 9255728,
+ 8472792,
+ 7700292,
+ 6938387,
+ 6187229,
+ 5446959,
+ 4717715,
+ 3999622,
+ 3292804,
+ 2597372,
+ 1913433,
+ 1241083,
+ 580415,
+ -68486,
+ -705546,
+ -1330692,
+ -1943863,
+ -2545001,
+ -3134059,
+ -3710990,
+ -4275761,
+ -4828341,
+ -5368705,
+ -5896837,
+ -6412725,
+ -6916364,
+ -7407754,
+ -7886901,
+ -8353820,
+ -8808525,
+ -9251042,
+ -9681397,
+ -10099626,
+ -10505769,
+ -10899866,
+ -11281971,
+ -11652134,
+ -12010417,
+ -12356880,
+ -12691592,
+ -13014625,
+ -13326057,
+ -13625965,
+ -13914437,
+ -14191560,
+ -14457426,
+ -14712131,
+ -14955775,
+ -15188460,
+ -15410293,
+ -15621384,
+ -15821844,
+ -16011790,
+ -16191339,
+ -16360615,
+ -16519739,
+ -16668838,
+ -16808042,
+ -16937482,
+ -17057290,
+ -17167602,
+ -17268557,
+ -17360293,
+ -17442951,
+ -17516674,
+ -17581607,
+ -17637895,
+ -17685686,
+ -17725127,
+ -17756370,
+ -17779564,
+ -17794860,
+ -17802413,
+ -17802374,
+ -17794898,
+ -17780139,
+ -17758253,
+ -17729395,
+ -17693721,
+ -17651386,
+ -17602548,
+ -17547361,
+ -17485983,
+ -17418570,
+ -17345276,
+ -17266260,
+ -17181675,
+ -17091677,
+ -16996420,
+ -16896057,
+ -16790743,
+ -16680631,
+ -16565872,
+ -16446616,
+ -16323015,
+ -16195217,
+ -16063371,
+ -15927624,
+ -15788123,
+ -15645011,
+ -15498434,
+ -15348533,
+ -15195449,
+ -15039324,
+ -14880294,
+ -14718496,
+ -14554066,
+ -14387139,
+ -14217846,
+ -14046319,
+ -13872685,
+ -13697073,
+ -13519608,
+ -13340414,
+ -13159614,
+ -12977327,
+ -12793673,
+ -12608767,
+ -12422724,
+ -12235658,
+ -12047679,
+ -11858897,
+ -11669418,
+ -11479348,
+ -11288789,
+ -11097842,
+ -10906607,
+ -10715182,
+ -10523660,
+ -10332135,
+ -10140696,
+ -9949435,
+ -9758437,
+ -9567787,
+ -9377567,
+ -9187859,
+ -8998740,
+ -8810288,
+ -8622577,
+ -8435679,
+ -8249665,
+ -8064602,
+ -7880559,
+ -7697597,
+ -7515780,
+ -7335167,
+ -7155819,
+ -6977789,
+ -6801133,
+ -6625903,
+ -6452150,
+ -6279922,
+ -6109265,
+ -5940225,
+ -5772842,
+ -5607161,
+ -5443218,
+ -5281052,
+ -5120698,
+ -4962189,
+ -4805558,
+ -4650835,
+ -4498046,
+ -4347223,
+ -4198387,
+ -4051563,
+ -3906773,
+ -3764038,
+ -3623375,
+ -3484803,
+ -3348336,
+ -3213990,
+ -3081776,
+ -2951706,
+ -2823791,
+ -2698038,
+ -2574456,
+ -2453049,
+ -2333823,
+ -2216780,
+ -2101924,
+ -1989253,
+ -1878769,
+ -1770470,
+ -1664353,
+ -1560414,
+ -1458649,
+ -1359052,
+ -1261615,
+ -1166332,
+ -1073194,
+ -982189,
+ -893309,
+ -806541,
+ -721872,
+ -639291,
+ -558783,
+ -480333,
+ -403926,
+ -329544,
+ -257173,
+ -186793,
+ -118387,
+ -51937,
+ 12577,
+ 75177,
+ 135881,
+ 194710,
+ 251686,
+ 306832,
+ 360168,
+ 411719,
+ 461506,
+ 509555,
+ 555887,
+ 600528,
+ 643502,
+ 684833,
+ 724548,
+ 762671,
+ 799225,
+ 834239,
+ 867737,
+ 899746,
+ 930292,
+ 959400,
+ 987096,
+ 1013408,
+ 1038361,
+ 1061981,
+ 1084297,
+ 1105333,
+ 1125116,
+ 1143673,
+ 1161030,
+ 1177213,
+ 1192249,
+ 1206163,
+ 1218982,
+ 1230732,
+ 1241438,
+ 1251128,
+ 1259825,
+ 1267555,
+ 1274343,
+ 1280216,
+ 1285197,
+ 1289310,
+ 1292582,
+ 1295037,
+ 1296696,
+ 1297585,
+ 1297728,
+ 1297147,
+ 1295866,
+ 1293907,
+ 1291293,
+ 1288047,
+ 1284189,
+ 1279742,
+ 1274727,
+ 1269166,
+ 1263078,
+ 1256484,
+ 1249405,
+ 1241861,
+ 1233870,
+ 1225451,
+ 1216625,
+ 1207409,
+ 1197822,
+ 1187882,
+ 1177604,
+ 1167009,
+ 1156111,
+ 1144927,
+ 1133474,
+ 1121768,
+ 1109823,
+ 1097656,
+ 1085281,
+ 1072712,
+ 1059964,
+ 1047050,
+ 1033984,
+ 1020778,
+ 1007448,
+ 994002,
+ 980456,
+ 966820,
+ 953105,
+ 939324,
+ 925487,
+ 911603,
+ 897684,
+ 883740,
+ 869780,
+ 855813,
+ 841849,
+ 827895,
+ 813962,
+ 800056,
+ 786185,
+ 772357,
+ 758580,
+ 744859,
+ 731203,
+ 717617,
+ 704107,
+ 690681,
+ 677342,
+ 664096,
+ 650949,
+ 637906,
+ 624971,
+ 612150,
+ 599445,
+ 586861,
+ 574401,
+ 562070,
+ 549871,
+ 537807,
+ 525880,
+ 514093,
+ 502450,
+ 490952,
+ 479601,
+ 468400,
+ 457350,
+ 446454,
+ 435712,
+ 425125,
+ 414697,
+ 404426,
+ 394313,
+ 384361,
+ 374568,
+ 364937,
+ 355466,
+ 346156,
+ 337009,
+ 328022,
+ 319195,
+ 310531,
+ 302027,
+ 293682,
+ 285496,
+ 277470,
+ 269602,
+ 261891,
+ 254335,
+ 246936,
+ 239690,
+ 232598,
+ 225657,
+ 218867,
+ 212226,
+ 205733,
+ 199385,
+ 193184,
+ 187125,
+ 181208,
+ 175431,
+ 169792,
+ 164291,
+ 158923,
+ 153688,
+ 148585,
+ 143612,
+ 138766,
+ 134046,
+ 129448,
+ 124974,
+ 120618,
+ 116381,
+ 112260,
+ 108252,
+ 104356,
+ 100570,
+ 96892,
+ 93320,
+ 89852,
+ 86485,
+ 83220,
+ 80051,
+ 76978,
+ 74000,
+ 71113,
+ 68316,
+ 65607,
+ 62985,
+ 60446,
+ 57990,
+ 55614,
+ 53317,
+ 51096,
+ 48950,
+ 46877,
+ 44875,
+ 42943,
+ 41078,
+ 39279,
+ 37544,
+ 35871,
+ 34260,
+ 32707,
+ 31212,
+ 29772,
+ 28388,
+ 27055,
+ 25774,
+ 24543,
+ 23360,
+ 22224,
+ 21133,
+ 20086,
+ 19082,
+ 18119,
+ 17196,
+ 16312,
+ 15466,
+ 14654,
+ 13879,
+ 13138,
+ 12429,
+ 11751,
+ 11104,
+ 10487,
+ 9897,
+ 9335,
+ 8799,
+ 8289,
+ 7802,
+ 7340,
+ 6900,
+ 6483,
+ 6085,
+ 5707,
+ 5350,
+ 5010,
+ 4688,
+ 4383,
+ 4094,
+ 3821,
+ 3563,
+ 3319,
+ 3089,
+ 2872,
+ 2667,
+ 2475,
+ 2293,
+ 2122,
+ 1961,
+ 1811,
+ 1669,
+ 1537,
+ 1413,
+ 1297,
+ 1189,
+ 1088,
+ 993,
+ 905,
+ 824,
+ 748,
+ 678,
+ 612,
+ 551,
+ 497,
+ 445,
+ 398,
+ 354,
+ 314,
+ 278,
+ 244,
+ 213,
+ 186,
+ 160,
+ 506
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.sfp
new file mode 100644
index 0000000..7a79b6e
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/ADFir.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BL.dat
new file mode 100644
index 0000000..d87e46e
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BL.dat
@@ -0,0 +1,146 @@
+ 4084,
+ 22854,
+ 52180,
+ 39395,
+ -78621,
+ -243300,
+ -252701,
+ -27685,
+ 159757,
+ 11667,
+ -247746,
+ -115683,
+ 280119,
+ 215393,
+ -331173,
+ -372062,
+ 355638,
+ 570150,
+ -353372,
+ -821087,
+ 305094,
+ 1124112,
+ -195835,
+ -1480384,
+ 5655,
+ 1886268,
+ 286062,
+ -2335369,
+ -701573,
+ 2817885,
+ 1264995,
+ -3319400,
+ -2001423,
+ 3820542,
+ 2936209,
+ -4297256,
+ -4095319,
+ 4720234,
+ 5505636,
+ -5053395,
+ -7193471,
+ 5255380,
+ 9187349,
+ -5276420,
+ -11516938,
+ 5058910,
+ 14216600,
+ -4533971,
+ -17327743,
+ 3618612,
+ 20905173,
+ -2208339,
+ -25024691,
+ 168320,
+ 29801046,
+ 2688694,
+ -35412940,
+ -6636421,
+ 42156519,
+ 12107736,
+ -50551264,
+ -19850848,
+ 61576623,
+ 31301922,
+ -77293704,
+ -49656486,
+ 102809719,
+ 83785579,
+ -154988931,
+ -170966127,
+ 340824123,
+ 945102387,
+ 945102387,
+ 340824123,
+ -170966127,
+ -154988931,
+ 83785579,
+ 102809719,
+ -49656486,
+ -77293704,
+ 31301922,
+ 61576623,
+ -19850848,
+ -50551264,
+ 12107736,
+ 42156519,
+ -6636421,
+ -35412940,
+ 2688694,
+ 29801046,
+ 168320,
+ -25024691,
+ -2208339,
+ 20905173,
+ 3618612,
+ -17327743,
+ -4533971,
+ 14216600,
+ 5058910,
+ -11516938,
+ -5276420,
+ 9187349,
+ 5255380,
+ -7193471,
+ -5053395,
+ 5505636,
+ 4720234,
+ -4095319,
+ -4297256,
+ 2936209,
+ 3820542,
+ -2001423,
+ -3319400,
+ 1264995,
+ 2817885,
+ -701573,
+ -2335369,
+ 286062,
+ 1886268,
+ 5655,
+ -1480384,
+ -195835,
+ 1124112,
+ 305094,
+ -821087,
+ -353372,
+ 570150,
+ 355638,
+ -372062,
+ -331173,
+ 215393,
+ 280119,
+ -115683,
+ -247746,
+ 11667,
+ 159757,
+ -27685,
+ -252701,
+ -243300,
+ -78621,
+ 39395,
+ 52180,
+ 22854,
+ 4084
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BL.sfp
new file mode 100644
index 0000000..8529d1a
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BL.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.dat
new file mode 100644
index 0000000..2f91019
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.dat
@@ -0,0 +1,98 @@
+ -1116,
+ -20768,
+ -104458,
+ -248303,
+ -275463,
+ -517,
+ 313401,
+ 100873,
+ -444328,
+ -261412,
+ 638927,
+ 522376,
+ -898040,
+ -916504,
+ 1235729,
+ 1482958,
+ -1673249,
+ -2266617,
+ 2241974,
+ 3321802,
+ -2981022,
+ -4708347,
+ 3943706,
+ 6495294,
+ -5199982,
+ -8763339,
+ 6840942,
+ 11608771,
+ -8987996,
+ -15153857,
+ 11806332,
+ 19564828,
+ -15531025,
+ -25088630,
+ 20515206,
+ 32124100,
+ -27333207,
+ -41377896,
+ 37016239,
+ 54241657,
+ -51667556,
+ -73862022,
+ 76427490,
+ 109062105,
+ -128180346,
+ -197073282,
+ 313925811,
+ 971760226,
+ 971760226,
+ 313925811,
+ -197073282,
+ -128180346,
+ 109062105,
+ 76427490,
+ -73862022,
+ -51667556,
+ 54241657,
+ 37016239,
+ -41377896,
+ -27333207,
+ 32124100,
+ 20515206,
+ -25088630,
+ -15531025,
+ 19564828,
+ 11806332,
+ -15153857,
+ -8987996,
+ 11608771,
+ 6840942,
+ -8763339,
+ -5199982,
+ 6495294,
+ 3943706,
+ -4708347,
+ -2981022,
+ 3321802,
+ 2241974,
+ -2266617,
+ -1673249,
+ 1482958,
+ 1235729,
+ -916504,
+ -898040,
+ 522376,
+ 638927,
+ -261412,
+ -444328,
+ 100873,
+ 313401,
+ -517,
+ -275463,
+ -248303,
+ -104458,
+ -20768,
+ -1116
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.sfp
new file mode 100644
index 0000000..c7d59fa
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BL17696.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.dat
new file mode 100644
index 0000000..cc92116
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.dat
@@ -0,0 +1,98 @@
+ -4640,
+ -34592,
+ -121751,
+ -254869,
+ -313637,
+ -134691,
+ 239142,
+ 417864,
+ 33073,
+ -610782,
+ -592854,
+ 424259,
+ 1254482,
+ 387093,
+ -1549232,
+ -1767412,
+ 898346,
+ 3193330,
+ 1060101,
+ -3707010,
+ -4085364,
+ 2245933,
+ 7100189,
+ 1781838,
+ -8316244,
+ -7885369,
+ 5811025,
+ 14144323,
+ 1540792,
+ -17417378,
+ -13097038,
+ 14213948,
+ 25861528,
+ -2068523,
+ -34636747,
+ -18994046,
+ 33014731,
+ 45418698,
+ -14897433,
+ -69833343,
+ -24246447,
+ 81197067,
+ 88042240,
+ -62959570,
+ -187744689,
+ -27366363,
+ 421762203,
+ 824686499,
+ 824686499,
+ 421762203,
+ -27366363,
+ -187744689,
+ -62959570,
+ 88042240,
+ 81197067,
+ -24246447,
+ -69833343,
+ -14897433,
+ 45418698,
+ 33014731,
+ -18994046,
+ -34636747,
+ -2068523,
+ 25861528,
+ 14213948,
+ -13097038,
+ -17417378,
+ 1540792,
+ 14144323,
+ 5811025,
+ -7885369,
+ -8316244,
+ 1781838,
+ 7100189,
+ 2245933,
+ -4085364,
+ -3707010,
+ 1060101,
+ 3193330,
+ 898346,
+ -1767412,
+ -1549232,
+ 387093,
+ 1254482,
+ 424259,
+ -592854,
+ -610782,
+ 33073,
+ 417864,
+ 239142,
+ -134691,
+ -313637,
+ -254869,
+ -121751,
+ -34592,
+ -4640
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.sfp
new file mode 100644
index 0000000..49eab33
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BL19288.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.dat
new file mode 100644
index 0000000..a2ce053
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.dat
@@ -0,0 +1,146 @@
+ -3371,
+ -23147,
+ -67489,
+ -98347,
+ -48040,
+ 55732,
+ 61843,
+ -59368,
+ -83604,
+ 80269,
+ 117021,
+ -116524,
+ -161351,
+ 173357,
+ 215114,
+ -258975,
+ -274765,
+ 383632,
+ 333325,
+ -558903,
+ -379076,
+ 796406,
+ 394137,
+ -1106167,
+ -353540,
+ 1494189,
+ 224761,
+ -1959370,
+ 32035,
+ 2490139,
+ -462424,
+ -3060647,
+ 1115040,
+ 3627213,
+ -2037489,
+ -4125577,
+ 3270536,
+ 4468781,
+ -4841632,
+ -4547239,
+ 6756938,
+ 4230085,
+ -8993432,
+ -3368677,
+ 11491190,
+ 1801903,
+ -14146348,
+ 637685,
+ 16805536,
+ -4117397,
+ -19260951,
+ 8800097,
+ 21245130,
+ -14845672,
+ -22423974,
+ 22421816,
+ 22380809,
+ -31733886,
+ -20577514,
+ 43096164,
+ 16266176,
+ -57087587,
+ -8265439,
+ 74934568,
+ -5642436,
+ -99589690,
+ 30666724,
+ 139664897,
+ -83708462,
+ -232177217,
+ 271728844,
+ 1010788127,
+ 1010788127,
+ 271728844,
+ -232177217,
+ -83708462,
+ 139664897,
+ 30666724,
+ -99589690,
+ -5642436,
+ 74934568,
+ -8265439,
+ -57087587,
+ 16266176,
+ 43096164,
+ -20577514,
+ -31733886,
+ 22380809,
+ 22421816,
+ -22423974,
+ -14845672,
+ 21245130,
+ 8800097,
+ -19260951,
+ -4117397,
+ 16805536,
+ 637685,
+ -14146348,
+ 1801903,
+ 11491190,
+ -3368677,
+ -8993432,
+ 4230085,
+ 6756938,
+ -4547239,
+ -4841632,
+ 4468781,
+ 3270536,
+ -4125577,
+ -2037489,
+ 3627213,
+ 1115040,
+ -3060647,
+ -462424,
+ 2490139,
+ 32035,
+ -1959370,
+ 224761,
+ 1494189,
+ -353540,
+ -1106167,
+ 394137,
+ 796406,
+ -379076,
+ -558903,
+ 333325,
+ 383632,
+ -274765,
+ -258975,
+ 215114,
+ 173357,
+ -161351,
+ -116524,
+ 117021,
+ 80269,
+ -83604,
+ -59368,
+ 61843,
+ 55732,
+ -48040,
+ -98347,
+ -67489,
+ -23147,
+ -3371
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.sfp
new file mode 100644
index 0000000..5629c2c
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BL8848.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.dat
new file mode 100644
index 0000000..2ac8f70
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.dat
@@ -0,0 +1,162 @@
+ -182,
+ 2541,
+ 21604,
+ 76263,
+ 158552,
+ 201429,
+ 122823,
+ -52649,
+ -153225,
+ -42344,
+ 151551,
+ 137241,
+ -116676,
+ -241038,
+ 23778,
+ 328559,
+ 137876,
+ -360612,
+ -359013,
+ 293813,
+ 605744,
+ -92831,
+ -820191,
+ -257032,
+ 926283,
+ 738007,
+ -841538,
+ -1291253,
+ 495016,
+ 1815656,
+ 152096,
+ -2175356,
+ -1086370,
+ 2216856,
+ 2226211,
+ -1795782,
+ -3415630,
+ 809723,
+ 4431102,
+ 767753,
+ -5003215,
+ -2857478,
+ 4853401,
+ 5256558,
+ -3742344,
+ -7637657,
+ 1524060,
+ 9569304,
+ 1801934,
+ -10558602,
+ -6049456,
+ 10113676,
+ 10823878,
+ -7819779,
+ -15526072,
+ 3420042,
+ 19385007,
+ 3109929,
+ -21517134,
+ -11504032,
+ 21005609,
+ 21172359,
+ -16986719,
+ -31195443,
+ 8724792,
+ 40339589,
+ 4350821,
+ -47071161,
+ -22689723,
+ 49513585,
+ 46835166,
+ -45196886,
+ -78062802,
+ 30110657,
+ 120411583,
+ 5112556,
+ -189494034,
+ -97857932,
+ 390995800,
+ 881725504,
+ 881725504,
+ 390995800,
+ -97857932,
+ -189494034,
+ 5112556,
+ 120411583,
+ 30110657,
+ -78062802,
+ -45196886,
+ 46835166,
+ 49513585,
+ -22689723,
+ -47071161,
+ 4350821,
+ 40339589,
+ 8724792,
+ -31195443,
+ -16986719,
+ 21172359,
+ 21005609,
+ -11504032,
+ -21517134,
+ 3109929,
+ 19385007,
+ 3420042,
+ -15526072,
+ -7819779,
+ 10823878,
+ 10113676,
+ -6049456,
+ -10558602,
+ 1801934,
+ 9569304,
+ 1524060,
+ -7637657,
+ -3742344,
+ 5256558,
+ 4853401,
+ -2857478,
+ -5003215,
+ 767753,
+ 4431102,
+ 809723,
+ -3415630,
+ -1795782,
+ 2226211,
+ 2216856,
+ -1086370,
+ -2175356,
+ 152096,
+ 1815656,
+ 495016,
+ -1291253,
+ -841538,
+ 738007,
+ 926283,
+ -257032,
+ -820191,
+ -92831,
+ 605744,
+ 293813,
+ -359013,
+ -360612,
+ 137876,
+ 328559,
+ 23778,
+ -241038,
+ -116676,
+ 137241,
+ 151551,
+ -42344,
+ -153225,
+ -52649,
+ 122823,
+ 201429,
+ 158552,
+ 76263,
+ 21604,
+ 2541,
+ -182
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.sfp
new file mode 100644
index 0000000..efcbd7a
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BL9644.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.dat
new file mode 100644
index 0000000..5e6b90f
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.dat
@@ -0,0 +1,98 @@
+ -4550,
+ -38311,
+ -141612,
+ -290871,
+ -314152,
+ -39562,
+ 337094,
+ 272407,
+ -333028,
+ -608619,
+ 172958,
+ 1021715,
+ 256946,
+ -1404059,
+ -1034346,
+ 1588318,
+ 2182082,
+ -1354938,
+ -3634693,
+ 458987,
+ 5211564,
+ 1328429,
+ -6603440,
+ -4170432,
+ 7372867,
+ 8106689,
+ -6976767,
+ -13000061,
+ 4806781,
+ 18494516,
+ -239012,
+ -23986537,
+ -7318297,
+ 28609542,
+ 18404878,
+ -31211643,
+ -33557196,
+ 30274750,
+ 53514761,
+ -23630628,
+ -79840849,
+ 7486355,
+ 116927221,
+ 27411231,
+ -180772918,
+ -118444916,
+ 377451192,
+ 899323996,
+ 899323996,
+ 377451192,
+ -118444916,
+ -180772918,
+ 27411231,
+ 116927221,
+ 7486355,
+ -79840849,
+ -23630628,
+ 53514761,
+ 30274750,
+ -33557196,
+ -31211643,
+ 18404878,
+ 28609542,
+ -7318297,
+ -23986537,
+ -239012,
+ 18494516,
+ 4806781,
+ -13000061,
+ -6976767,
+ 8106689,
+ 7372867,
+ -4170432,
+ -6603440,
+ 1328429,
+ 5211564,
+ 458987,
+ -3634693,
+ -1354938,
+ 2182082,
+ 1588318,
+ -1034346,
+ -1404059,
+ 256946,
+ 1021715,
+ 172958,
+ -608619,
+ -333028,
+ 272407,
+ 337094,
+ -39562,
+ -314152,
+ -290871,
+ -141612,
+ -38311,
+ -4550
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.sfp
new file mode 100644
index 0000000..0a724cd
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/BLF.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/DS.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/DS.dat
new file mode 100644
index 0000000..f9dc528
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/DS.dat
@@ -0,0 +1,34 @@
+ -62273,
+ -489260,
+ -1432411,
+ -1194562,
+ 3183049,
+ 8042385,
+ -120909,
+ -21180934,
+ -18230466,
+ 33797847,
+ 65099488,
+ -25831630,
+ -158314967,
+ -54117326,
+ 394835460,
+ 848183659,
+ 848183659,
+ 394835460,
+ -54117326,
+ -158314967,
+ -25831630,
+ 65099488,
+ 33797847,
+ -18230466,
+ -21180934,
+ -120909,
+ 8042385,
+ 3183049,
+ -1194562,
+ -1432411,
+ -489260,
+ -62273
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/DS.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/DS.sfp
new file mode 100644
index 0000000..d2f8a3e
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/DS.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/DS_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/DS_xs3.dat
new file mode 100644
index 0000000..7d1e230
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/DS_xs3.dat
@@ -0,0 +1,34 @@
+ -62273,
+ -1432411,
+ 3183049,
+ -120909,
+ -18230466,
+ 65099488,
+ -158314967,
+ 394835460,
+ -489260,
+ -1194562,
+ 8042385,
+ -21180934,
+ 33797847,
+ -25831630,
+ -54117326,
+ 848183659,
+ 848183659,
+ -54117326,
+ -25831630,
+ 33797847,
+ -21180934,
+ 8042385,
+ -1194562,
+ -489260,
+ 394835460,
+ -158314967,
+ 65099488,
+ -18230466,
+ -120909,
+ 3183049,
+ -1432411,
+ -62273
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.dat
new file mode 100644
index 0000000..71cab1a
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.dat
@@ -0,0 +1,2354 @@
+ -422024,
+ -332048,
+ 12057955,
+ -43792168,
+ 100152771,
+ -169717457,
+ 226051370,
+ 1888913548,
+ 238889399,
+ -173998387,
+ 101475575,
+ -44011177,
+ 11995573,
+ -279574,
+ -432035,
+ 0,
+ -412156,
+ -383164,
+ 12114943,
+ -43559841,
+ 98807925,
+ -165421325,
+ 213329945,
+ 1888676601,
+ 251841986,
+ -178262343,
+ 102775562,
+ -44216595,
+ 11927728,
+ -225736,
+ -442192,
+ 0,
+ -402437,
+ -432934,
+ 12166601,
+ -43314458,
+ 97441805,
+ -161111719,
+ 200727056,
+ 1888202707,
+ 264907100,
+ -182507550,
+ 104051972,
+ -44408163,
+ 11854358,
+ -170525,
+ -452493,
+ 0,
+ -392863,
+ -481365,
+ 12213002,
+ -43056301,
+ 96055185,
+ -156790381,
+ 188244655,
+ 1887491995,
+ 278082663,
+ -186732217,
+ 105304039,
+ -44585610,
+ 11775396,
+ -113935,
+ -462939,
+ 0,
+ -383435,
+ -528467,
+ 12254212,
+ -42785628,
+ 94648808,
+ -152459036,
+ 175884611,
+ 1886544719,
+ 291366486,
+ -190934538,
+ 106530986,
+ -44748687,
+ 11690782,
+ -55958,
+ -473526,
+ 0,
+ -374154,
+ -574250,
+ 12290303,
+ -42502723,
+ 93223467,
+ -148119396,
+ 163648779,
+ 1885361136,
+ 304756474,
+ -195112708,
+ 107732056,
+ -44897122,
+ 11600452,
+ 3414,
+ -484256,
+ 0,
+ -365021,
+ -618725,
+ 12321347,
+ -42207858,
+ 91779912,
+ -143773139,
+ 151538949,
+ 1883941245,
+ 318250359,
+ -199264904,
+ 108906481,
+ -45030664,
+ 11504349,
+ 64184,
+ -495127,
+ 0,
+ -356033,
+ -661902,
+ 12347418,
+ -41901309,
+ 90318903,
+ -139421942,
+ 139556879,
+ 1882285814,
+ 331845902,
+ -203389287,
+ 110053500,
+ -45149066,
+ 11402413,
+ 126359,
+ -506138,
+ 0,
+ -347192,
+ -703793,
+ 12368587,
+ -41583351,
+ 88841206,
+ -135067453,
+ 127704280,
+ 1880394843,
+ 345540833,
+ -207484004,
+ 111172348,
+ -45252071,
+ 11294588,
+ 189943,
+ -517288,
+ 0,
+ -338497,
+ -744409,
+ 12384930,
+ -41254268,
+ 87347581,
+ -130711326,
+ 115982829,
+ 1878269099,
+ 359332819,
+ -211547217,
+ 112262265,
+ -45339427,
+ 11180820,
+ 254942,
+ -528575,
+ 0,
+ -329949,
+ -783760,
+ 12396521,
+ -40914333,
+ 85838779,
+ -126355182,
+ 104394141,
+ 1875908965,
+ 373219495,
+ -215577055,
+ 113322508,
+ -45410900,
+ 11061053,
+ 321358,
+ -539997,
+ 0,
+ -321546,
+ -821862,
+ 12403437,
+ -40563828,
+ 84315552,
+ -122000629,
+ 92939807,
+ 1873315082,
+ 387198462,
+ -219571665,
+ 114352309,
+ -45466240,
+ 10935237,
+ 389196,
+ -551555,
+ 0,
+ -313288,
+ -858724,
+ 12405754,
+ -40203029,
+ 82778650,
+ -117649249,
+ 81621345,
+ 1870487960,
+ 401267291,
+ -223529127,
+ 115350934,
+ -45505213,
+ 10803322,
+ 458457,
+ -563244,
+ -3119,
+ -305176,
+ -894361,
+ 12403550,
+ -39832220,
+ 81228826,
+ -113302616,
+ 70440257,
+ 1867428366,
+ 415423489,
+ -227447573,
+ 116317614,
+ -45527587,
+ 10665257,
+ 529144,
+ -575064,
+ -755,
+ -297207,
+ -928784,
+ 12396902,
+ -39451681,
+ 79666813,
+ -108962281,
+ 59397991,
+ 1864137069,
+ 429664561,
+ -231325115,
+ 117251623,
+ -45533125,
+ 10520999,
+ 601258,
+ -587013,
+ -847,
+ -289382,
+ -962008,
+ 12385890,
+ -39061695,
+ 78093364,
+ -104629769,
+ 48495944,
+ 1860614707,
+ 443987984,
+ -235159853,
+ 118152226,
+ -45521601,
+ 10370501,
+ 674800,
+ -599089,
+ -943,
+ -281701,
+ -994045,
+ 12370590,
+ -38662539,
+ 76509198,
+ -100306601,
+ 37735463,
+ 1856862431,
+ 458391166,
+ -238949867,
+ 119018670,
+ -45492794,
+ 10213721,
+ 749769,
+ -611288,
+ -1050,
+ -274161,
+ -1024910,
+ 12351085,
+ -38254491,
+ 74915058,
+ -95994262,
+ 27117867,
+ 1852880880,
+ 472871487,
+ -242693256,
+ 119850254,
+ -45446484,
+ 10050618,
+ 826167,
+ -623611,
+ -1163,
+ -266763,
+ -1054615,
+ 12327451,
+ -37837836,
+ 73311655,
+ -91694230,
+ 16644414,
+ 1848671206,
+ 487426326,
+ -246388101,
+ 120646233,
+ -45382460,
+ 9881154,
+ 903991,
+ -636051,
+ -1286,
+ -259505,
+ -1083178,
+ 12299773,
+ -37412858,
+ 71699732,
+ -87407961,
+ 6316321,
+ 1844234304,
+ 502053028,
+ -250032469,
+ 121405897,
+ -45300506,
+ 9705291,
+ 983240,
+ -648610,
+ -1414,
+ -252387,
+ -1110610,
+ 12268128,
+ -36979827,
+ 70079986,
+ -83136876,
+ -3865239,
+ 1839571451,
+ 516748846,
+ -253624458,
+ 122128533,
+ -45200418,
+ 9522995,
+ 1063910,
+ -661281,
+ -1553,
+ -245408,
+ -1136928,
+ 12232598,
+ -36539028,
+ 68453142,
+ -78882399,
+ -13899142,
+ 1834683416,
+ 531511061,
+ -257162132,
+ 122813440,
+ -45081993,
+ 9334234,
+ 1146000,
+ -674064,
+ -1699,
+ -238567,
+ -1162144,
+ 12193264,
+ -36090737,
+ 66819897,
+ -74645911,
+ -23784312,
+ 1829571733,
+ 546336892,
+ -260643560,
+ 123459913,
+ -44945038,
+ 9138979,
+ 1229503,
+ -686954,
+ -1860,
+ -231861,
+ -1186276,
+ 12150209,
+ -35635233,
+ 65180954,
+ -70428773,
+ -33519715,
+ 1824237552,
+ 561223623,
+ -264066805,
+ 124067265,
+ -44789362,
+ 8937199,
+ 1314418,
+ -699950,
+ -2029,
+ -225292,
+ -1209336,
+ 12103511,
+ -35172792,
+ 63537003,
+ -66232349,
+ -43104364,
+ 1818682025,
+ 576168343,
+ -267429934,
+ 124634808,
+ -44614773,
+ 8728869,
+ 1400738,
+ -713047,
+ -2213,
+ -218857,
+ -1231343,
+ 12053256,
+ -34703690,
+ 61888737,
+ -62057948,
+ -52537326,
+ 1812906559,
+ 591168240,
+ -270731046,
+ 125161865,
+ -44421094,
+ 8513969,
+ 1488456,
+ -726242,
+ -2399,
+ -212555,
+ -1252310,
+ 11999523,
+ -34228202,
+ 60236835,
+ -57906879,
+ -61817704,
+ 1806912687,
+ 606220373,
+ -273968158,
+ 125647778,
+ -44208148,
+ 8292474,
+ 1577565,
+ -739530,
+ -2604,
+ -206385,
+ -1272254,
+ 11942397,
+ -33746600,
+ 58581971,
+ -53780422,
+ -70944656,
+ 1800701688,
+ 621321928,
+ -277139383,
+ 126091878,
+ -43975768,
+ 8064369,
+ 1668059,
+ -752908,
+ -2820,
+ -200346,
+ -1291190,
+ 11881955,
+ -33259160,
+ 56924818,
+ -49679822,
+ -79917379,
+ 1794275225,
+ 636469965,
+ -280242773,
+ 126493516,
+ -43723784,
+ 7829636,
+ 1759928,
+ -766373,
+ -3048,
+ -194436,
+ -1309133,
+ 11818284,
+ -32766147,
+ 55266031,
+ -45606328,
+ -88735128,
+ 1787634704,
+ 651661542,
+ -283276408,
+ 126852045,
+ -43452040,
+ 7588261,
+ 1853164,
+ -779919,
+ -3291,
+ -188655,
+ -1326100,
+ 11751464,
+ -32267834,
+ 53606268,
+ -41561141,
+ -97397185,
+ 1780781788,
+ 666893591,
+ -286238339,
+ 127166842,
+ -43160380,
+ 7340235,
+ 1947755,
+ -793543,
+ -3546,
+ -183000,
+ -1342106,
+ 11681576,
+ -31764488,
+ 51946174,
+ -37545449,
+ -105902903,
+ 1773718138,
+ 682163170,
+ -289126680,
+ 127437275,
+ -42848664,
+ 7085550,
+ 2043691,
+ -807240,
+ -3817,
+ -177470,
+ -1357168,
+ 11608702,
+ -31256376,
+ 50286391,
+ -33560418,
+ -114251658,
+ 1766445418,
+ 697467275,
+ -291939512,
+ 127662729,
+ -42516749,
+ 6824201,
+ 2140962,
+ -821005,
+ -4104,
+ -172065,
+ -1371302,
+ 11532925,
+ -30743761,
+ 48627548,
+ -29607183,
+ -122442891,
+ 1758965418,
+ 712802772,
+ -294674886,
+ 127842621,
+ -42164497,
+ 6556182,
+ 2239552,
+ -834834,
+ -4407,
+ -166782,
+ -1384525,
+ 11454324,
+ -30226907,
+ 46970271,
+ -25686861,
+ -130476089,
+ 1751279927,
+ 728166720,
+ -297330947,
+ 127976336,
+ -41791782,
+ 6281497,
+ 2339450,
+ -848720,
+ -4726,
+ -161619,
+ -1396853,
+ 11372984,
+ -29706072,
+ 45315179,
+ -21800546,
+ -138350759,
+ 1743390736,
+ 743555924,
+ -299905746,
+ 128063312,
+ -41398484,
+ 6000147,
+ 2440641,
+ -862660,
+ -5063,
+ -156576,
+ -1408300,
+ 11288982,
+ -29181515,
+ 43662873,
+ -17949299,
+ -146066491,
+ 1735299891,
+ 758967377,
+ -302397428,
+ 128102969,
+ -40984486,
+ 5712138,
+ 2543109,
+ -876647,
+ -5419,
+ -151651,
+ -1418886,
+ 11202401,
+ -28653494,
+ 42013960,
+ -14134166,
+ -153622911,
+ 1727009310,
+ 774397883,
+ -304804107,
+ 128094753,
+ -40549690,
+ 5417478,
+ 2646840,
+ -890678,
+ -5791,
+ -146844,
+ -1428625,
+ 11113321,
+ -28122264,
+ 40369027,
+ -10356165,
+ -161019651,
+ 1718520783,
+ 789844245,
+ -307123865,
+ 128038122,
+ -40093982,
+ 5116181,
+ 2751814,
+ -904743,
+ -6186,
+ -142150,
+ -1437534,
+ 11021821,
+ -27588076,
+ 38728657,
+ -6616290,
+ -168256455,
+ 1709836484,
+ 805303458,
+ -309354879,
+ 127932539,
+ -39617279,
+ 4808258,
+ 2858016,
+ -918840,
+ -6598,
+ -137571,
+ -1445629,
+ 10927981,
+ -27051178,
+ 37093429,
+ -2915508,
+ -175333051,
+ 1700958587,
+ 820772198,
+ -311495233,
+ 127777495,
+ -39119489,
+ 4493730,
+ 2965425,
+ -932961,
+ -7033,
+ -133102,
+ -1452928,
+ 10831882,
+ -26511818,
+ 35463901,
+ 745237,
+ -182249264,
+ 1691889137,
+ 836247332,
+ -313543135,
+ 127572476,
+ -38600541,
+ 4172615,
+ 3074022,
+ -947100,
+ -7490,
+ -128745,
+ -1459445,
+ 10733601,
+ -25970244,
+ 33840633,
+ 4365026,
+ -189004918,
+ 1682630182,
+ 851725726,
+ -315496731,
+ 127316996,
+ -38060358,
+ 3844938,
+ 3183786,
+ -961250,
+ -7968,
+ -124495,
+ -1465198,
+ 10633217,
+ -25426694,
+ 32224176,
+ 7942965,
+ -195599932,
+ 1673184021,
+ 867204056,
+ -317354168,
+ 127010574,
+ -37498876,
+ 3510727,
+ 3294696,
+ -975406,
+ -8471,
+ -120354,
+ -1470203,
+ 10530807,
+ -24881410,
+ 30615062,
+ 11478186,
+ -202034212,
+ 1663552958,
+ 882679125,
+ -319113687,
+ 126652740,
+ -36916043,
+ 3170010,
+ 3406729,
+ -989557,
+ -8997,
+ -116316,
+ -1474477,
+ 10426450,
+ -24334629,
+ 29013825,
+ 14969846,
+ -208307756,
+ 1653739293,
+ 898147673,
+ -320773402,
+ 126243063,
+ -36311812,
+ 2822820,
+ 3519863,
+ -1003701,
+ -9548,
+ -112383,
+ -1478035,
+ 10320221,
+ -23786586,
+ 27420984,
+ 18417126,
+ -214420597,
+ 1643745329,
+ 913606503,
+ -322331586,
+ 125781085,
+ -35686142,
+ 2469197,
+ 3634069,
+ -1017828,
+ -10127,
+ -108551,
+ -1480895,
+ 10212199,
+ -23237509,
+ 25837045,
+ 21819235,
+ -220372783,
+ 1633573367,
+ 929052290,
+ -323786481,
+ 125266408,
+ -35038998,
+ 2109177,
+ 3749327,
+ -1031931,
+ -10731,
+ -104820,
+ -1483070,
+ 10102455,
+ -22687630,
+ 24262515,
+ 25175401,
+ -226164425,
+ 1623225965,
+ 944481773,
+ -325136266,
+ 124698617,
+ -34370367,
+ 1742804,
+ 3865607,
+ -1046002,
+ -11365,
+ -101188,
+ -1484581,
+ 9991069,
+ -22137173,
+ 22697879,
+ 28484887,
+ -231795700,
+ 1612705424,
+ 959891755,
+ -326379214,
+ 124077334,
+ -33680226,
+ 1370127,
+ 3982883,
+ -1060035,
+ -12026,
+ -97653,
+ -1485439,
+ 9878113,
+ -21586364,
+ 21143623,
+ 31746973,
+ -237266800,
+ 1602014430,
+ 975278785,
+ -327513631,
+ 123402170,
+ -32968570,
+ 991192,
+ 4101126,
+ -1074018,
+ -12718,
+ -94213,
+ -1485664,
+ 9763662,
+ -21035418,
+ 19600216,
+ 34960968,
+ -242577947,
+ 1591155284,
+ 990639729,
+ -328537789,
+ 122672796,
+ -32235404,
+ 606054,
+ 4220306,
+ -1087947,
+ -13441,
+ -90868,
+ -1485268,
+ 9647787,
+ -20484553,
+ 18068122,
+ 38126204,
+ -247729463,
+ 1580130799,
+ 1005971198,
+ -329449996,
+ 121888853,
+ -31480740,
+ 214771,
+ 4340393,
+ -1101811,
+ -14195,
+ -87613,
+ -1484271,
+ 9530562,
+ -19933986,
+ 16547787,
+ 41242045,
+ -252721633,
+ 1568943278,
+ 1021269932,
+ -330248557,
+ 121050029,
+ -30704593,
+ -182600,
+ 4461357,
+ -1115603,
+ -14982,
+ -84450,
+ -1482686,
+ 9412058,
+ -19383923,
+ 15039657,
+ 44307872,
+ -257554859,
+ 1557595661,
+ 1036532670,
+ -330931809,
+ 120156028,
+ -29906997,
+ -585993,
+ 4583163,
+ -1129313,
+ -15802,
+ -81376,
+ -1480530,
+ 9292346,
+ -18834573,
+ 13544163,
+ 47323094,
+ -262229524,
+ 1546090378,
+ 1051755959,
+ -331498154,
+ 119206554,
+ -29087987,
+ -995343,
+ 4705780,
+ -1142932,
+ -16658,
+ -78389,
+ -1477817,
+ 9171497,
+ -18286140,
+ 12061725,
+ 50287143,
+ -266746107,
+ 1534430370,
+ 1066936603,
+ -331945962,
+ 118201344,
+ -28247612,
+ -1410576,
+ 4829171,
+ -1156450,
+ -17550,
+ -75486,
+ -1474564,
+ 9049580,
+ -17738823,
+ 10592756,
+ 53199487,
+ -271105072,
+ 1522618194,
+ 1082071278,
+ -332273634,
+ 117140151,
+ -27385927,
+ -1831622,
+ 4953303,
+ -1169860,
+ -18479,
+ -72669,
+ -1470785,
+ 8926663,
+ -17192824,
+ 9137654,
+ 56059604,
+ -275306945,
+ 1510656663,
+ 1097156593,
+ -332479572,
+ 116022741,
+ -26502998,
+ -2258399,
+ 5078136,
+ -1183150,
+ -19447,
+ -69933,
+ -1466496,
+ 8802814,
+ -16648332,
+ 7696812,
+ 58867010,
+ -279352336,
+ 1498548591,
+ 1112189353,
+ -332562273,
+ 114848908,
+ -25598901,
+ -2690830,
+ 5203636,
+ -1196312,
+ -20453,
+ -67279,
+ -1461712,
+ 8678100,
+ -16105538,
+ 6270610,
+ 61621237,
+ -283241851,
+ 1486296791,
+ 1127166233,
+ -332520171,
+ 113618460,
+ -24673718,
+ -3128828,
+ 5329762,
+ -1209334,
+ -21500,
+ -64702,
+ -1456448,
+ 8552589,
+ -15564632,
+ 4859418,
+ 64321842,
+ -286976097,
+ 1473904204,
+ 1142083781,
+ -332351764,
+ 112331228,
+ -23727545,
+ -3572305,
+ 5456476,
+ -1222208,
+ -22589,
+ -62205,
+ -1450719,
+ 8426342,
+ -15025794,
+ 3463593,
+ 66968413,
+ -290555777,
+ 1461373516,
+ 1156938927,
+ -332055548,
+ 110987054,
+ -22760487,
+ -4021168,
+ 5583736,
+ -1234922,
+ -23721,
+ -59781,
+ -1444539,
+ 8299428,
+ -14489207,
+ 2083486,
+ 69560562,
+ -293981660,
+ 1448707922,
+ 1171728219,
+ -331630118,
+ 109585801,
+ -21772654,
+ -4475321,
+ 5711501,
+ -1247465,
+ -24897,
+ -57434,
+ -1437922,
+ 8171907,
+ -13955046,
+ 719436,
+ 72097918,
+ -297254448,
+ 1435910109,
+ 1186448460,
+ -331074003,
+ 108127372,
+ -20764169,
+ -4934665,
+ 5839727,
+ -1259828,
+ -26120,
+ -55157,
+ -1430884,
+ 8043844,
+ -13423484,
+ -628229,
+ 74580145,
+ -300375004,
+ 1422983144,
+ 1201096198,
+ -330385827,
+ 106611666,
+ -19735167,
+ -5399098,
+ 5968372,
+ -1271999,
+ -27389,
+ -52953,
+ -1423437,
+ 7915299,
+ -12894690,
+ -1959192,
+ 77006916,
+ -303344096,
+ 1409930099,
+ 1215668363,
+ -329564186,
+ 105038608,
+ -18685792,
+ -5868513,
+ 6097390,
+ -1283966,
+ -28705,
+ -50817,
+ -1415598,
+ 7786333,
+ -12368832,
+ -3273145,
+ 79377951,
+ -306162683,
+ 1396753912,
+ 1230161631,
+ -328607735,
+ 103408160,
+ -17616192,
+ -6342798,
+ 6226736,
+ -1295718,
+ -30071,
+ -48750,
+ -1407379,
+ 7657006,
+ -11846070,
+ -4569792,
+ 81692969,
+ -308831595,
+ 1383457654,
+ 1244572805,
+ -327515133,
+ 101720290,
+ -16526534,
+ -6821838,
+ 6356361,
+ -1307244,
+ -31488,
+ -46749,
+ -1398794,
+ 7527378,
+ -11326563,
+ -5848844,
+ 83951732,
+ -311351825,
+ 1370044392,
+ 1258898433,
+ -326285132,
+ 99974997,
+ -15416990,
+ -7305518,
+ 6486220,
+ -1318533,
+ -32957,
+ -44814,
+ -1389856,
+ 7397505,
+ -10810467,
+ -7110029,
+ 86154024,
+ -313724330,
+ 1356517069,
+ 1273135446,
+ -324916422,
+ 98172281,
+ -14287743,
+ -7793714,
+ 6616262,
+ -1329571,
+ -34479,
+ -42941,
+ -1380580,
+ 7267445,
+ -10297932,
+ -8353079,
+ 88299636,
+ -315950134,
+ 1342878881,
+ 1287280647,
+ -323407757,
+ 96312199,
+ -13138985,
+ -8286302,
+ 6746439,
+ -1340347,
+ -36056,
+ -41131,
+ -1370978,
+ 7137254,
+ -9789106,
+ -9577739,
+ 90388401,
+ -318030291,
+ 1329133152,
+ 1301330839,
+ -321757952,
+ 94394799,
+ -11970921,
+ -8783153,
+ 6876697,
+ -1350849,
+ -37690,
+ -39381,
+ -1361064,
+ 7006987,
+ -9284133,
+ -10783764,
+ 92420159,
+ -319965858,
+ 1315282697,
+ 1315282697,
+ -319965858,
+ 92420159,
+ -10783764,
+ -9284133,
+ 7006987,
+ -1361064,
+ -39381,
+ -37690,
+ -1350849,
+ 6876697,
+ -8783153,
+ -11970921,
+ 94394799,
+ -321757952,
+ 1301330839,
+ 1329133152,
+ -318030291,
+ 90388401,
+ -9577739,
+ -9789106,
+ 7137254,
+ -1370978,
+ -41131,
+ -36056,
+ -1340347,
+ 6746439,
+ -8286302,
+ -13138985,
+ 96312199,
+ -323407757,
+ 1287280647,
+ 1342878881,
+ -315950134,
+ 88299636,
+ -8353079,
+ -10297932,
+ 7267445,
+ -1380580,
+ -42941,
+ -34479,
+ -1329571,
+ 6616262,
+ -7793714,
+ -14287743,
+ 98172281,
+ -324916422,
+ 1273135446,
+ 1356517069,
+ -313724330,
+ 86154024,
+ -7110029,
+ -10810467,
+ 7397505,
+ -1389856,
+ -44814,
+ -32957,
+ -1318533,
+ 6486220,
+ -7305518,
+ -15416990,
+ 99974997,
+ -326285132,
+ 1258898433,
+ 1370044392,
+ -311351825,
+ 83951732,
+ -5848844,
+ -11326563,
+ 7527378,
+ -1398794,
+ -46749,
+ -31488,
+ -1307244,
+ 6356361,
+ -6821838,
+ -16526534,
+ 101720290,
+ -327515133,
+ 1244572805,
+ 1383457654,
+ -308831595,
+ 81692969,
+ -4569792,
+ -11846070,
+ 7657006,
+ -1407379,
+ -48750,
+ -30071,
+ -1295718,
+ 6226736,
+ -6342798,
+ -17616192,
+ 103408160,
+ -328607735,
+ 1230161631,
+ 1396753912,
+ -306162683,
+ 79377951,
+ -3273145,
+ -12368832,
+ 7786333,
+ -1415598,
+ -50817,
+ -28705,
+ -1283966,
+ 6097390,
+ -5868513,
+ -18685792,
+ 105038608,
+ -329564186,
+ 1215668363,
+ 1409930099,
+ -303344096,
+ 77006916,
+ -1959192,
+ -12894690,
+ 7915299,
+ -1423437,
+ -52953,
+ -27389,
+ -1271999,
+ 5968372,
+ -5399098,
+ -19735167,
+ 106611666,
+ -330385827,
+ 1201096198,
+ 1422983144,
+ -300375004,
+ 74580145,
+ -628229,
+ -13423484,
+ 8043844,
+ -1430884,
+ -55157,
+ -26120,
+ -1259828,
+ 5839727,
+ -4934665,
+ -20764169,
+ 108127372,
+ -331074003,
+ 1186448460,
+ 1435910109,
+ -297254448,
+ 72097918,
+ 719436,
+ -13955046,
+ 8171907,
+ -1437922,
+ -57434,
+ -24897,
+ -1247465,
+ 5711501,
+ -4475321,
+ -21772654,
+ 109585801,
+ -331630118,
+ 1171728219,
+ 1448707922,
+ -293981660,
+ 69560562,
+ 2083486,
+ -14489207,
+ 8299428,
+ -1444539,
+ -59781,
+ -23721,
+ -1234922,
+ 5583736,
+ -4021168,
+ -22760487,
+ 110987054,
+ -332055548,
+ 1156938927,
+ 1461373516,
+ -290555777,
+ 66968413,
+ 3463593,
+ -15025794,
+ 8426342,
+ -1450719,
+ -62205,
+ -22589,
+ -1222208,
+ 5456476,
+ -3572305,
+ -23727545,
+ 112331228,
+ -332351764,
+ 1142083781,
+ 1473904204,
+ -286976097,
+ 64321842,
+ 4859418,
+ -15564632,
+ 8552589,
+ -1456448,
+ -64702,
+ -21500,
+ -1209334,
+ 5329762,
+ -3128828,
+ -24673718,
+ 113618460,
+ -332520171,
+ 1127166233,
+ 1486296791,
+ -283241851,
+ 61621237,
+ 6270610,
+ -16105538,
+ 8678100,
+ -1461712,
+ -67279,
+ -20453,
+ -1196312,
+ 5203636,
+ -2690830,
+ -25598901,
+ 114848908,
+ -332562273,
+ 1112189353,
+ 1498548591,
+ -279352336,
+ 58867010,
+ 7696812,
+ -16648332,
+ 8802814,
+ -1466496,
+ -69933,
+ -19447,
+ -1183150,
+ 5078136,
+ -2258399,
+ -26502998,
+ 116022741,
+ -332479572,
+ 1097156593,
+ 1510656663,
+ -275306945,
+ 56059604,
+ 9137654,
+ -17192824,
+ 8926663,
+ -1470785,
+ -72669,
+ -18479,
+ -1169860,
+ 4953303,
+ -1831622,
+ -27385927,
+ 117140151,
+ -332273634,
+ 1082071278,
+ 1522618194,
+ -271105072,
+ 53199487,
+ 10592756,
+ -17738823,
+ 9049580,
+ -1474564,
+ -75486,
+ -17550,
+ -1156450,
+ 4829171,
+ -1410576,
+ -28247612,
+ 118201344,
+ -331945962,
+ 1066936603,
+ 1534430370,
+ -266746107,
+ 50287143,
+ 12061725,
+ -18286140,
+ 9171497,
+ -1477817,
+ -78389,
+ -16658,
+ -1142932,
+ 4705780,
+ -995343,
+ -29087987,
+ 119206554,
+ -331498154,
+ 1051755959,
+ 1546090378,
+ -262229524,
+ 47323094,
+ 13544163,
+ -18834573,
+ 9292346,
+ -1480530,
+ -81376,
+ -15802,
+ -1129313,
+ 4583163,
+ -585993,
+ -29906997,
+ 120156028,
+ -330931809,
+ 1036532670,
+ 1557595661,
+ -257554859,
+ 44307872,
+ 15039657,
+ -19383923,
+ 9412058,
+ -1482686,
+ -84450,
+ -14982,
+ -1115603,
+ 4461357,
+ -182600,
+ -30704593,
+ 121050029,
+ -330248557,
+ 1021269932,
+ 1568943278,
+ -252721633,
+ 41242045,
+ 16547787,
+ -19933986,
+ 9530562,
+ -1484271,
+ -87613,
+ -14195,
+ -1101811,
+ 4340393,
+ 214771,
+ -31480740,
+ 121888853,
+ -329449996,
+ 1005971198,
+ 1580130799,
+ -247729463,
+ 38126204,
+ 18068122,
+ -20484553,
+ 9647787,
+ -1485268,
+ -90868,
+ -13441,
+ -1087947,
+ 4220306,
+ 606054,
+ -32235404,
+ 122672796,
+ -328537789,
+ 990639729,
+ 1591155284,
+ -242577947,
+ 34960968,
+ 19600216,
+ -21035418,
+ 9763662,
+ -1485664,
+ -94213,
+ -12718,
+ -1074018,
+ 4101126,
+ 991192,
+ -32968570,
+ 123402170,
+ -327513631,
+ 975278785,
+ 1602014430,
+ -237266800,
+ 31746973,
+ 21143623,
+ -21586364,
+ 9878113,
+ -1485439,
+ -97653,
+ -12026,
+ -1060035,
+ 3982883,
+ 1370127,
+ -33680226,
+ 124077334,
+ -326379214,
+ 959891755,
+ 1612705424,
+ -231795700,
+ 28484887,
+ 22697879,
+ -22137173,
+ 9991069,
+ -1484581,
+ -101188,
+ -11365,
+ -1046002,
+ 3865607,
+ 1742804,
+ -34370367,
+ 124698617,
+ -325136266,
+ 944481773,
+ 1623225965,
+ -226164425,
+ 25175401,
+ 24262515,
+ -22687630,
+ 10102455,
+ -1483070,
+ -104820,
+ -10731,
+ -1031931,
+ 3749327,
+ 2109177,
+ -35038998,
+ 125266408,
+ -323786481,
+ 929052290,
+ 1633573367,
+ -220372783,
+ 21819235,
+ 25837045,
+ -23237509,
+ 10212199,
+ -1480895,
+ -108551,
+ -10127,
+ -1017828,
+ 3634069,
+ 2469197,
+ -35686142,
+ 125781085,
+ -322331586,
+ 913606503,
+ 1643745329,
+ -214420597,
+ 18417126,
+ 27420984,
+ -23786586,
+ 10320221,
+ -1478035,
+ -112383,
+ -9548,
+ -1003701,
+ 3519863,
+ 2822820,
+ -36311812,
+ 126243063,
+ -320773402,
+ 898147673,
+ 1653739293,
+ -208307756,
+ 14969846,
+ 29013825,
+ -24334629,
+ 10426450,
+ -1474477,
+ -116316,
+ -8997,
+ -989557,
+ 3406729,
+ 3170010,
+ -36916043,
+ 126652740,
+ -319113687,
+ 882679125,
+ 1663552958,
+ -202034212,
+ 11478186,
+ 30615062,
+ -24881410,
+ 10530807,
+ -1470203,
+ -120354,
+ -8471,
+ -975406,
+ 3294696,
+ 3510727,
+ -37498876,
+ 127010574,
+ -317354168,
+ 867204056,
+ 1673184021,
+ -195599932,
+ 7942965,
+ 32224176,
+ -25426694,
+ 10633217,
+ -1465198,
+ -124495,
+ -7968,
+ -961250,
+ 3183786,
+ 3844938,
+ -38060358,
+ 127316996,
+ -315496731,
+ 851725726,
+ 1682630182,
+ -189004918,
+ 4365026,
+ 33840633,
+ -25970244,
+ 10733601,
+ -1459445,
+ -128745,
+ -7490,
+ -947100,
+ 3074022,
+ 4172615,
+ -38600541,
+ 127572476,
+ -313543135,
+ 836247332,
+ 1691889137,
+ -182249264,
+ 745237,
+ 35463901,
+ -26511818,
+ 10831882,
+ -1452928,
+ -133102,
+ -7033,
+ -932961,
+ 2965425,
+ 4493730,
+ -39119489,
+ 127777495,
+ -311495233,
+ 820772198,
+ 1700958587,
+ -175333051,
+ -2915508,
+ 37093429,
+ -27051178,
+ 10927981,
+ -1445629,
+ -137571,
+ -6598,
+ -918840,
+ 2858016,
+ 4808258,
+ -39617279,
+ 127932539,
+ -309354879,
+ 805303458,
+ 1709836484,
+ -168256455,
+ -6616290,
+ 38728657,
+ -27588076,
+ 11021821,
+ -1437534,
+ -142150,
+ -6186,
+ -904743,
+ 2751814,
+ 5116181,
+ -40093982,
+ 128038122,
+ -307123865,
+ 789844245,
+ 1718520783,
+ -161019651,
+ -10356165,
+ 40369027,
+ -28122264,
+ 11113321,
+ -1428625,
+ -146844,
+ -5791,
+ -890678,
+ 2646840,
+ 5417478,
+ -40549690,
+ 128094753,
+ -304804107,
+ 774397883,
+ 1727009310,
+ -153622911,
+ -14134166,
+ 42013960,
+ -28653494,
+ 11202401,
+ -1418886,
+ -151651,
+ -5419,
+ -876647,
+ 2543109,
+ 5712138,
+ -40984486,
+ 128102969,
+ -302397428,
+ 758967377,
+ 1735299891,
+ -146066491,
+ -17949299,
+ 43662873,
+ -29181515,
+ 11288982,
+ -1408300,
+ -156576,
+ -5063,
+ -862660,
+ 2440641,
+ 6000147,
+ -41398484,
+ 128063312,
+ -299905746,
+ 743555924,
+ 1743390736,
+ -138350759,
+ -21800546,
+ 45315179,
+ -29706072,
+ 11372984,
+ -1396853,
+ -161619,
+ -4726,
+ -848720,
+ 2339450,
+ 6281497,
+ -41791782,
+ 127976336,
+ -297330947,
+ 728166720,
+ 1751279927,
+ -130476089,
+ -25686861,
+ 46970271,
+ -30226907,
+ 11454324,
+ -1384525,
+ -166782,
+ -4407,
+ -834834,
+ 2239552,
+ 6556182,
+ -42164497,
+ 127842621,
+ -294674886,
+ 712802772,
+ 1758965418,
+ -122442891,
+ -29607183,
+ 48627548,
+ -30743761,
+ 11532925,
+ -1371302,
+ -172065,
+ -4104,
+ -821005,
+ 2140962,
+ 6824201,
+ -42516749,
+ 127662729,
+ -291939512,
+ 697467275,
+ 1766445418,
+ -114251658,
+ -33560418,
+ 50286391,
+ -31256376,
+ 11608702,
+ -1357168,
+ -177470,
+ -3817,
+ -807240,
+ 2043691,
+ 7085550,
+ -42848664,
+ 127437275,
+ -289126680,
+ 682163170,
+ 1773718138,
+ -105902903,
+ -37545449,
+ 51946174,
+ -31764488,
+ 11681576,
+ -1342106,
+ -183000,
+ -3546,
+ -793543,
+ 1947755,
+ 7340235,
+ -43160380,
+ 127166842,
+ -286238339,
+ 666893591,
+ 1780781788,
+ -97397185,
+ -41561141,
+ 53606268,
+ -32267834,
+ 11751464,
+ -1326100,
+ -188655,
+ -3291,
+ -779919,
+ 1853164,
+ 7588261,
+ -43452040,
+ 126852045,
+ -283276408,
+ 651661542,
+ 1787634704,
+ -88735128,
+ -45606328,
+ 55266031,
+ -32766147,
+ 11818284,
+ -1309133,
+ -194436,
+ -3048,
+ -766373,
+ 1759928,
+ 7829636,
+ -43723784,
+ 126493516,
+ -280242773,
+ 636469965,
+ 1794275225,
+ -79917379,
+ -49679822,
+ 56924818,
+ -33259160,
+ 11881955,
+ -1291190,
+ -200346,
+ -2820,
+ -752908,
+ 1668059,
+ 8064369,
+ -43975768,
+ 126091878,
+ -277139383,
+ 621321928,
+ 1800701688,
+ -70944656,
+ -53780422,
+ 58581971,
+ -33746600,
+ 11942397,
+ -1272254,
+ -206385,
+ -2604,
+ -739530,
+ 1577565,
+ 8292474,
+ -44208148,
+ 125647778,
+ -273968158,
+ 606220373,
+ 1806912687,
+ -61817704,
+ -57906879,
+ 60236835,
+ -34228202,
+ 11999523,
+ -1252310,
+ -212555,
+ -2399,
+ -726242,
+ 1488456,
+ 8513969,
+ -44421094,
+ 125161865,
+ -270731046,
+ 591168240,
+ 1812906559,
+ -52537326,
+ -62057948,
+ 61888737,
+ -34703690,
+ 12053256,
+ -1231343,
+ -218857,
+ -2213,
+ -713047,
+ 1400738,
+ 8728869,
+ -44614773,
+ 124634808,
+ -267429934,
+ 576168343,
+ 1818682025,
+ -43104364,
+ -66232349,
+ 63537003,
+ -35172792,
+ 12103511,
+ -1209336,
+ -225292,
+ -2029,
+ -699950,
+ 1314418,
+ 8937199,
+ -44789362,
+ 124067265,
+ -264066805,
+ 561223623,
+ 1824237552,
+ -33519715,
+ -70428773,
+ 65180954,
+ -35635233,
+ 12150209,
+ -1186276,
+ -231861,
+ -1860,
+ -686954,
+ 1229503,
+ 9138979,
+ -44945038,
+ 123459913,
+ -260643560,
+ 546336892,
+ 1829571733,
+ -23784312,
+ -74645911,
+ 66819897,
+ -36090737,
+ 12193264,
+ -1162144,
+ -238567,
+ -1699,
+ -674064,
+ 1146000,
+ 9334234,
+ -45081993,
+ 122813440,
+ -257162132,
+ 531511061,
+ 1834683416,
+ -13899142,
+ -78882399,
+ 68453142,
+ -36539028,
+ 12232598,
+ -1136928,
+ -245408,
+ -1553,
+ -661281,
+ 1063910,
+ 9522995,
+ -45200418,
+ 122128533,
+ -253624458,
+ 516748846,
+ 1839571451,
+ -3865239,
+ -83136876,
+ 70079986,
+ -36979827,
+ 12268128,
+ -1110610,
+ -252387,
+ -1414,
+ -648610,
+ 983240,
+ 9705291,
+ -45300506,
+ 121405897,
+ -250032469,
+ 502053028,
+ 1844234304,
+ 6316321,
+ -87407961,
+ 71699732,
+ -37412858,
+ 12299773,
+ -1083178,
+ -259505,
+ -1286,
+ -636051,
+ 903991,
+ 9881154,
+ -45382460,
+ 120646233,
+ -246388101,
+ 487426326,
+ 1848671206,
+ 16644414,
+ -91694230,
+ 73311655,
+ -37837836,
+ 12327451,
+ -1054615,
+ -266763,
+ -1163,
+ -623611,
+ 826167,
+ 10050618,
+ -45446484,
+ 119850254,
+ -242693256,
+ 472871487,
+ 1852880880,
+ 27117867,
+ -95994262,
+ 74915058,
+ -38254491,
+ 12351085,
+ -1024910,
+ -274161,
+ -1050,
+ -611288,
+ 749769,
+ 10213721,
+ -45492794,
+ 119018670,
+ -238949867,
+ 458391166,
+ 1856862431,
+ 37735463,
+ -100306601,
+ 76509198,
+ -38662539,
+ 12370590,
+ -994045,
+ -281701,
+ -943,
+ -599089,
+ 674800,
+ 10370501,
+ -45521601,
+ 118152226,
+ -235159853,
+ 443987984,
+ 1860614707,
+ 48495944,
+ -104629769,
+ 78093364,
+ -39061695,
+ 12385890,
+ -962008,
+ -289382,
+ -847,
+ -587013,
+ 601258,
+ 10520999,
+ -45533125,
+ 117251623,
+ -231325115,
+ 429664561,
+ 1864137069,
+ 59397991,
+ -108962281,
+ 79666813,
+ -39451681,
+ 12396902,
+ -928784,
+ -297207,
+ -755,
+ -575064,
+ 529144,
+ 10665257,
+ -45527587,
+ 116317614,
+ -227447573,
+ 415423489,
+ 1867428366,
+ 70440257,
+ -113302616,
+ 81228826,
+ -39832220,
+ 12403550,
+ -894361,
+ -305176,
+ -3119,
+ -563244,
+ 458457,
+ 10803322,
+ -45505213,
+ 115350934,
+ -223529127,
+ 401267291,
+ 1870487960,
+ 81621345,
+ -117649249,
+ 82778650,
+ -40203029,
+ 12405754,
+ -858724,
+ -313288,
+ 0,
+ -551555,
+ 389196,
+ 10935237,
+ -45466240,
+ 114352309,
+ -219571665,
+ 387198462,
+ 1873315082,
+ 92939807,
+ -122000629,
+ 84315552,
+ -40563828,
+ 12403437,
+ -821862,
+ -321546,
+ 0,
+ -539997,
+ 321358,
+ 11061053,
+ -45410900,
+ 113322508,
+ -215577055,
+ 373219495,
+ 1875908965,
+ 104394141,
+ -126355182,
+ 85838779,
+ -40914333,
+ 12396521,
+ -783760,
+ -329949,
+ 0,
+ -528575,
+ 254942,
+ 11180820,
+ -45339427,
+ 112262265,
+ -211547217,
+ 359332819,
+ 1878269099,
+ 115982829,
+ -130711326,
+ 87347581,
+ -41254268,
+ 12384930,
+ -744409,
+ -338497,
+ 0,
+ -517288,
+ 189943,
+ 11294588,
+ -45252071,
+ 111172348,
+ -207484004,
+ 345540833,
+ 1880394843,
+ 127704280,
+ -135067453,
+ 88841206,
+ -41583351,
+ 12368587,
+ -703793,
+ -347192,
+ 0,
+ -506138,
+ 126359,
+ 11402413,
+ -45149066,
+ 110053500,
+ -203389287,
+ 331845902,
+ 1882285814,
+ 139556879,
+ -139421942,
+ 90318903,
+ -41901309,
+ 12347418,
+ -661902,
+ -356033,
+ 0,
+ -495127,
+ 64184,
+ 11504349,
+ -45030664,
+ 108906481,
+ -199264904,
+ 318250359,
+ 1883941245,
+ 151538949,
+ -143773139,
+ 91779912,
+ -42207858,
+ 12321347,
+ -618725,
+ -365021,
+ 0,
+ -484256,
+ 3414,
+ 11600452,
+ -44897122,
+ 107732056,
+ -195112708,
+ 304756474,
+ 1885361136,
+ 163648779,
+ -148119396,
+ 93223467,
+ -42502723,
+ 12290303,
+ -574250,
+ -374154,
+ 0,
+ -473526,
+ -55958,
+ 11690782,
+ -44748687,
+ 106530986,
+ -190934538,
+ 291366486,
+ 1886544719,
+ 175884611,
+ -152459036,
+ 94648808,
+ -42785628,
+ 12254212,
+ -528467,
+ -383435,
+ 0,
+ -462939,
+ -113935,
+ 11775396,
+ -44585610,
+ 105304039,
+ -186732217,
+ 278082663,
+ 1887491995,
+ 188244655,
+ -156790381,
+ 96055185,
+ -43056301,
+ 12213002,
+ -481365,
+ -392863,
+ 0,
+ -452493,
+ -170525,
+ 11854358,
+ -44408163,
+ 104051972,
+ -182507550,
+ 264907100,
+ 1888202707,
+ 200727056,
+ -161111719,
+ 97441805,
+ -43314458,
+ 12166601,
+ -432934,
+ -402437,
+ 0,
+ -442192,
+ -225736,
+ 11927728,
+ -44216595,
+ 102775562,
+ -178262343,
+ 251841986,
+ 1888676601,
+ 213329945,
+ -165421325,
+ 98807925,
+ -43559841,
+ 12114943,
+ -383164,
+ -412156,
+ 0,
+ -432035,
+ -279574,
+ 11995573,
+ -44011177,
+ 101475575,
+ -173998387,
+ 238889399,
+ 1888913548,
+ 226051370,
+ -169717457,
+ 100152771,
+ -43792168,
+ 12057955,
+ -332048,
+ -422024
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.sfp
new file mode 100644
index 0000000..4fa9ad1
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS294_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294_xs3.dat
new file mode 100644
index 0000000..5332fa0
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/HS294_xs3.dat
@@ -0,0 +1,2354 @@
+ -422024,
+ 12057955,
+ 100152771,
+ 226051370,
+ 238889399,
+ 101475575,
+ 11995573,
+ -432035,
+ -332048,
+ -43792168,
+ -169717457,
+ 1888913548,
+ -173998387,
+ -44011177,
+ -279574,
+ 0,
+ -412156,
+ 12114943,
+ 98807925,
+ 213329945,
+ 251841986,
+ 102775562,
+ 11927728,
+ -442192,
+ -383164,
+ -43559841,
+ -165421325,
+ 1888676601,
+ -178262343,
+ -44216595,
+ -225736,
+ 0,
+ -402437,
+ 12166601,
+ 97441805,
+ 200727056,
+ 264907100,
+ 104051972,
+ 11854358,
+ -452493,
+ -432934,
+ -43314458,
+ -161111719,
+ 1888202707,
+ -182507550,
+ -44408163,
+ -170525,
+ 0,
+ -392863,
+ 12213002,
+ 96055185,
+ 188244655,
+ 278082663,
+ 105304039,
+ 11775396,
+ -462939,
+ -481365,
+ -43056301,
+ -156790381,
+ 1887491995,
+ -186732217,
+ -44585610,
+ -113935,
+ 0,
+ -383435,
+ 12254212,
+ 94648808,
+ 175884611,
+ 291366486,
+ 106530986,
+ 11690782,
+ -473526,
+ -528467,
+ -42785628,
+ -152459036,
+ 1886544719,
+ -190934538,
+ -44748687,
+ -55958,
+ 0,
+ -374154,
+ 12290303,
+ 93223467,
+ 163648779,
+ 304756474,
+ 107732056,
+ 11600452,
+ -484256,
+ -574250,
+ -42502723,
+ -148119396,
+ 1885361136,
+ -195112708,
+ -44897122,
+ 3414,
+ 0,
+ -365021,
+ 12321347,
+ 91779912,
+ 151538949,
+ 318250359,
+ 108906481,
+ 11504349,
+ -495127,
+ -618725,
+ -42207858,
+ -143773139,
+ 1883941245,
+ -199264904,
+ -45030664,
+ 64184,
+ 0,
+ -356033,
+ 12347418,
+ 90318903,
+ 139556879,
+ 331845902,
+ 110053500,
+ 11402413,
+ -506138,
+ -661902,
+ -41901309,
+ -139421942,
+ 1882285814,
+ -203389287,
+ -45149066,
+ 126359,
+ 0,
+ -347192,
+ 12368587,
+ 88841206,
+ 127704280,
+ 345540833,
+ 111172348,
+ 11294588,
+ -517288,
+ -703793,
+ -41583351,
+ -135067453,
+ 1880394843,
+ -207484004,
+ -45252071,
+ 189943,
+ 0,
+ -338497,
+ 12384930,
+ 87347581,
+ 115982829,
+ 359332819,
+ 112262265,
+ 11180820,
+ -528575,
+ -744409,
+ -41254268,
+ -130711326,
+ 1878269099,
+ -211547217,
+ -45339427,
+ 254942,
+ 0,
+ -329949,
+ 12396521,
+ 85838779,
+ 104394141,
+ 373219495,
+ 113322508,
+ 11061053,
+ -539997,
+ -783760,
+ -40914333,
+ -126355182,
+ 1875908965,
+ -215577055,
+ -45410900,
+ 321358,
+ 0,
+ -321546,
+ 12403437,
+ 84315552,
+ 92939807,
+ 387198462,
+ 114352309,
+ 10935237,
+ -551555,
+ -821862,
+ -40563828,
+ -122000629,
+ 1873315082,
+ -219571665,
+ -45466240,
+ 389196,
+ 0,
+ -313288,
+ 12405754,
+ 82778650,
+ 81621345,
+ 401267291,
+ 115350934,
+ 10803322,
+ -563244,
+ -858724,
+ -40203029,
+ -117649249,
+ 1870487960,
+ -223529127,
+ -45505213,
+ 458457,
+ -3119,
+ -305176,
+ 12403550,
+ 81228826,
+ 70440257,
+ 415423489,
+ 116317614,
+ 10665257,
+ -575064,
+ -894361,
+ -39832220,
+ -113302616,
+ 1867428366,
+ -227447573,
+ -45527587,
+ 529144,
+ -755,
+ -297207,
+ 12396902,
+ 79666813,
+ 59397991,
+ 429664561,
+ 117251623,
+ 10520999,
+ -587013,
+ -928784,
+ -39451681,
+ -108962281,
+ 1864137069,
+ -231325115,
+ -45533125,
+ 601258,
+ -847,
+ -289382,
+ 12385890,
+ 78093364,
+ 48495944,
+ 443987984,
+ 118152226,
+ 10370501,
+ -599089,
+ -962008,
+ -39061695,
+ -104629769,
+ 1860614707,
+ -235159853,
+ -45521601,
+ 674800,
+ -943,
+ -281701,
+ 12370590,
+ 76509198,
+ 37735463,
+ 458391166,
+ 119018670,
+ 10213721,
+ -611288,
+ -994045,
+ -38662539,
+ -100306601,
+ 1856862431,
+ -238949867,
+ -45492794,
+ 749769,
+ -1050,
+ -274161,
+ 12351085,
+ 74915058,
+ 27117867,
+ 472871487,
+ 119850254,
+ 10050618,
+ -623611,
+ -1024910,
+ -38254491,
+ -95994262,
+ 1852880880,
+ -242693256,
+ -45446484,
+ 826167,
+ -1163,
+ -266763,
+ 12327451,
+ 73311655,
+ 16644414,
+ 487426326,
+ 120646233,
+ 9881154,
+ -636051,
+ -1054615,
+ -37837836,
+ -91694230,
+ 1848671206,
+ -246388101,
+ -45382460,
+ 903991,
+ -1286,
+ -259505,
+ 12299773,
+ 71699732,
+ 6316321,
+ 502053028,
+ 121405897,
+ 9705291,
+ -648610,
+ -1083178,
+ -37412858,
+ -87407961,
+ 1844234304,
+ -250032469,
+ -45300506,
+ 983240,
+ -1414,
+ -252387,
+ 12268128,
+ 70079986,
+ -3865239,
+ 516748846,
+ 122128533,
+ 9522995,
+ -661281,
+ -1110610,
+ -36979827,
+ -83136876,
+ 1839571451,
+ -253624458,
+ -45200418,
+ 1063910,
+ -1553,
+ -245408,
+ 12232598,
+ 68453142,
+ -13899142,
+ 531511061,
+ 122813440,
+ 9334234,
+ -674064,
+ -1136928,
+ -36539028,
+ -78882399,
+ 1834683416,
+ -257162132,
+ -45081993,
+ 1146000,
+ -1699,
+ -238567,
+ 12193264,
+ 66819897,
+ -23784312,
+ 546336892,
+ 123459913,
+ 9138979,
+ -686954,
+ -1162144,
+ -36090737,
+ -74645911,
+ 1829571733,
+ -260643560,
+ -44945038,
+ 1229503,
+ -1860,
+ -231861,
+ 12150209,
+ 65180954,
+ -33519715,
+ 561223623,
+ 124067265,
+ 8937199,
+ -699950,
+ -1186276,
+ -35635233,
+ -70428773,
+ 1824237552,
+ -264066805,
+ -44789362,
+ 1314418,
+ -2029,
+ -225292,
+ 12103511,
+ 63537003,
+ -43104364,
+ 576168343,
+ 124634808,
+ 8728869,
+ -713047,
+ -1209336,
+ -35172792,
+ -66232349,
+ 1818682025,
+ -267429934,
+ -44614773,
+ 1400738,
+ -2213,
+ -218857,
+ 12053256,
+ 61888737,
+ -52537326,
+ 591168240,
+ 125161865,
+ 8513969,
+ -726242,
+ -1231343,
+ -34703690,
+ -62057948,
+ 1812906559,
+ -270731046,
+ -44421094,
+ 1488456,
+ -2399,
+ -212555,
+ 11999523,
+ 60236835,
+ -61817704,
+ 606220373,
+ 125647778,
+ 8292474,
+ -739530,
+ -1252310,
+ -34228202,
+ -57906879,
+ 1806912687,
+ -273968158,
+ -44208148,
+ 1577565,
+ -2604,
+ -206385,
+ 11942397,
+ 58581971,
+ -70944656,
+ 621321928,
+ 126091878,
+ 8064369,
+ -752908,
+ -1272254,
+ -33746600,
+ -53780422,
+ 1800701688,
+ -277139383,
+ -43975768,
+ 1668059,
+ -2820,
+ -200346,
+ 11881955,
+ 56924818,
+ -79917379,
+ 636469965,
+ 126493516,
+ 7829636,
+ -766373,
+ -1291190,
+ -33259160,
+ -49679822,
+ 1794275225,
+ -280242773,
+ -43723784,
+ 1759928,
+ -3048,
+ -194436,
+ 11818284,
+ 55266031,
+ -88735128,
+ 651661542,
+ 126852045,
+ 7588261,
+ -779919,
+ -1309133,
+ -32766147,
+ -45606328,
+ 1787634704,
+ -283276408,
+ -43452040,
+ 1853164,
+ -3291,
+ -188655,
+ 11751464,
+ 53606268,
+ -97397185,
+ 666893591,
+ 127166842,
+ 7340235,
+ -793543,
+ -1326100,
+ -32267834,
+ -41561141,
+ 1780781788,
+ -286238339,
+ -43160380,
+ 1947755,
+ -3546,
+ -183000,
+ 11681576,
+ 51946174,
+ -105902903,
+ 682163170,
+ 127437275,
+ 7085550,
+ -807240,
+ -1342106,
+ -31764488,
+ -37545449,
+ 1773718138,
+ -289126680,
+ -42848664,
+ 2043691,
+ -3817,
+ -177470,
+ 11608702,
+ 50286391,
+ -114251658,
+ 697467275,
+ 127662729,
+ 6824201,
+ -821005,
+ -1357168,
+ -31256376,
+ -33560418,
+ 1766445418,
+ -291939512,
+ -42516749,
+ 2140962,
+ -4104,
+ -172065,
+ 11532925,
+ 48627548,
+ -122442891,
+ 712802772,
+ 127842621,
+ 6556182,
+ -834834,
+ -1371302,
+ -30743761,
+ -29607183,
+ 1758965418,
+ -294674886,
+ -42164497,
+ 2239552,
+ -4407,
+ -166782,
+ 11454324,
+ 46970271,
+ -130476089,
+ 728166720,
+ 127976336,
+ 6281497,
+ -848720,
+ -1384525,
+ -30226907,
+ -25686861,
+ 1751279927,
+ -297330947,
+ -41791782,
+ 2339450,
+ -4726,
+ -161619,
+ 11372984,
+ 45315179,
+ -138350759,
+ 743555924,
+ 128063312,
+ 6000147,
+ -862660,
+ -1396853,
+ -29706072,
+ -21800546,
+ 1743390736,
+ -299905746,
+ -41398484,
+ 2440641,
+ -5063,
+ -156576,
+ 11288982,
+ 43662873,
+ -146066491,
+ 758967377,
+ 128102969,
+ 5712138,
+ -876647,
+ -1408300,
+ -29181515,
+ -17949299,
+ 1735299891,
+ -302397428,
+ -40984486,
+ 2543109,
+ -5419,
+ -151651,
+ 11202401,
+ 42013960,
+ -153622911,
+ 774397883,
+ 128094753,
+ 5417478,
+ -890678,
+ -1418886,
+ -28653494,
+ -14134166,
+ 1727009310,
+ -304804107,
+ -40549690,
+ 2646840,
+ -5791,
+ -146844,
+ 11113321,
+ 40369027,
+ -161019651,
+ 789844245,
+ 128038122,
+ 5116181,
+ -904743,
+ -1428625,
+ -28122264,
+ -10356165,
+ 1718520783,
+ -307123865,
+ -40093982,
+ 2751814,
+ -6186,
+ -142150,
+ 11021821,
+ 38728657,
+ -168256455,
+ 805303458,
+ 127932539,
+ 4808258,
+ -918840,
+ -1437534,
+ -27588076,
+ -6616290,
+ 1709836484,
+ -309354879,
+ -39617279,
+ 2858016,
+ -6598,
+ -137571,
+ 10927981,
+ 37093429,
+ -175333051,
+ 820772198,
+ 127777495,
+ 4493730,
+ -932961,
+ -1445629,
+ -27051178,
+ -2915508,
+ 1700958587,
+ -311495233,
+ -39119489,
+ 2965425,
+ -7033,
+ -133102,
+ 10831882,
+ 35463901,
+ -182249264,
+ 836247332,
+ 127572476,
+ 4172615,
+ -947100,
+ -1452928,
+ -26511818,
+ 745237,
+ 1691889137,
+ -313543135,
+ -38600541,
+ 3074022,
+ -7490,
+ -128745,
+ 10733601,
+ 33840633,
+ -189004918,
+ 851725726,
+ 127316996,
+ 3844938,
+ -961250,
+ -1459445,
+ -25970244,
+ 4365026,
+ 1682630182,
+ -315496731,
+ -38060358,
+ 3183786,
+ -7968,
+ -124495,
+ 10633217,
+ 32224176,
+ -195599932,
+ 867204056,
+ 127010574,
+ 3510727,
+ -975406,
+ -1465198,
+ -25426694,
+ 7942965,
+ 1673184021,
+ -317354168,
+ -37498876,
+ 3294696,
+ -8471,
+ -120354,
+ 10530807,
+ 30615062,
+ -202034212,
+ 882679125,
+ 126652740,
+ 3170010,
+ -989557,
+ -1470203,
+ -24881410,
+ 11478186,
+ 1663552958,
+ -319113687,
+ -36916043,
+ 3406729,
+ -8997,
+ -116316,
+ 10426450,
+ 29013825,
+ -208307756,
+ 898147673,
+ 126243063,
+ 2822820,
+ -1003701,
+ -1474477,
+ -24334629,
+ 14969846,
+ 1653739293,
+ -320773402,
+ -36311812,
+ 3519863,
+ -9548,
+ -112383,
+ 10320221,
+ 27420984,
+ -214420597,
+ 913606503,
+ 125781085,
+ 2469197,
+ -1017828,
+ -1478035,
+ -23786586,
+ 18417126,
+ 1643745329,
+ -322331586,
+ -35686142,
+ 3634069,
+ -10127,
+ -108551,
+ 10212199,
+ 25837045,
+ -220372783,
+ 929052290,
+ 125266408,
+ 2109177,
+ -1031931,
+ -1480895,
+ -23237509,
+ 21819235,
+ 1633573367,
+ -323786481,
+ -35038998,
+ 3749327,
+ -10731,
+ -104820,
+ 10102455,
+ 24262515,
+ -226164425,
+ 944481773,
+ 124698617,
+ 1742804,
+ -1046002,
+ -1483070,
+ -22687630,
+ 25175401,
+ 1623225965,
+ -325136266,
+ -34370367,
+ 3865607,
+ -11365,
+ -101188,
+ 9991069,
+ 22697879,
+ -231795700,
+ 959891755,
+ 124077334,
+ 1370127,
+ -1060035,
+ -1484581,
+ -22137173,
+ 28484887,
+ 1612705424,
+ -326379214,
+ -33680226,
+ 3982883,
+ -12026,
+ -97653,
+ 9878113,
+ 21143623,
+ -237266800,
+ 975278785,
+ 123402170,
+ 991192,
+ -1074018,
+ -1485439,
+ -21586364,
+ 31746973,
+ 1602014430,
+ -327513631,
+ -32968570,
+ 4101126,
+ -12718,
+ -94213,
+ 9763662,
+ 19600216,
+ -242577947,
+ 990639729,
+ 122672796,
+ 606054,
+ -1087947,
+ -1485664,
+ -21035418,
+ 34960968,
+ 1591155284,
+ -328537789,
+ -32235404,
+ 4220306,
+ -13441,
+ -90868,
+ 9647787,
+ 18068122,
+ -247729463,
+ 1005971198,
+ 121888853,
+ 214771,
+ -1101811,
+ -1485268,
+ -20484553,
+ 38126204,
+ 1580130799,
+ -329449996,
+ -31480740,
+ 4340393,
+ -14195,
+ -87613,
+ 9530562,
+ 16547787,
+ -252721633,
+ 1021269932,
+ 121050029,
+ -182600,
+ -1115603,
+ -1484271,
+ -19933986,
+ 41242045,
+ 1568943278,
+ -330248557,
+ -30704593,
+ 4461357,
+ -14982,
+ -84450,
+ 9412058,
+ 15039657,
+ -257554859,
+ 1036532670,
+ 120156028,
+ -585993,
+ -1129313,
+ -1482686,
+ -19383923,
+ 44307872,
+ 1557595661,
+ -330931809,
+ -29906997,
+ 4583163,
+ -15802,
+ -81376,
+ 9292346,
+ 13544163,
+ -262229524,
+ 1051755959,
+ 119206554,
+ -995343,
+ -1142932,
+ -1480530,
+ -18834573,
+ 47323094,
+ 1546090378,
+ -331498154,
+ -29087987,
+ 4705780,
+ -16658,
+ -78389,
+ 9171497,
+ 12061725,
+ -266746107,
+ 1066936603,
+ 118201344,
+ -1410576,
+ -1156450,
+ -1477817,
+ -18286140,
+ 50287143,
+ 1534430370,
+ -331945962,
+ -28247612,
+ 4829171,
+ -17550,
+ -75486,
+ 9049580,
+ 10592756,
+ -271105072,
+ 1082071278,
+ 117140151,
+ -1831622,
+ -1169860,
+ -1474564,
+ -17738823,
+ 53199487,
+ 1522618194,
+ -332273634,
+ -27385927,
+ 4953303,
+ -18479,
+ -72669,
+ 8926663,
+ 9137654,
+ -275306945,
+ 1097156593,
+ 116022741,
+ -2258399,
+ -1183150,
+ -1470785,
+ -17192824,
+ 56059604,
+ 1510656663,
+ -332479572,
+ -26502998,
+ 5078136,
+ -19447,
+ -69933,
+ 8802814,
+ 7696812,
+ -279352336,
+ 1112189353,
+ 114848908,
+ -2690830,
+ -1196312,
+ -1466496,
+ -16648332,
+ 58867010,
+ 1498548591,
+ -332562273,
+ -25598901,
+ 5203636,
+ -20453,
+ -67279,
+ 8678100,
+ 6270610,
+ -283241851,
+ 1127166233,
+ 113618460,
+ -3128828,
+ -1209334,
+ -1461712,
+ -16105538,
+ 61621237,
+ 1486296791,
+ -332520171,
+ -24673718,
+ 5329762,
+ -21500,
+ -64702,
+ 8552589,
+ 4859418,
+ -286976097,
+ 1142083781,
+ 112331228,
+ -3572305,
+ -1222208,
+ -1456448,
+ -15564632,
+ 64321842,
+ 1473904204,
+ -332351764,
+ -23727545,
+ 5456476,
+ -22589,
+ -62205,
+ 8426342,
+ 3463593,
+ -290555777,
+ 1156938927,
+ 110987054,
+ -4021168,
+ -1234922,
+ -1450719,
+ -15025794,
+ 66968413,
+ 1461373516,
+ -332055548,
+ -22760487,
+ 5583736,
+ -23721,
+ -59781,
+ 8299428,
+ 2083486,
+ -293981660,
+ 1171728219,
+ 109585801,
+ -4475321,
+ -1247465,
+ -1444539,
+ -14489207,
+ 69560562,
+ 1448707922,
+ -331630118,
+ -21772654,
+ 5711501,
+ -24897,
+ -57434,
+ 8171907,
+ 719436,
+ -297254448,
+ 1186448460,
+ 108127372,
+ -4934665,
+ -1259828,
+ -1437922,
+ -13955046,
+ 72097918,
+ 1435910109,
+ -331074003,
+ -20764169,
+ 5839727,
+ -26120,
+ -55157,
+ 8043844,
+ -628229,
+ -300375004,
+ 1201096198,
+ 106611666,
+ -5399098,
+ -1271999,
+ -1430884,
+ -13423484,
+ 74580145,
+ 1422983144,
+ -330385827,
+ -19735167,
+ 5968372,
+ -27389,
+ -52953,
+ 7915299,
+ -1959192,
+ -303344096,
+ 1215668363,
+ 105038608,
+ -5868513,
+ -1283966,
+ -1423437,
+ -12894690,
+ 77006916,
+ 1409930099,
+ -329564186,
+ -18685792,
+ 6097390,
+ -28705,
+ -50817,
+ 7786333,
+ -3273145,
+ -306162683,
+ 1230161631,
+ 103408160,
+ -6342798,
+ -1295718,
+ -1415598,
+ -12368832,
+ 79377951,
+ 1396753912,
+ -328607735,
+ -17616192,
+ 6226736,
+ -30071,
+ -48750,
+ 7657006,
+ -4569792,
+ -308831595,
+ 1244572805,
+ 101720290,
+ -6821838,
+ -1307244,
+ -1407379,
+ -11846070,
+ 81692969,
+ 1383457654,
+ -327515133,
+ -16526534,
+ 6356361,
+ -31488,
+ -46749,
+ 7527378,
+ -5848844,
+ -311351825,
+ 1258898433,
+ 99974997,
+ -7305518,
+ -1318533,
+ -1398794,
+ -11326563,
+ 83951732,
+ 1370044392,
+ -326285132,
+ -15416990,
+ 6486220,
+ -32957,
+ -44814,
+ 7397505,
+ -7110029,
+ -313724330,
+ 1273135446,
+ 98172281,
+ -7793714,
+ -1329571,
+ -1389856,
+ -10810467,
+ 86154024,
+ 1356517069,
+ -324916422,
+ -14287743,
+ 6616262,
+ -34479,
+ -42941,
+ 7267445,
+ -8353079,
+ -315950134,
+ 1287280647,
+ 96312199,
+ -8286302,
+ -1340347,
+ -1380580,
+ -10297932,
+ 88299636,
+ 1342878881,
+ -323407757,
+ -13138985,
+ 6746439,
+ -36056,
+ -41131,
+ 7137254,
+ -9577739,
+ -318030291,
+ 1301330839,
+ 94394799,
+ -8783153,
+ -1350849,
+ -1370978,
+ -9789106,
+ 90388401,
+ 1329133152,
+ -321757952,
+ -11970921,
+ 6876697,
+ -37690,
+ -39381,
+ 7006987,
+ -10783764,
+ -319965858,
+ 1315282697,
+ 92420159,
+ -9284133,
+ -1361064,
+ -1361064,
+ -9284133,
+ 92420159,
+ 1315282697,
+ -319965858,
+ -10783764,
+ 7006987,
+ -39381,
+ -37690,
+ 6876697,
+ -11970921,
+ -321757952,
+ 1329133152,
+ 90388401,
+ -9789106,
+ -1370978,
+ -1350849,
+ -8783153,
+ 94394799,
+ 1301330839,
+ -318030291,
+ -9577739,
+ 7137254,
+ -41131,
+ -36056,
+ 6746439,
+ -13138985,
+ -323407757,
+ 1342878881,
+ 88299636,
+ -10297932,
+ -1380580,
+ -1340347,
+ -8286302,
+ 96312199,
+ 1287280647,
+ -315950134,
+ -8353079,
+ 7267445,
+ -42941,
+ -34479,
+ 6616262,
+ -14287743,
+ -324916422,
+ 1356517069,
+ 86154024,
+ -10810467,
+ -1389856,
+ -1329571,
+ -7793714,
+ 98172281,
+ 1273135446,
+ -313724330,
+ -7110029,
+ 7397505,
+ -44814,
+ -32957,
+ 6486220,
+ -15416990,
+ -326285132,
+ 1370044392,
+ 83951732,
+ -11326563,
+ -1398794,
+ -1318533,
+ -7305518,
+ 99974997,
+ 1258898433,
+ -311351825,
+ -5848844,
+ 7527378,
+ -46749,
+ -31488,
+ 6356361,
+ -16526534,
+ -327515133,
+ 1383457654,
+ 81692969,
+ -11846070,
+ -1407379,
+ -1307244,
+ -6821838,
+ 101720290,
+ 1244572805,
+ -308831595,
+ -4569792,
+ 7657006,
+ -48750,
+ -30071,
+ 6226736,
+ -17616192,
+ -328607735,
+ 1396753912,
+ 79377951,
+ -12368832,
+ -1415598,
+ -1295718,
+ -6342798,
+ 103408160,
+ 1230161631,
+ -306162683,
+ -3273145,
+ 7786333,
+ -50817,
+ -28705,
+ 6097390,
+ -18685792,
+ -329564186,
+ 1409930099,
+ 77006916,
+ -12894690,
+ -1423437,
+ -1283966,
+ -5868513,
+ 105038608,
+ 1215668363,
+ -303344096,
+ -1959192,
+ 7915299,
+ -52953,
+ -27389,
+ 5968372,
+ -19735167,
+ -330385827,
+ 1422983144,
+ 74580145,
+ -13423484,
+ -1430884,
+ -1271999,
+ -5399098,
+ 106611666,
+ 1201096198,
+ -300375004,
+ -628229,
+ 8043844,
+ -55157,
+ -26120,
+ 5839727,
+ -20764169,
+ -331074003,
+ 1435910109,
+ 72097918,
+ -13955046,
+ -1437922,
+ -1259828,
+ -4934665,
+ 108127372,
+ 1186448460,
+ -297254448,
+ 719436,
+ 8171907,
+ -57434,
+ -24897,
+ 5711501,
+ -21772654,
+ -331630118,
+ 1448707922,
+ 69560562,
+ -14489207,
+ -1444539,
+ -1247465,
+ -4475321,
+ 109585801,
+ 1171728219,
+ -293981660,
+ 2083486,
+ 8299428,
+ -59781,
+ -23721,
+ 5583736,
+ -22760487,
+ -332055548,
+ 1461373516,
+ 66968413,
+ -15025794,
+ -1450719,
+ -1234922,
+ -4021168,
+ 110987054,
+ 1156938927,
+ -290555777,
+ 3463593,
+ 8426342,
+ -62205,
+ -22589,
+ 5456476,
+ -23727545,
+ -332351764,
+ 1473904204,
+ 64321842,
+ -15564632,
+ -1456448,
+ -1222208,
+ -3572305,
+ 112331228,
+ 1142083781,
+ -286976097,
+ 4859418,
+ 8552589,
+ -64702,
+ -21500,
+ 5329762,
+ -24673718,
+ -332520171,
+ 1486296791,
+ 61621237,
+ -16105538,
+ -1461712,
+ -1209334,
+ -3128828,
+ 113618460,
+ 1127166233,
+ -283241851,
+ 6270610,
+ 8678100,
+ -67279,
+ -20453,
+ 5203636,
+ -25598901,
+ -332562273,
+ 1498548591,
+ 58867010,
+ -16648332,
+ -1466496,
+ -1196312,
+ -2690830,
+ 114848908,
+ 1112189353,
+ -279352336,
+ 7696812,
+ 8802814,
+ -69933,
+ -19447,
+ 5078136,
+ -26502998,
+ -332479572,
+ 1510656663,
+ 56059604,
+ -17192824,
+ -1470785,
+ -1183150,
+ -2258399,
+ 116022741,
+ 1097156593,
+ -275306945,
+ 9137654,
+ 8926663,
+ -72669,
+ -18479,
+ 4953303,
+ -27385927,
+ -332273634,
+ 1522618194,
+ 53199487,
+ -17738823,
+ -1474564,
+ -1169860,
+ -1831622,
+ 117140151,
+ 1082071278,
+ -271105072,
+ 10592756,
+ 9049580,
+ -75486,
+ -17550,
+ 4829171,
+ -28247612,
+ -331945962,
+ 1534430370,
+ 50287143,
+ -18286140,
+ -1477817,
+ -1156450,
+ -1410576,
+ 118201344,
+ 1066936603,
+ -266746107,
+ 12061725,
+ 9171497,
+ -78389,
+ -16658,
+ 4705780,
+ -29087987,
+ -331498154,
+ 1546090378,
+ 47323094,
+ -18834573,
+ -1480530,
+ -1142932,
+ -995343,
+ 119206554,
+ 1051755959,
+ -262229524,
+ 13544163,
+ 9292346,
+ -81376,
+ -15802,
+ 4583163,
+ -29906997,
+ -330931809,
+ 1557595661,
+ 44307872,
+ -19383923,
+ -1482686,
+ -1129313,
+ -585993,
+ 120156028,
+ 1036532670,
+ -257554859,
+ 15039657,
+ 9412058,
+ -84450,
+ -14982,
+ 4461357,
+ -30704593,
+ -330248557,
+ 1568943278,
+ 41242045,
+ -19933986,
+ -1484271,
+ -1115603,
+ -182600,
+ 121050029,
+ 1021269932,
+ -252721633,
+ 16547787,
+ 9530562,
+ -87613,
+ -14195,
+ 4340393,
+ -31480740,
+ -329449996,
+ 1580130799,
+ 38126204,
+ -20484553,
+ -1485268,
+ -1101811,
+ 214771,
+ 121888853,
+ 1005971198,
+ -247729463,
+ 18068122,
+ 9647787,
+ -90868,
+ -13441,
+ 4220306,
+ -32235404,
+ -328537789,
+ 1591155284,
+ 34960968,
+ -21035418,
+ -1485664,
+ -1087947,
+ 606054,
+ 122672796,
+ 990639729,
+ -242577947,
+ 19600216,
+ 9763662,
+ -94213,
+ -12718,
+ 4101126,
+ -32968570,
+ -327513631,
+ 1602014430,
+ 31746973,
+ -21586364,
+ -1485439,
+ -1074018,
+ 991192,
+ 123402170,
+ 975278785,
+ -237266800,
+ 21143623,
+ 9878113,
+ -97653,
+ -12026,
+ 3982883,
+ -33680226,
+ -326379214,
+ 1612705424,
+ 28484887,
+ -22137173,
+ -1484581,
+ -1060035,
+ 1370127,
+ 124077334,
+ 959891755,
+ -231795700,
+ 22697879,
+ 9991069,
+ -101188,
+ -11365,
+ 3865607,
+ -34370367,
+ -325136266,
+ 1623225965,
+ 25175401,
+ -22687630,
+ -1483070,
+ -1046002,
+ 1742804,
+ 124698617,
+ 944481773,
+ -226164425,
+ 24262515,
+ 10102455,
+ -104820,
+ -10731,
+ 3749327,
+ -35038998,
+ -323786481,
+ 1633573367,
+ 21819235,
+ -23237509,
+ -1480895,
+ -1031931,
+ 2109177,
+ 125266408,
+ 929052290,
+ -220372783,
+ 25837045,
+ 10212199,
+ -108551,
+ -10127,
+ 3634069,
+ -35686142,
+ -322331586,
+ 1643745329,
+ 18417126,
+ -23786586,
+ -1478035,
+ -1017828,
+ 2469197,
+ 125781085,
+ 913606503,
+ -214420597,
+ 27420984,
+ 10320221,
+ -112383,
+ -9548,
+ 3519863,
+ -36311812,
+ -320773402,
+ 1653739293,
+ 14969846,
+ -24334629,
+ -1474477,
+ -1003701,
+ 2822820,
+ 126243063,
+ 898147673,
+ -208307756,
+ 29013825,
+ 10426450,
+ -116316,
+ -8997,
+ 3406729,
+ -36916043,
+ -319113687,
+ 1663552958,
+ 11478186,
+ -24881410,
+ -1470203,
+ -989557,
+ 3170010,
+ 126652740,
+ 882679125,
+ -202034212,
+ 30615062,
+ 10530807,
+ -120354,
+ -8471,
+ 3294696,
+ -37498876,
+ -317354168,
+ 1673184021,
+ 7942965,
+ -25426694,
+ -1465198,
+ -975406,
+ 3510727,
+ 127010574,
+ 867204056,
+ -195599932,
+ 32224176,
+ 10633217,
+ -124495,
+ -7968,
+ 3183786,
+ -38060358,
+ -315496731,
+ 1682630182,
+ 4365026,
+ -25970244,
+ -1459445,
+ -961250,
+ 3844938,
+ 127316996,
+ 851725726,
+ -189004918,
+ 33840633,
+ 10733601,
+ -128745,
+ -7490,
+ 3074022,
+ -38600541,
+ -313543135,
+ 1691889137,
+ 745237,
+ -26511818,
+ -1452928,
+ -947100,
+ 4172615,
+ 127572476,
+ 836247332,
+ -182249264,
+ 35463901,
+ 10831882,
+ -133102,
+ -7033,
+ 2965425,
+ -39119489,
+ -311495233,
+ 1700958587,
+ -2915508,
+ -27051178,
+ -1445629,
+ -932961,
+ 4493730,
+ 127777495,
+ 820772198,
+ -175333051,
+ 37093429,
+ 10927981,
+ -137571,
+ -6598,
+ 2858016,
+ -39617279,
+ -309354879,
+ 1709836484,
+ -6616290,
+ -27588076,
+ -1437534,
+ -918840,
+ 4808258,
+ 127932539,
+ 805303458,
+ -168256455,
+ 38728657,
+ 11021821,
+ -142150,
+ -6186,
+ 2751814,
+ -40093982,
+ -307123865,
+ 1718520783,
+ -10356165,
+ -28122264,
+ -1428625,
+ -904743,
+ 5116181,
+ 128038122,
+ 789844245,
+ -161019651,
+ 40369027,
+ 11113321,
+ -146844,
+ -5791,
+ 2646840,
+ -40549690,
+ -304804107,
+ 1727009310,
+ -14134166,
+ -28653494,
+ -1418886,
+ -890678,
+ 5417478,
+ 128094753,
+ 774397883,
+ -153622911,
+ 42013960,
+ 11202401,
+ -151651,
+ -5419,
+ 2543109,
+ -40984486,
+ -302397428,
+ 1735299891,
+ -17949299,
+ -29181515,
+ -1408300,
+ -876647,
+ 5712138,
+ 128102969,
+ 758967377,
+ -146066491,
+ 43662873,
+ 11288982,
+ -156576,
+ -5063,
+ 2440641,
+ -41398484,
+ -299905746,
+ 1743390736,
+ -21800546,
+ -29706072,
+ -1396853,
+ -862660,
+ 6000147,
+ 128063312,
+ 743555924,
+ -138350759,
+ 45315179,
+ 11372984,
+ -161619,
+ -4726,
+ 2339450,
+ -41791782,
+ -297330947,
+ 1751279927,
+ -25686861,
+ -30226907,
+ -1384525,
+ -848720,
+ 6281497,
+ 127976336,
+ 728166720,
+ -130476089,
+ 46970271,
+ 11454324,
+ -166782,
+ -4407,
+ 2239552,
+ -42164497,
+ -294674886,
+ 1758965418,
+ -29607183,
+ -30743761,
+ -1371302,
+ -834834,
+ 6556182,
+ 127842621,
+ 712802772,
+ -122442891,
+ 48627548,
+ 11532925,
+ -172065,
+ -4104,
+ 2140962,
+ -42516749,
+ -291939512,
+ 1766445418,
+ -33560418,
+ -31256376,
+ -1357168,
+ -821005,
+ 6824201,
+ 127662729,
+ 697467275,
+ -114251658,
+ 50286391,
+ 11608702,
+ -177470,
+ -3817,
+ 2043691,
+ -42848664,
+ -289126680,
+ 1773718138,
+ -37545449,
+ -31764488,
+ -1342106,
+ -807240,
+ 7085550,
+ 127437275,
+ 682163170,
+ -105902903,
+ 51946174,
+ 11681576,
+ -183000,
+ -3546,
+ 1947755,
+ -43160380,
+ -286238339,
+ 1780781788,
+ -41561141,
+ -32267834,
+ -1326100,
+ -793543,
+ 7340235,
+ 127166842,
+ 666893591,
+ -97397185,
+ 53606268,
+ 11751464,
+ -188655,
+ -3291,
+ 1853164,
+ -43452040,
+ -283276408,
+ 1787634704,
+ -45606328,
+ -32766147,
+ -1309133,
+ -779919,
+ 7588261,
+ 126852045,
+ 651661542,
+ -88735128,
+ 55266031,
+ 11818284,
+ -194436,
+ -3048,
+ 1759928,
+ -43723784,
+ -280242773,
+ 1794275225,
+ -49679822,
+ -33259160,
+ -1291190,
+ -766373,
+ 7829636,
+ 126493516,
+ 636469965,
+ -79917379,
+ 56924818,
+ 11881955,
+ -200346,
+ -2820,
+ 1668059,
+ -43975768,
+ -277139383,
+ 1800701688,
+ -53780422,
+ -33746600,
+ -1272254,
+ -752908,
+ 8064369,
+ 126091878,
+ 621321928,
+ -70944656,
+ 58581971,
+ 11942397,
+ -206385,
+ -2604,
+ 1577565,
+ -44208148,
+ -273968158,
+ 1806912687,
+ -57906879,
+ -34228202,
+ -1252310,
+ -739530,
+ 8292474,
+ 125647778,
+ 606220373,
+ -61817704,
+ 60236835,
+ 11999523,
+ -212555,
+ -2399,
+ 1488456,
+ -44421094,
+ -270731046,
+ 1812906559,
+ -62057948,
+ -34703690,
+ -1231343,
+ -726242,
+ 8513969,
+ 125161865,
+ 591168240,
+ -52537326,
+ 61888737,
+ 12053256,
+ -218857,
+ -2213,
+ 1400738,
+ -44614773,
+ -267429934,
+ 1818682025,
+ -66232349,
+ -35172792,
+ -1209336,
+ -713047,
+ 8728869,
+ 124634808,
+ 576168343,
+ -43104364,
+ 63537003,
+ 12103511,
+ -225292,
+ -2029,
+ 1314418,
+ -44789362,
+ -264066805,
+ 1824237552,
+ -70428773,
+ -35635233,
+ -1186276,
+ -699950,
+ 8937199,
+ 124067265,
+ 561223623,
+ -33519715,
+ 65180954,
+ 12150209,
+ -231861,
+ -1860,
+ 1229503,
+ -44945038,
+ -260643560,
+ 1829571733,
+ -74645911,
+ -36090737,
+ -1162144,
+ -686954,
+ 9138979,
+ 123459913,
+ 546336892,
+ -23784312,
+ 66819897,
+ 12193264,
+ -238567,
+ -1699,
+ 1146000,
+ -45081993,
+ -257162132,
+ 1834683416,
+ -78882399,
+ -36539028,
+ -1136928,
+ -674064,
+ 9334234,
+ 122813440,
+ 531511061,
+ -13899142,
+ 68453142,
+ 12232598,
+ -245408,
+ -1553,
+ 1063910,
+ -45200418,
+ -253624458,
+ 1839571451,
+ -83136876,
+ -36979827,
+ -1110610,
+ -661281,
+ 9522995,
+ 122128533,
+ 516748846,
+ -3865239,
+ 70079986,
+ 12268128,
+ -252387,
+ -1414,
+ 983240,
+ -45300506,
+ -250032469,
+ 1844234304,
+ -87407961,
+ -37412858,
+ -1083178,
+ -648610,
+ 9705291,
+ 121405897,
+ 502053028,
+ 6316321,
+ 71699732,
+ 12299773,
+ -259505,
+ -1286,
+ 903991,
+ -45382460,
+ -246388101,
+ 1848671206,
+ -91694230,
+ -37837836,
+ -1054615,
+ -636051,
+ 9881154,
+ 120646233,
+ 487426326,
+ 16644414,
+ 73311655,
+ 12327451,
+ -266763,
+ -1163,
+ 826167,
+ -45446484,
+ -242693256,
+ 1852880880,
+ -95994262,
+ -38254491,
+ -1024910,
+ -623611,
+ 10050618,
+ 119850254,
+ 472871487,
+ 27117867,
+ 74915058,
+ 12351085,
+ -274161,
+ -1050,
+ 749769,
+ -45492794,
+ -238949867,
+ 1856862431,
+ -100306601,
+ -38662539,
+ -994045,
+ -611288,
+ 10213721,
+ 119018670,
+ 458391166,
+ 37735463,
+ 76509198,
+ 12370590,
+ -281701,
+ -943,
+ 674800,
+ -45521601,
+ -235159853,
+ 1860614707,
+ -104629769,
+ -39061695,
+ -962008,
+ -599089,
+ 10370501,
+ 118152226,
+ 443987984,
+ 48495944,
+ 78093364,
+ 12385890,
+ -289382,
+ -847,
+ 601258,
+ -45533125,
+ -231325115,
+ 1864137069,
+ -108962281,
+ -39451681,
+ -928784,
+ -587013,
+ 10520999,
+ 117251623,
+ 429664561,
+ 59397991,
+ 79666813,
+ 12396902,
+ -297207,
+ -755,
+ 529144,
+ -45527587,
+ -227447573,
+ 1867428366,
+ -113302616,
+ -39832220,
+ -894361,
+ -575064,
+ 10665257,
+ 116317614,
+ 415423489,
+ 70440257,
+ 81228826,
+ 12403550,
+ -305176,
+ -3119,
+ 458457,
+ -45505213,
+ -223529127,
+ 1870487960,
+ -117649249,
+ -40203029,
+ -858724,
+ -563244,
+ 10803322,
+ 115350934,
+ 401267291,
+ 81621345,
+ 82778650,
+ 12405754,
+ -313288,
+ 0,
+ 389196,
+ -45466240,
+ -219571665,
+ 1873315082,
+ -122000629,
+ -40563828,
+ -821862,
+ -551555,
+ 10935237,
+ 114352309,
+ 387198462,
+ 92939807,
+ 84315552,
+ 12403437,
+ -321546,
+ 0,
+ 321358,
+ -45410900,
+ -215577055,
+ 1875908965,
+ -126355182,
+ -40914333,
+ -783760,
+ -539997,
+ 11061053,
+ 113322508,
+ 373219495,
+ 104394141,
+ 85838779,
+ 12396521,
+ -329949,
+ 0,
+ 254942,
+ -45339427,
+ -211547217,
+ 1878269099,
+ -130711326,
+ -41254268,
+ -744409,
+ -528575,
+ 11180820,
+ 112262265,
+ 359332819,
+ 115982829,
+ 87347581,
+ 12384930,
+ -338497,
+ 0,
+ 189943,
+ -45252071,
+ -207484004,
+ 1880394843,
+ -135067453,
+ -41583351,
+ -703793,
+ -517288,
+ 11294588,
+ 111172348,
+ 345540833,
+ 127704280,
+ 88841206,
+ 12368587,
+ -347192,
+ 0,
+ 126359,
+ -45149066,
+ -203389287,
+ 1882285814,
+ -139421942,
+ -41901309,
+ -661902,
+ -506138,
+ 11402413,
+ 110053500,
+ 331845902,
+ 139556879,
+ 90318903,
+ 12347418,
+ -356033,
+ 0,
+ 64184,
+ -45030664,
+ -199264904,
+ 1883941245,
+ -143773139,
+ -42207858,
+ -618725,
+ -495127,
+ 11504349,
+ 108906481,
+ 318250359,
+ 151538949,
+ 91779912,
+ 12321347,
+ -365021,
+ 0,
+ 3414,
+ -44897122,
+ -195112708,
+ 1885361136,
+ -148119396,
+ -42502723,
+ -574250,
+ -484256,
+ 11600452,
+ 107732056,
+ 304756474,
+ 163648779,
+ 93223467,
+ 12290303,
+ -374154,
+ 0,
+ -55958,
+ -44748687,
+ -190934538,
+ 1886544719,
+ -152459036,
+ -42785628,
+ -528467,
+ -473526,
+ 11690782,
+ 106530986,
+ 291366486,
+ 175884611,
+ 94648808,
+ 12254212,
+ -383435,
+ 0,
+ -113935,
+ -44585610,
+ -186732217,
+ 1887491995,
+ -156790381,
+ -43056301,
+ -481365,
+ -462939,
+ 11775396,
+ 105304039,
+ 278082663,
+ 188244655,
+ 96055185,
+ 12213002,
+ -392863,
+ 0,
+ -170525,
+ -44408163,
+ -182507550,
+ 1888202707,
+ -161111719,
+ -43314458,
+ -432934,
+ -452493,
+ 11854358,
+ 104051972,
+ 264907100,
+ 200727056,
+ 97441805,
+ 12166601,
+ -402437,
+ 0,
+ -225736,
+ -44216595,
+ -178262343,
+ 1888676601,
+ -165421325,
+ -43559841,
+ -383164,
+ -442192,
+ 11927728,
+ 102775562,
+ 251841986,
+ 213329945,
+ 98807925,
+ 12114943,
+ -412156,
+ 0,
+ -279574,
+ -44011177,
+ -173998387,
+ 1888913548,
+ -169717457,
+ -43792168,
+ -332048,
+ -432035,
+ 11995573,
+ 101475575,
+ 238889399,
+ 226051370,
+ 100152771,
+ 12057955,
+ -422024
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.dat
new file mode 100644
index 0000000..f3696d1
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.dat
@@ -0,0 +1,2562 @@
+ -540643,
+ 1049478,
+ 9120963,
+ -42914890,
+ 108606645,
+ -194403322,
+ 267053128,
+ 1841778905,
+ 278610646,
+ -197980653,
+ 109499655,
+ -42915649,
+ 8981898,
+ 1114874,
+ -550250,
+ -5103,
+ -531109,
+ 985120,
+ 9255277,
+ -42901268,
+ 107690338,
+ -190804125,
+ 255581155,
+ 1841593235,
+ 290252177,
+ -201534855,
+ 110368825,
+ -42903390,
+ 8838056,
+ 1181304,
+ -559931,
+ -1056,
+ -521653,
+ 921799,
+ 9384870,
+ -42874938,
+ 106751238,
+ -187184388,
+ 244196199,
+ 1841221895,
+ 301976218,
+ -205064634,
+ 111213643,
+ -42877955,
+ 8689411,
+ 1248765,
+ -569681,
+ -1167,
+ -512275,
+ 859518,
+ 9509767,
+ -42836069,
+ 105789888,
+ -183545359,
+ 232899731,
+ 1840665012,
+ 313781201,
+ -208568679,
+ 112033582,
+ -42839190,
+ 8535941,
+ 1317256,
+ -579499,
+ -1282,
+ -502977,
+ 798277,
+ 9630001,
+ -42784820,
+ 104806800,
+ -179888332,
+ 221693189,
+ 1839922716,
+ 325665528,
+ -212045678,
+ 112828147,
+ -42786950,
+ 8377620,
+ 1386774,
+ -589384,
+ -1408,
+ -493761,
+ 738075,
+ 9745603,
+ -42721356,
+ 103802518,
+ -176214553,
+ 210577947,
+ 1838995132,
+ 337627602,
+ -215494306,
+ 113596801,
+ -42721084,
+ 8214429,
+ 1457313,
+ -599330,
+ -1538,
+ -484628,
+ 678915,
+ 9856605,
+ -42645851,
+ 102777568,
+ -172525270,
+ 199555429,
+ 1837882262,
+ 349665760,
+ -218913268,
+ 114339050,
+ -42641448,
+ 8046349,
+ 1528871,
+ -609339,
+ -1680,
+ -475581,
+ 620794,
+ 9963039,
+ -42558471,
+ 101732478,
+ -168821761,
+ 188626976,
+ 1836584617,
+ 361778403,
+ -222301236,
+ 115054374,
+ -42547906,
+ 7873360,
+ 1601442,
+ -619405,
+ -1826,
+ -466619,
+ 563713,
+ 10064942,
+ -42459386,
+ 100667775,
+ -165105241,
+ 177793900,
+ 1835102325,
+ 373963838,
+ -225656869,
+ 115742278,
+ -42440309,
+ 7695443,
+ 1675021,
+ -629527,
+ -1983,
+ -457747,
+ 507668,
+ 10162347,
+ -42348769,
+ 99584012,
+ -161376958,
+ 167057527,
+ 1833435641,
+ 386220337,
+ -228978840,
+ 116402257,
+ -42318527,
+ 7512586,
+ 1749604,
+ -639701,
+ -2146,
+ -448963,
+ 452661,
+ 10255294,
+ -42226799,
+ 98481700,
+ -157638124,
+ 156419120,
+ 1831584822,
+ 398546175,
+ -232265822,
+ 117033809,
+ -42182431,
+ 7324772,
+ 1825182,
+ -649924,
+ -2325,
+ -440270,
+ 398687,
+ 10343818,
+ -42093652,
+ 97361389,
+ -153889956,
+ 145879910,
+ 1829550506,
+ 410939657,
+ -235516456,
+ 117636454,
+ -42031886,
+ 7131990,
+ 1901751,
+ -660194,
+ -2511,
+ -431669,
+ 345746,
+ 10427958,
+ -41949505,
+ 96223608,
+ -150133668,
+ 135441143,
+ 1827332694,
+ 423398929,
+ -238729432,
+ 118209688,
+ -41866767,
+ 6934227,
+ 1979304,
+ -670508,
+ -2712,
+ -423160,
+ 293834,
+ 10507753,
+ -41794536,
+ 95068884,
+ -146370443,
+ 125104011,
+ 1824932281,
+ 435922297,
+ -241903374,
+ 118753032,
+ -41686951,
+ 6731474,
+ 2057831,
+ -680861,
+ -2912,
+ -414746,
+ 242949,
+ 10583245,
+ -41628929,
+ 93897752,
+ -142601464,
+ 114869663,
+ 1822349267,
+ 448507875,
+ -245036958,
+ 119265999,
+ -41492322,
+ 6523724,
+ 2137327,
+ -691252,
+ -3132,
+ -406426,
+ 193087,
+ 10654473,
+ -41452866,
+ 92710756,
+ -138827913,
+ 104739244,
+ 1819584546,
+ 461153873,
+ -248128823,
+ 119748124,
+ -41282756,
+ 6310969,
+ 2217781,
+ -701676,
+ -3368,
+ -398201,
+ 144245,
+ 10721481,
+ -41266524,
+ 91508424,
+ -135050942,
+ 94713863,
+ 1816638503,
+ 473858435,
+ -251177611,
+ 120198921,
+ -41058145,
+ 6093205,
+ 2299185,
+ -712130,
+ -3606,
+ -390075,
+ 96418,
+ 10784310,
+ -41070101,
+ 90291282,
+ -131271741,
+ 84794593,
+ 1813511649,
+ 486619645,
+ -254181996,
+ 120617933,
+ -40818381,
+ 5870428,
+ 2381529,
+ -722610,
+ -3864,
+ -382044,
+ 49604,
+ 10843005,
+ -40863767,
+ 89059859,
+ -127491421,
+ 74982502,
+ 1810204623,
+ 499435680,
+ -257140602,
+ 121004698,
+ -40563352,
+ 5642637,
+ 2464803,
+ -733113,
+ -4131,
+ -374112,
+ 3797,
+ 10897610,
+ -40647720,
+ 87814697,
+ -123711125,
+ 65278608,
+ 1806718193,
+ 512304559,
+ -260052088,
+ 121358760,
+ -40292963,
+ 5409833,
+ 2548996,
+ -743634,
+ -4413,
+ -366277,
+ -41007,
+ 10948170,
+ -40422145,
+ 86556317,
+ -119931980,
+ 55683904,
+ 1803052870,
+ 525224394,
+ -262915094,
+ 121679663,
+ -40007117,
+ 5172016,
+ 2634098,
+ -754169,
+ -4707,
+ -358543,
+ -84815,
+ 10994731,
+ -40187229,
+ 85285245,
+ -116155097,
+ 46199362,
+ 1799209549,
+ 538193236,
+ -265728262,
+ 121966967,
+ -39705715,
+ 4929190,
+ 2720096,
+ -764716,
+ -5018,
+ -350908,
+ -127629,
+ 11037340,
+ -39943157,
+ 84002010,
+ -112381570,
+ 36825913,
+ 1795188742,
+ 551209135,
+ -268490249,
+ 122220233,
+ -39388668,
+ 4681361,
+ 2806978,
+ -775268,
+ -5344,
+ -343372,
+ -169458,
+ 11076043,
+ -39690126,
+ 82707138,
+ -108612487,
+ 27564476,
+ 1790991472,
+ 564269981,
+ -271199697,
+ 122439022,
+ -39055893,
+ 4428537,
+ 2894732,
+ -785822,
+ -5685,
+ -335937,
+ -210306,
+ 11110888,
+ -39428324,
+ 81401149,
+ -104848926,
+ 18415926,
+ 1786618505,
+ 577373920,
+ -273855279,
+ 122622918,
+ -38707302,
+ 4170725,
+ 2983343,
+ -796374,
+ -6042,
+ -328603,
+ -250180,
+ 11141924,
+ -39157939,
+ 80084555,
+ -101091951,
+ 9381115,
+ 1782070610,
+ 590518906,
+ -276455620,
+ 122771490,
+ -38342827,
+ 3907937,
+ 3072798,
+ -806918,
+ -6415,
+ -321369,
+ -289085,
+ 11169201,
+ -38879166,
+ 78757891,
+ -97342616,
+ 460868,
+ 1777348680,
+ 603702829,
+ -278999345,
+ 122884329,
+ -37962388,
+ 3640185,
+ 3163082,
+ -817452,
+ -6806,
+ -314237,
+ -327029,
+ 11192765,
+ -38592197,
+ 77421661,
+ -93601952,
+ -8344024,
+ 1772453740,
+ 616923707,
+ -281485177,
+ 122961036,
+ -37565916,
+ 3367485,
+ 3254181,
+ -827968,
+ -7217,
+ -307206,
+ -364017,
+ 11212670,
+ -38297220,
+ 76076383,
+ -89870991,
+ -17032794,
+ 1767386684,
+ 630179430,
+ -283911708,
+ 123001196,
+ -37153345,
+ 3089851,
+ 3346077,
+ -838465,
+ -7642,
+ -300277,
+ -400059,
+ 11228964,
+ -37994432,
+ 74722571,
+ -86150747,
+ -25604710,
+ 1762148536,
+ 643467888,
+ -286277660,
+ 123004432,
+ -36724623,
+ 2807304,
+ 3438755,
+ -848933,
+ -8090,
+ -293448,
+ -435158,
+ 11241699,
+ -37684022,
+ 73360726,
+ -82442219,
+ -34059059,
+ 1756740189,
+ 656787099,
+ -288581657,
+ 122970355,
+ -36279688,
+ 2519863,
+ 3532197,
+ -859371,
+ -8555,
+ -286722,
+ -469326,
+ 11250926,
+ -37366188,
+ 71991353,
+ -78746391,
+ -42395174,
+ 1751162796,
+ 670134826,
+ -290822359,
+ 122898586,
+ -35818490,
+ 2227550,
+ 3626389,
+ -869771,
+ -9041,
+ -280096,
+ -502568,
+ 11256697,
+ -37041114,
+ 70614962,
+ -75064245,
+ -50612405,
+ 1745417379,
+ 683508959,
+ -292998452,
+ 122788760,
+ -35340984,
+ 1930390,
+ 3721309,
+ -880130,
+ -9548,
+ -273571,
+ -534893,
+ 11259065,
+ -36709002,
+ 69232051,
+ -71396732,
+ -58710131,
+ 1739505218,
+ 696907387,
+ -295108628,
+ 122640509,
+ -34847130,
+ 1628409,
+ 3816940,
+ -890442,
+ -10077,
+ -267148,
+ -566307,
+ 11258081,
+ -36370038,
+ 67843113,
+ -67744803,
+ -66687765,
+ 1733427206,
+ 710327937,
+ -297151575,
+ 122453488,
+ -34336885,
+ 1321634,
+ 3913263,
+ -900699,
+ -10627,
+ -260826,
+ -596822,
+ 11253798,
+ -36024420,
+ 66448641,
+ -64109386,
+ -74544749,
+ 1727184750,
+ 723768435,
+ -299125919,
+ 122227354,
+ -33810228,
+ 1010098,
+ 4010257,
+ -910898,
+ -11201,
+ -254603,
+ -626443,
+ 11246271,
+ -35672332,
+ 65049126,
+ -60491408,
+ -82280549,
+ 1720779002,
+ 737226771,
+ -301030412,
+ 121961772,
+ -33267126,
+ 693831,
+ 4107902,
+ -921033,
+ -11797,
+ -248482,
+ -655180,
+ 11235553,
+ -35313975,
+ 63645055,
+ -56891767,
+ -89894671,
+ 1714211113,
+ 750700644,
+ -302863713,
+ 121656414,
+ -32707558,
+ 372869,
+ 4206178,
+ -931097,
+ -12418,
+ -242460,
+ -683040,
+ 11221697,
+ -34949535,
+ 62236909,
+ -53311355,
+ -97386636,
+ 1707482360,
+ 764187943,
+ -304624574,
+ 121310952,
+ -32131508,
+ 47247,
+ 4305060,
+ -941085,
+ -13064,
+ -236539,
+ -710036,
+ 11204758,
+ -34579210,
+ 60825166,
+ -49751051,
+ -104756011,
+ 1700594279,
+ 777686367,
+ -306311654,
+ 120925098,
+ -31538967,
+ -282995,
+ 4404529,
+ -950989,
+ -13735,
+ -230716,
+ -736173,
+ 11184790,
+ -34203179,
+ 59410302,
+ -46211710,
+ -112002374,
+ 1693547893,
+ 791193806,
+ -307923704,
+ 120498533,
+ -30929927,
+ -617817,
+ 4504561,
+ -960804,
+ -14434,
+ -224993,
+ -761462,
+ 11161846,
+ -33821644,
+ 57992785,
+ -42694187,
+ -119125347,
+ 1686344735,
+ 804707895,
+ -309459447,
+ 120030985,
+ -30304389,
+ -957175,
+ 4605132,
+ -970524,
+ -15158,
+ -219366,
+ -785911,
+ 11135984,
+ -33434792,
+ 56573082,
+ -39199309,
+ -126124581,
+ 1678986085,
+ 818226458,
+ -310917635,
+ 119522166,
+ -29662356,
+ -1301026,
+ 4706218,
+ -980142,
+ -15911,
+ -213840,
+ -809533,
+ 11107255,
+ -33042808,
+ 55151661,
+ -35727896,
+ -132999747,
+ 1671473477,
+ 831747260,
+ -312296958,
+ 118971813,
+ -29003839,
+ -1649321,
+ 4807794,
+ -989649,
+ -16691,
+ -208409,
+ -832332,
+ 11075717,
+ -32645881,
+ 53728973,
+ -32280747,
+ -139750542,
+ 1663808318,
+ 845267998,
+ -313596202,
+ 118379662,
+ -28328855,
+ -2002012,
+ 4909835,
+ -999043,
+ -17503,
+ -203077,
+ -854323,
+ 11041424,
+ -32244204,
+ 52305470,
+ -28858652,
+ -146376709,
+ 1655992142,
+ 858786434,
+ -314814119,
+ 117745465,
+ -27637425,
+ -2359046,
+ 5012316,
+ -1008314,
+ -18344,
+ -197839,
+ -875512,
+ 11004431,
+ -31837958,
+ 50881607,
+ -25462384,
+ -152878009,
+ 1648026356,
+ 872300267,
+ -315949462,
+ 117068990,
+ -26929575,
+ -2720370,
+ 5115207,
+ -1017456,
+ -19217,
+ -192697,
+ -895911,
+ 10964792,
+ -31427333,
+ 49457825,
+ -22092697,
+ -159254218,
+ 1639912494,
+ 885807194,
+ -317001050,
+ 116349998,
+ -26205336,
+ -3085927,
+ 5218483,
+ -1026460,
+ -20120,
+ -187650,
+ -915529,
+ 10922566,
+ -31012512,
+ 48034561,
+ -18750337,
+ -165505177,
+ 1631652218,
+ 899305043,
+ -317967666,
+ 115588280,
+ -25464752,
+ -3455662,
+ 5322116,
+ -1035321,
+ -21057,
+ -182698,
+ -934377,
+ 10877804,
+ -30593684,
+ 46612253,
+ -15436029,
+ -171630725,
+ 1623246936,
+ 912791319,
+ -318848065,
+ 114783629,
+ -24707861,
+ -3829511,
+ 5426076,
+ -1044030,
+ -22027,
+ -177839,
+ -952464,
+ 10830565,
+ -30171023,
+ 45191323,
+ -12150482,
+ -177630735,
+ 1614698437,
+ 926263913,
+ -319641095,
+ 113935854,
+ -23934717,
+ -4207412,
+ 5530335,
+ -1052580,
+ -23032,
+ -173073,
+ -969801,
+ 10780901,
+ -29744720,
+ 43772208,
+ -8894395,
+ -183505111,
+ 1606008384,
+ 939720395,
+ -320345606,
+ 113044762,
+ -23145373,
+ -4589302,
+ 5634863,
+ -1060965,
+ -24070,
+ -168398,
+ -986399,
+ 10728869,
+ -29314952,
+ 42355318,
+ -5668445,
+ -189253789,
+ 1597178183,
+ 953158527,
+ -320960350,
+ 112110194,
+ -22339894,
+ -4975113,
+ 5739630,
+ -1069176,
+ -25146,
+ -163816,
+ -1002267,
+ 10674526,
+ -28881897,
+ 40941074,
+ -2473298,
+ -194876736,
+ 1588209880,
+ 966575945,
+ -321484242,
+ 111131981,
+ -21518342,
+ -5364775,
+ 5844605,
+ -1077205,
+ -26258,
+ -159323,
+ -1017416,
+ 10617923,
+ -28445738,
+ 39529875,
+ 690397,
+ -200373937,
+ 1579104882,
+ 979970409,
+ -321916130,
+ 110109980,
+ -20680795,
+ -5758216,
+ 5949753,
+ -1085044,
+ -27408,
+ -154921,
+ -1031856,
+ 10559119,
+ -28006651,
+ 38122132,
+ 3822006,
+ -205745393,
+ 1569864980,
+ 993339490,
+ -322254863,
+ 109044055,
+ -19827333,
+ -6155362,
+ 6055046,
+ -1092684,
+ -28595,
+ -150606,
+ -1045599,
+ 10498167,
+ -27564812,
+ 36718245,
+ 6920914,
+ -210991182,
+ 1560492090,
+ 1006680887,
+ -322499354,
+ 107934078,
+ -18958039,
+ -6556139,
+ 6160448,
+ -1100120,
+ -29825,
+ -146380,
+ -1058655,
+ 10435121,
+ -27120392,
+ 35318598,
+ 9986517,
+ -216111352,
+ 1550987876,
+ 1019992363,
+ -322648485,
+ 106779945,
+ -18073009,
+ -6960467,
+ 6265928,
+ -1107341,
+ -31093,
+ -142241,
+ -1071034,
+ 10370039,
+ -26673572,
+ 33923586,
+ 13018232,
+ -221106001,
+ 1541354127,
+ 1033271486,
+ -322701168,
+ 105581553,
+ -17172334,
+ -7368264,
+ 6371449,
+ -1114340,
+ -32404,
+ -138188,
+ -1082748,
+ 10302971,
+ -26224519,
+ 32533586,
+ 16015486,
+ -225975271,
+ 1531592762,
+ 1046516020,
+ -322656317,
+ 104338821,
+ -16256125,
+ -7779450,
+ 6476979,
+ -1121107,
+ -33755,
+ -134219,
+ -1093806,
+ 10233975,
+ -25773405,
+ 31148974,
+ 18977727,
+ -230719322,
+ 1521705571,
+ 1059723600,
+ -322512908,
+ 103051661,
+ -15324489,
+ -8193936,
+ 6582480,
+ -1127635,
+ -35152,
+ -130336,
+ -1104220,
+ 10163103,
+ -25320398,
+ 29770122,
+ 21904418,
+ -235338298,
+ 1511694472,
+ 1072891858,
+ -322269856,
+ 101720034,
+ -14377543,
+ -8611637,
+ 6687917,
+ -1133914,
+ -36591,
+ -126534,
+ -1114000,
+ 10090409,
+ -24865665,
+ 28397394,
+ 24795032,
+ -239832455,
+ 1501561384,
+ 1086018558,
+ -321926168,
+ 100343876,
+ -13415411,
+ -9032461,
+ 6793254,
+ -1139937,
+ -38078,
+ -122817,
+ -1123158,
+ 10015949,
+ -24409374,
+ 27031146,
+ 27649067,
+ -244201986,
+ 1491308095,
+ 1099101271,
+ -321480821,
+ 98923154,
+ -12438222,
+ -9456318,
+ 6898454,
+ -1145692,
+ -39609,
+ -119180,
+ -1131703,
+ 9939774,
+ -23951688,
+ 25671735,
+ 30466029,
+ -248447176,
+ 1480936653,
+ 1112137821,
+ -320932794,
+ 97457853,
+ -11446110,
+ -9883112,
+ 7003477,
+ -1151174,
+ -41189,
+ -115623,
+ -1139648,
+ 9861937,
+ -23492772,
+ 24319500,
+ 33245445,
+ -252568299,
+ 1470448975,
+ 1125125780,
+ -320281158,
+ 95947972,
+ -10439219,
+ -10312747,
+ 7108286,
+ -1156370,
+ -42815,
+ -112146,
+ -1147002,
+ 9782494,
+ -23032782,
+ 22974786,
+ 35986861,
+ -256565658,
+ 1459846980,
+ 1138062846,
+ -319524891,
+ 94393496,
+ -9417698,
+ -10745123,
+ 7212841,
+ -1161275,
+ -44492,
+ -108748,
+ -1153777,
+ 9701493,
+ -22571882,
+ 21637928,
+ 38689823,
+ -260439620,
+ 1449132841,
+ 1150946717,
+ -318663098,
+ 92794473,
+ -8381698,
+ -11180141,
+ 7317105,
+ -1165876,
+ -46219,
+ -105425,
+ -1159982,
+ 9618989,
+ -22110228,
+ 20309254,
+ 41353917,
+ -264190537,
+ 1438308348,
+ 1163775092,
+ -317694819,
+ 91150910,
+ -7331384,
+ -11617694,
+ 7421035,
+ -1170166,
+ -47997,
+ -102182,
+ -1165630,
+ 9535034,
+ -21647974,
+ 18989084,
+ 43978721,
+ -267818777,
+ 1427375676,
+ 1176545541,
+ -316619160,
+ 89462880,
+ -6266922,
+ -12057678,
+ 7524591,
+ -1174134,
+ -49827,
+ -99011,
+ -1170730,
+ 9449680,
+ -21185278,
+ 17677733,
+ 46563850,
+ -271324788,
+ 1416336742,
+ 1189256018,
+ -315435225,
+ 87730422,
+ -5188485,
+ -12499986,
+ 7627732,
+ -1177771,
+ -51711,
+ -95917,
+ -1175296,
+ 9362977,
+ -20722285,
+ 16375512,
+ 49108914,
+ -274708984,
+ 1405193720,
+ 1201904093,
+ -314142119,
+ 85953624,
+ -4096257,
+ -12944506,
+ 7730417,
+ -1181067,
+ -53648,
+ -92894,
+ -1179333,
+ 9274977,
+ -20259153,
+ 15082724,
+ 51613555,
+ -277971830,
+ 1393948784,
+ 1214487465,
+ -312739044,
+ 84132583,
+ -2990422,
+ -13391125,
+ 7832601,
+ -1184013,
+ -55642,
+ -89945,
+ -1182857,
+ 9185728,
+ -19796026,
+ 13799668,
+ 54077424,
+ -281113805,
+ 1382603724,
+ 1227003960,
+ -311225071,
+ 82267394,
+ -1871174,
+ -13839729,
+ 7934244,
+ -1186599,
+ -57691,
+ -87066,
+ -1185876,
+ 9095284,
+ -19333052,
+ 12526631,
+ 56500187,
+ -284135420,
+ 1371160970,
+ 1239451148,
+ -309599467,
+ 80358177,
+ -738715,
+ -14290202,
+ 8035300,
+ -1188815,
+ -59798,
+ -84258,
+ -1188402,
+ 9003691,
+ -18870371,
+ 11263899,
+ 58881532,
+ -287037251,
+ 1359622441,
+ 1251826856,
+ -307861430,
+ 78405068,
+ 406752,
+ -14742424,
+ 8135726,
+ -1190651,
+ -61963,
+ -81518,
+ -1190444,
+ 8911001,
+ -18408131,
+ 10011750,
+ 61221150,
+ -289819810,
+ 1347990436,
+ 1264128782,
+ -306010132,
+ 76408219,
+ 1565010,
+ -15196274,
+ 8235478,
+ -1192098,
+ -64189,
+ -78847,
+ -1192015,
+ 8817262,
+ -17946472,
+ 8770455,
+ 63518766,
+ -292483704,
+ 1336267003,
+ 1276354752,
+ -304044867,
+ 74367790,
+ 2735841,
+ -15651626,
+ 8334510,
+ -1193143,
+ -66473,
+ -76243,
+ -1193123,
+ 8722523,
+ -17485529,
+ 7540279,
+ 65774100,
+ -295029507,
+ 1324454316,
+ 1288502592,
+ -301964869,
+ 72283964,
+ 3919020,
+ -16108357,
+ 8432777,
+ -1193779,
+ -68821,
+ -73704,
+ -1193779,
+ 8626830,
+ -17025440,
+ 6321481,
+ 67986905,
+ -297457860,
+ 1312554548,
+ 1300569872,
+ -299769434,
+ 70156933,
+ 5114314,
+ -16566338,
+ 8530232,
+ -1193995,
+ -71231,
+ -71231,
+ -1193995,
+ 8530232,
+ -16566338,
+ 5114314,
+ 70156933,
+ -299769434,
+ 1300569872,
+ 1312554548,
+ -297457860,
+ 67986905,
+ 6321481,
+ -17025440,
+ 8626830,
+ -1193779,
+ -73704,
+ -68821,
+ -1193779,
+ 8432777,
+ -16108357,
+ 3919020,
+ 72283964,
+ -301964869,
+ 1288502592,
+ 1324454316,
+ -295029507,
+ 65774100,
+ 7540279,
+ -17485529,
+ 8722523,
+ -1193123,
+ -76243,
+ -66473,
+ -1193143,
+ 8334510,
+ -15651626,
+ 2735841,
+ 74367790,
+ -304044867,
+ 1276354752,
+ 1336267003,
+ -292483704,
+ 63518766,
+ 8770455,
+ -17946472,
+ 8817262,
+ -1192015,
+ -78847,
+ -64189,
+ -1192098,
+ 8235478,
+ -15196274,
+ 1565010,
+ 76408219,
+ -306010132,
+ 1264128782,
+ 1347990436,
+ -289819810,
+ 61221150,
+ 10011750,
+ -18408131,
+ 8911001,
+ -1190444,
+ -81518,
+ -61963,
+ -1190651,
+ 8135726,
+ -14742424,
+ 406752,
+ 78405068,
+ -307861430,
+ 1251826856,
+ 1359622441,
+ -287037251,
+ 58881532,
+ 11263899,
+ -18870371,
+ 9003691,
+ -1188402,
+ -84258,
+ -59798,
+ -1188815,
+ 8035300,
+ -14290202,
+ -738715,
+ 80358177,
+ -309599467,
+ 1239451148,
+ 1371160970,
+ -284135420,
+ 56500187,
+ 12526631,
+ -19333052,
+ 9095284,
+ -1185876,
+ -87066,
+ -57691,
+ -1186599,
+ 7934244,
+ -13839729,
+ -1871174,
+ 82267394,
+ -311225071,
+ 1227003960,
+ 1382603724,
+ -281113805,
+ 54077424,
+ 13799668,
+ -19796026,
+ 9185728,
+ -1182857,
+ -89945,
+ -55642,
+ -1184013,
+ 7832601,
+ -13391125,
+ -2990422,
+ 84132583,
+ -312739044,
+ 1214487465,
+ 1393948784,
+ -277971830,
+ 51613555,
+ 15082724,
+ -20259153,
+ 9274977,
+ -1179333,
+ -92894,
+ -53648,
+ -1181067,
+ 7730417,
+ -12944506,
+ -4096257,
+ 85953624,
+ -314142119,
+ 1201904093,
+ 1405193720,
+ -274708984,
+ 49108914,
+ 16375512,
+ -20722285,
+ 9362977,
+ -1175296,
+ -95917,
+ -51711,
+ -1177771,
+ 7627732,
+ -12499986,
+ -5188485,
+ 87730422,
+ -315435225,
+ 1189256018,
+ 1416336742,
+ -271324788,
+ 46563850,
+ 17677733,
+ -21185278,
+ 9449680,
+ -1170730,
+ -99011,
+ -49827,
+ -1174134,
+ 7524591,
+ -12057678,
+ -6266922,
+ 89462880,
+ -316619160,
+ 1176545541,
+ 1427375676,
+ -267818777,
+ 43978721,
+ 18989084,
+ -21647974,
+ 9535034,
+ -1165630,
+ -102182,
+ -47997,
+ -1170166,
+ 7421035,
+ -11617694,
+ -7331384,
+ 91150910,
+ -317694819,
+ 1163775092,
+ 1438308348,
+ -264190537,
+ 41353917,
+ 20309254,
+ -22110228,
+ 9618989,
+ -1159982,
+ -105425,
+ -46219,
+ -1165876,
+ 7317105,
+ -11180141,
+ -8381698,
+ 92794473,
+ -318663098,
+ 1150946717,
+ 1449132841,
+ -260439620,
+ 38689823,
+ 21637928,
+ -22571882,
+ 9701493,
+ -1153777,
+ -108748,
+ -44492,
+ -1161275,
+ 7212841,
+ -10745123,
+ -9417698,
+ 94393496,
+ -319524891,
+ 1138062846,
+ 1459846980,
+ -256565658,
+ 35986861,
+ 22974786,
+ -23032782,
+ 9782494,
+ -1147002,
+ -112146,
+ -42815,
+ -1156370,
+ 7108286,
+ -10312747,
+ -10439219,
+ 95947972,
+ -320281158,
+ 1125125780,
+ 1470448975,
+ -252568299,
+ 33245445,
+ 24319500,
+ -23492772,
+ 9861937,
+ -1139648,
+ -115623,
+ -41189,
+ -1151174,
+ 7003477,
+ -9883112,
+ -11446110,
+ 97457853,
+ -320932794,
+ 1112137821,
+ 1480936653,
+ -248447176,
+ 30466029,
+ 25671735,
+ -23951688,
+ 9939774,
+ -1131703,
+ -119180,
+ -39609,
+ -1145692,
+ 6898454,
+ -9456318,
+ -12438222,
+ 98923154,
+ -321480821,
+ 1099101271,
+ 1491308095,
+ -244201986,
+ 27649067,
+ 27031146,
+ -24409374,
+ 10015949,
+ -1123158,
+ -122817,
+ -38078,
+ -1139937,
+ 6793254,
+ -9032461,
+ -13415411,
+ 100343876,
+ -321926168,
+ 1086018558,
+ 1501561384,
+ -239832455,
+ 24795032,
+ 28397394,
+ -24865665,
+ 10090409,
+ -1114000,
+ -126534,
+ -36591,
+ -1133914,
+ 6687917,
+ -8611637,
+ -14377543,
+ 101720034,
+ -322269856,
+ 1072891858,
+ 1511694472,
+ -235338298,
+ 21904418,
+ 29770122,
+ -25320398,
+ 10163103,
+ -1104220,
+ -130336,
+ -35152,
+ -1127635,
+ 6582480,
+ -8193936,
+ -15324489,
+ 103051661,
+ -322512908,
+ 1059723600,
+ 1521705571,
+ -230719322,
+ 18977727,
+ 31148974,
+ -25773405,
+ 10233975,
+ -1093806,
+ -134219,
+ -33755,
+ -1121107,
+ 6476979,
+ -7779450,
+ -16256125,
+ 104338821,
+ -322656317,
+ 1046516020,
+ 1531592762,
+ -225975271,
+ 16015486,
+ 32533586,
+ -26224519,
+ 10302971,
+ -1082748,
+ -138188,
+ -32404,
+ -1114340,
+ 6371449,
+ -7368264,
+ -17172334,
+ 105581553,
+ -322701168,
+ 1033271486,
+ 1541354127,
+ -221106001,
+ 13018232,
+ 33923586,
+ -26673572,
+ 10370039,
+ -1071034,
+ -142241,
+ -31093,
+ -1107341,
+ 6265928,
+ -6960467,
+ -18073009,
+ 106779945,
+ -322648485,
+ 1019992363,
+ 1550987876,
+ -216111352,
+ 9986517,
+ 35318598,
+ -27120392,
+ 10435121,
+ -1058655,
+ -146380,
+ -29825,
+ -1100120,
+ 6160448,
+ -6556139,
+ -18958039,
+ 107934078,
+ -322499354,
+ 1006680887,
+ 1560492090,
+ -210991182,
+ 6920914,
+ 36718245,
+ -27564812,
+ 10498167,
+ -1045599,
+ -150606,
+ -28595,
+ -1092684,
+ 6055046,
+ -6155362,
+ -19827333,
+ 109044055,
+ -322254863,
+ 993339490,
+ 1569864980,
+ -205745393,
+ 3822006,
+ 38122132,
+ -28006651,
+ 10559119,
+ -1031856,
+ -154921,
+ -27408,
+ -1085044,
+ 5949753,
+ -5758216,
+ -20680795,
+ 110109980,
+ -321916130,
+ 979970409,
+ 1579104882,
+ -200373937,
+ 690397,
+ 39529875,
+ -28445738,
+ 10617923,
+ -1017416,
+ -159323,
+ -26258,
+ -1077205,
+ 5844605,
+ -5364775,
+ -21518342,
+ 111131981,
+ -321484242,
+ 966575945,
+ 1588209880,
+ -194876736,
+ -2473298,
+ 40941074,
+ -28881897,
+ 10674526,
+ -1002267,
+ -163816,
+ -25146,
+ -1069176,
+ 5739630,
+ -4975113,
+ -22339894,
+ 112110194,
+ -320960350,
+ 953158527,
+ 1597178183,
+ -189253789,
+ -5668445,
+ 42355318,
+ -29314952,
+ 10728869,
+ -986399,
+ -168398,
+ -24070,
+ -1060965,
+ 5634863,
+ -4589302,
+ -23145373,
+ 113044762,
+ -320345606,
+ 939720395,
+ 1606008384,
+ -183505111,
+ -8894395,
+ 43772208,
+ -29744720,
+ 10780901,
+ -969801,
+ -173073,
+ -23032,
+ -1052580,
+ 5530335,
+ -4207412,
+ -23934717,
+ 113935854,
+ -319641095,
+ 926263913,
+ 1614698437,
+ -177630735,
+ -12150482,
+ 45191323,
+ -30171023,
+ 10830565,
+ -952464,
+ -177839,
+ -22027,
+ -1044030,
+ 5426076,
+ -3829511,
+ -24707861,
+ 114783629,
+ -318848065,
+ 912791319,
+ 1623246936,
+ -171630725,
+ -15436029,
+ 46612253,
+ -30593684,
+ 10877804,
+ -934377,
+ -182698,
+ -21057,
+ -1035321,
+ 5322116,
+ -3455662,
+ -25464752,
+ 115588280,
+ -317967666,
+ 899305043,
+ 1631652218,
+ -165505177,
+ -18750337,
+ 48034561,
+ -31012512,
+ 10922566,
+ -915529,
+ -187650,
+ -20120,
+ -1026460,
+ 5218483,
+ -3085927,
+ -26205336,
+ 116349998,
+ -317001050,
+ 885807194,
+ 1639912494,
+ -159254218,
+ -22092697,
+ 49457825,
+ -31427333,
+ 10964792,
+ -895911,
+ -192697,
+ -19217,
+ -1017456,
+ 5115207,
+ -2720370,
+ -26929575,
+ 117068990,
+ -315949462,
+ 872300267,
+ 1648026356,
+ -152878009,
+ -25462384,
+ 50881607,
+ -31837958,
+ 11004431,
+ -875512,
+ -197839,
+ -18344,
+ -1008314,
+ 5012316,
+ -2359046,
+ -27637425,
+ 117745465,
+ -314814119,
+ 858786434,
+ 1655992142,
+ -146376709,
+ -28858652,
+ 52305470,
+ -32244204,
+ 11041424,
+ -854323,
+ -203077,
+ -17503,
+ -999043,
+ 4909835,
+ -2002012,
+ -28328855,
+ 118379662,
+ -313596202,
+ 845267998,
+ 1663808318,
+ -139750542,
+ -32280747,
+ 53728973,
+ -32645881,
+ 11075717,
+ -832332,
+ -208409,
+ -16691,
+ -989649,
+ 4807794,
+ -1649321,
+ -29003839,
+ 118971813,
+ -312296958,
+ 831747260,
+ 1671473477,
+ -132999747,
+ -35727896,
+ 55151661,
+ -33042808,
+ 11107255,
+ -809533,
+ -213840,
+ -15911,
+ -980142,
+ 4706218,
+ -1301026,
+ -29662356,
+ 119522166,
+ -310917635,
+ 818226458,
+ 1678986085,
+ -126124581,
+ -39199309,
+ 56573082,
+ -33434792,
+ 11135984,
+ -785911,
+ -219366,
+ -15158,
+ -970524,
+ 4605132,
+ -957175,
+ -30304389,
+ 120030985,
+ -309459447,
+ 804707895,
+ 1686344735,
+ -119125347,
+ -42694187,
+ 57992785,
+ -33821644,
+ 11161846,
+ -761462,
+ -224993,
+ -14434,
+ -960804,
+ 4504561,
+ -617817,
+ -30929927,
+ 120498533,
+ -307923704,
+ 791193806,
+ 1693547893,
+ -112002374,
+ -46211710,
+ 59410302,
+ -34203179,
+ 11184790,
+ -736173,
+ -230716,
+ -13735,
+ -950989,
+ 4404529,
+ -282995,
+ -31538967,
+ 120925098,
+ -306311654,
+ 777686367,
+ 1700594279,
+ -104756011,
+ -49751051,
+ 60825166,
+ -34579210,
+ 11204758,
+ -710036,
+ -236539,
+ -13064,
+ -941085,
+ 4305060,
+ 47247,
+ -32131508,
+ 121310952,
+ -304624574,
+ 764187943,
+ 1707482360,
+ -97386636,
+ -53311355,
+ 62236909,
+ -34949535,
+ 11221697,
+ -683040,
+ -242460,
+ -12418,
+ -931097,
+ 4206178,
+ 372869,
+ -32707558,
+ 121656414,
+ -302863713,
+ 750700644,
+ 1714211113,
+ -89894671,
+ -56891767,
+ 63645055,
+ -35313975,
+ 11235553,
+ -655180,
+ -248482,
+ -11797,
+ -921033,
+ 4107902,
+ 693831,
+ -33267126,
+ 121961772,
+ -301030412,
+ 737226771,
+ 1720779002,
+ -82280549,
+ -60491408,
+ 65049126,
+ -35672332,
+ 11246271,
+ -626443,
+ -254603,
+ -11201,
+ -910898,
+ 4010257,
+ 1010098,
+ -33810228,
+ 122227354,
+ -299125919,
+ 723768435,
+ 1727184750,
+ -74544749,
+ -64109386,
+ 66448641,
+ -36024420,
+ 11253798,
+ -596822,
+ -260826,
+ -10627,
+ -900699,
+ 3913263,
+ 1321634,
+ -34336885,
+ 122453488,
+ -297151575,
+ 710327937,
+ 1733427206,
+ -66687765,
+ -67744803,
+ 67843113,
+ -36370038,
+ 11258081,
+ -566307,
+ -267148,
+ -10077,
+ -890442,
+ 3816940,
+ 1628409,
+ -34847130,
+ 122640509,
+ -295108628,
+ 696907387,
+ 1739505218,
+ -58710131,
+ -71396732,
+ 69232051,
+ -36709002,
+ 11259065,
+ -534893,
+ -273571,
+ -9548,
+ -880130,
+ 3721309,
+ 1930390,
+ -35340984,
+ 122788760,
+ -292998452,
+ 683508959,
+ 1745417379,
+ -50612405,
+ -75064245,
+ 70614962,
+ -37041114,
+ 11256697,
+ -502568,
+ -280096,
+ -9041,
+ -869771,
+ 3626389,
+ 2227550,
+ -35818490,
+ 122898586,
+ -290822359,
+ 670134826,
+ 1751162796,
+ -42395174,
+ -78746391,
+ 71991353,
+ -37366188,
+ 11250926,
+ -469326,
+ -286722,
+ -8555,
+ -859371,
+ 3532197,
+ 2519863,
+ -36279688,
+ 122970355,
+ -288581657,
+ 656787099,
+ 1756740189,
+ -34059059,
+ -82442219,
+ 73360726,
+ -37684022,
+ 11241699,
+ -435158,
+ -293448,
+ -8090,
+ -848933,
+ 3438755,
+ 2807304,
+ -36724623,
+ 123004432,
+ -286277660,
+ 643467888,
+ 1762148536,
+ -25604710,
+ -86150747,
+ 74722571,
+ -37994432,
+ 11228964,
+ -400059,
+ -300277,
+ -7642,
+ -838465,
+ 3346077,
+ 3089851,
+ -37153345,
+ 123001196,
+ -283911708,
+ 630179430,
+ 1767386684,
+ -17032794,
+ -89870991,
+ 76076383,
+ -38297220,
+ 11212670,
+ -364017,
+ -307206,
+ -7217,
+ -827968,
+ 3254181,
+ 3367485,
+ -37565916,
+ 122961036,
+ -281485177,
+ 616923707,
+ 1772453740,
+ -8344024,
+ -93601952,
+ 77421661,
+ -38592197,
+ 11192765,
+ -327029,
+ -314237,
+ -6806,
+ -817452,
+ 3163082,
+ 3640185,
+ -37962388,
+ 122884329,
+ -278999345,
+ 603702829,
+ 1777348680,
+ 460868,
+ -97342616,
+ 78757891,
+ -38879166,
+ 11169201,
+ -289085,
+ -321369,
+ -6415,
+ -806918,
+ 3072798,
+ 3907937,
+ -38342827,
+ 122771490,
+ -276455620,
+ 590518906,
+ 1782070610,
+ 9381115,
+ -101091951,
+ 80084555,
+ -39157939,
+ 11141924,
+ -250180,
+ -328603,
+ -6042,
+ -796374,
+ 2983343,
+ 4170725,
+ -38707302,
+ 122622918,
+ -273855279,
+ 577373920,
+ 1786618505,
+ 18415926,
+ -104848926,
+ 81401149,
+ -39428324,
+ 11110888,
+ -210306,
+ -335937,
+ -5685,
+ -785822,
+ 2894732,
+ 4428537,
+ -39055893,
+ 122439022,
+ -271199697,
+ 564269981,
+ 1790991472,
+ 27564476,
+ -108612487,
+ 82707138,
+ -39690126,
+ 11076043,
+ -169458,
+ -343372,
+ -5344,
+ -775268,
+ 2806978,
+ 4681361,
+ -39388668,
+ 122220233,
+ -268490249,
+ 551209135,
+ 1795188742,
+ 36825913,
+ -112381570,
+ 84002010,
+ -39943157,
+ 11037340,
+ -127629,
+ -350908,
+ -5018,
+ -764716,
+ 2720096,
+ 4929190,
+ -39705715,
+ 121966967,
+ -265728262,
+ 538193236,
+ 1799209549,
+ 46199362,
+ -116155097,
+ 85285245,
+ -40187229,
+ 10994731,
+ -84815,
+ -358543,
+ -4707,
+ -754169,
+ 2634098,
+ 5172016,
+ -40007117,
+ 121679663,
+ -262915094,
+ 525224394,
+ 1803052870,
+ 55683904,
+ -119931980,
+ 86556317,
+ -40422145,
+ 10948170,
+ -41007,
+ -366277,
+ -4413,
+ -743634,
+ 2548996,
+ 5409833,
+ -40292963,
+ 121358760,
+ -260052088,
+ 512304559,
+ 1806718193,
+ 65278608,
+ -123711125,
+ 87814697,
+ -40647720,
+ 10897610,
+ 3797,
+ -374112,
+ -4131,
+ -733113,
+ 2464803,
+ 5642637,
+ -40563352,
+ 121004698,
+ -257140602,
+ 499435680,
+ 1810204623,
+ 74982502,
+ -127491421,
+ 89059859,
+ -40863767,
+ 10843005,
+ 49604,
+ -382044,
+ -3864,
+ -722610,
+ 2381529,
+ 5870428,
+ -40818381,
+ 120617933,
+ -254181996,
+ 486619645,
+ 1813511649,
+ 84794593,
+ -131271741,
+ 90291282,
+ -41070101,
+ 10784310,
+ 96418,
+ -390075,
+ -3606,
+ -712130,
+ 2299185,
+ 6093205,
+ -41058145,
+ 120198921,
+ -251177611,
+ 473858435,
+ 1816638503,
+ 94713863,
+ -135050942,
+ 91508424,
+ -41266524,
+ 10721481,
+ 144245,
+ -398201,
+ -3368,
+ -701676,
+ 2217781,
+ 6310969,
+ -41282756,
+ 119748124,
+ -248128823,
+ 461153873,
+ 1819584546,
+ 104739244,
+ -138827913,
+ 92710756,
+ -41452866,
+ 10654473,
+ 193087,
+ -406426,
+ -3132,
+ -691252,
+ 2137327,
+ 6523724,
+ -41492322,
+ 119265999,
+ -245036958,
+ 448507875,
+ 1822349267,
+ 114869663,
+ -142601464,
+ 93897752,
+ -41628929,
+ 10583245,
+ 242949,
+ -414746,
+ -2912,
+ -680861,
+ 2057831,
+ 6731474,
+ -41686951,
+ 118753032,
+ -241903374,
+ 435922297,
+ 1824932281,
+ 125104011,
+ -146370443,
+ 95068884,
+ -41794536,
+ 10507753,
+ 293834,
+ -423160,
+ -2712,
+ -670508,
+ 1979304,
+ 6934227,
+ -41866767,
+ 118209688,
+ -238729432,
+ 423398929,
+ 1827332694,
+ 135441143,
+ -150133668,
+ 96223608,
+ -41949505,
+ 10427958,
+ 345746,
+ -431669,
+ -2511,
+ -660194,
+ 1901751,
+ 7131990,
+ -42031886,
+ 117636454,
+ -235516456,
+ 410939657,
+ 1829550506,
+ 145879910,
+ -153889956,
+ 97361389,
+ -42093652,
+ 10343818,
+ 398687,
+ -440270,
+ -2325,
+ -649924,
+ 1825182,
+ 7324772,
+ -42182431,
+ 117033809,
+ -232265822,
+ 398546175,
+ 1831584822,
+ 156419120,
+ -157638124,
+ 98481700,
+ -42226799,
+ 10255294,
+ 452661,
+ -448963,
+ -2146,
+ -639701,
+ 1749604,
+ 7512586,
+ -42318527,
+ 116402257,
+ -228978840,
+ 386220337,
+ 1833435641,
+ 167057527,
+ -161376958,
+ 99584012,
+ -42348769,
+ 10162347,
+ 507668,
+ -457747,
+ -1983,
+ -629527,
+ 1675021,
+ 7695443,
+ -42440309,
+ 115742278,
+ -225656869,
+ 373963838,
+ 1835102325,
+ 177793900,
+ -165105241,
+ 100667775,
+ -42459386,
+ 10064942,
+ 563713,
+ -466619,
+ -1826,
+ -619405,
+ 1601442,
+ 7873360,
+ -42547906,
+ 115054374,
+ -222301236,
+ 361778403,
+ 1836584617,
+ 188626976,
+ -168821761,
+ 101732478,
+ -42558471,
+ 9963039,
+ 620794,
+ -475581,
+ -1680,
+ -609339,
+ 1528871,
+ 8046349,
+ -42641448,
+ 114339050,
+ -218913268,
+ 349665760,
+ 1837882262,
+ 199555429,
+ -172525270,
+ 102777568,
+ -42645851,
+ 9856605,
+ 678915,
+ -484628,
+ -1538,
+ -599330,
+ 1457313,
+ 8214429,
+ -42721084,
+ 113596801,
+ -215494306,
+ 337627602,
+ 1838995132,
+ 210577947,
+ -176214553,
+ 103802518,
+ -42721356,
+ 9745603,
+ 738075,
+ -493761,
+ -1408,
+ -589384,
+ 1386774,
+ 8377620,
+ -42786950,
+ 112828147,
+ -212045678,
+ 325665528,
+ 1839922716,
+ 221693189,
+ -179888332,
+ 104806800,
+ -42784820,
+ 9630001,
+ 798277,
+ -502977,
+ -1282,
+ -579499,
+ 1317256,
+ 8535941,
+ -42839190,
+ 112033582,
+ -208568679,
+ 313781201,
+ 1840665012,
+ 232899731,
+ -183545359,
+ 105789888,
+ -42836069,
+ 9509767,
+ 859518,
+ -512275,
+ -1167,
+ -569681,
+ 1248765,
+ 8689411,
+ -42877955,
+ 111213643,
+ -205064634,
+ 301976218,
+ 1841221895,
+ 244196199,
+ -187184388,
+ 106751238,
+ -42874938,
+ 9384870,
+ 921799,
+ -521653,
+ -1056,
+ -559931,
+ 1181304,
+ 8838056,
+ -42903390,
+ 110368825,
+ -201534855,
+ 290252177,
+ 1841593235,
+ 255581155,
+ -190804125,
+ 107690338,
+ -42901268,
+ 9255277,
+ 985120,
+ -531109,
+ -5103,
+ -550250,
+ 1114874,
+ 8981898,
+ -42915649,
+ 109499655,
+ -197980653,
+ 278610646,
+ 1841778905,
+ 267053128,
+ -194403322,
+ 108606645,
+ -42914890,
+ 9120963,
+ 1049478,
+ -540643
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.sfp
new file mode 100644
index 0000000..dcee3b9
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/HS320_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320_xs3.dat
new file mode 100644
index 0000000..fb6a397
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/HS320_xs3.dat
@@ -0,0 +1,2562 @@
+ -540643,
+ 9120963,
+ 108606645,
+ 267053128,
+ 278610646,
+ 109499655,
+ 8981898,
+ -550250,
+ 1049478,
+ -42914890,
+ -194403322,
+ 1841778905,
+ -197980653,
+ -42915649,
+ 1114874,
+ -5103,
+ -531109,
+ 9255277,
+ 107690338,
+ 255581155,
+ 290252177,
+ 110368825,
+ 8838056,
+ -559931,
+ 985120,
+ -42901268,
+ -190804125,
+ 1841593235,
+ -201534855,
+ -42903390,
+ 1181304,
+ -1056,
+ -521653,
+ 9384870,
+ 106751238,
+ 244196199,
+ 301976218,
+ 111213643,
+ 8689411,
+ -569681,
+ 921799,
+ -42874938,
+ -187184388,
+ 1841221895,
+ -205064634,
+ -42877955,
+ 1248765,
+ -1167,
+ -512275,
+ 9509767,
+ 105789888,
+ 232899731,
+ 313781201,
+ 112033582,
+ 8535941,
+ -579499,
+ 859518,
+ -42836069,
+ -183545359,
+ 1840665012,
+ -208568679,
+ -42839190,
+ 1317256,
+ -1282,
+ -502977,
+ 9630001,
+ 104806800,
+ 221693189,
+ 325665528,
+ 112828147,
+ 8377620,
+ -589384,
+ 798277,
+ -42784820,
+ -179888332,
+ 1839922716,
+ -212045678,
+ -42786950,
+ 1386774,
+ -1408,
+ -493761,
+ 9745603,
+ 103802518,
+ 210577947,
+ 337627602,
+ 113596801,
+ 8214429,
+ -599330,
+ 738075,
+ -42721356,
+ -176214553,
+ 1838995132,
+ -215494306,
+ -42721084,
+ 1457313,
+ -1538,
+ -484628,
+ 9856605,
+ 102777568,
+ 199555429,
+ 349665760,
+ 114339050,
+ 8046349,
+ -609339,
+ 678915,
+ -42645851,
+ -172525270,
+ 1837882262,
+ -218913268,
+ -42641448,
+ 1528871,
+ -1680,
+ -475581,
+ 9963039,
+ 101732478,
+ 188626976,
+ 361778403,
+ 115054374,
+ 7873360,
+ -619405,
+ 620794,
+ -42558471,
+ -168821761,
+ 1836584617,
+ -222301236,
+ -42547906,
+ 1601442,
+ -1826,
+ -466619,
+ 10064942,
+ 100667775,
+ 177793900,
+ 373963838,
+ 115742278,
+ 7695443,
+ -629527,
+ 563713,
+ -42459386,
+ -165105241,
+ 1835102325,
+ -225656869,
+ -42440309,
+ 1675021,
+ -1983,
+ -457747,
+ 10162347,
+ 99584012,
+ 167057527,
+ 386220337,
+ 116402257,
+ 7512586,
+ -639701,
+ 507668,
+ -42348769,
+ -161376958,
+ 1833435641,
+ -228978840,
+ -42318527,
+ 1749604,
+ -2146,
+ -448963,
+ 10255294,
+ 98481700,
+ 156419120,
+ 398546175,
+ 117033809,
+ 7324772,
+ -649924,
+ 452661,
+ -42226799,
+ -157638124,
+ 1831584822,
+ -232265822,
+ -42182431,
+ 1825182,
+ -2325,
+ -440270,
+ 10343818,
+ 97361389,
+ 145879910,
+ 410939657,
+ 117636454,
+ 7131990,
+ -660194,
+ 398687,
+ -42093652,
+ -153889956,
+ 1829550506,
+ -235516456,
+ -42031886,
+ 1901751,
+ -2511,
+ -431669,
+ 10427958,
+ 96223608,
+ 135441143,
+ 423398929,
+ 118209688,
+ 6934227,
+ -670508,
+ 345746,
+ -41949505,
+ -150133668,
+ 1827332694,
+ -238729432,
+ -41866767,
+ 1979304,
+ -2712,
+ -423160,
+ 10507753,
+ 95068884,
+ 125104011,
+ 435922297,
+ 118753032,
+ 6731474,
+ -680861,
+ 293834,
+ -41794536,
+ -146370443,
+ 1824932281,
+ -241903374,
+ -41686951,
+ 2057831,
+ -2912,
+ -414746,
+ 10583245,
+ 93897752,
+ 114869663,
+ 448507875,
+ 119265999,
+ 6523724,
+ -691252,
+ 242949,
+ -41628929,
+ -142601464,
+ 1822349267,
+ -245036958,
+ -41492322,
+ 2137327,
+ -3132,
+ -406426,
+ 10654473,
+ 92710756,
+ 104739244,
+ 461153873,
+ 119748124,
+ 6310969,
+ -701676,
+ 193087,
+ -41452866,
+ -138827913,
+ 1819584546,
+ -248128823,
+ -41282756,
+ 2217781,
+ -3368,
+ -398201,
+ 10721481,
+ 91508424,
+ 94713863,
+ 473858435,
+ 120198921,
+ 6093205,
+ -712130,
+ 144245,
+ -41266524,
+ -135050942,
+ 1816638503,
+ -251177611,
+ -41058145,
+ 2299185,
+ -3606,
+ -390075,
+ 10784310,
+ 90291282,
+ 84794593,
+ 486619645,
+ 120617933,
+ 5870428,
+ -722610,
+ 96418,
+ -41070101,
+ -131271741,
+ 1813511649,
+ -254181996,
+ -40818381,
+ 2381529,
+ -3864,
+ -382044,
+ 10843005,
+ 89059859,
+ 74982502,
+ 499435680,
+ 121004698,
+ 5642637,
+ -733113,
+ 49604,
+ -40863767,
+ -127491421,
+ 1810204623,
+ -257140602,
+ -40563352,
+ 2464803,
+ -4131,
+ -374112,
+ 10897610,
+ 87814697,
+ 65278608,
+ 512304559,
+ 121358760,
+ 5409833,
+ -743634,
+ 3797,
+ -40647720,
+ -123711125,
+ 1806718193,
+ -260052088,
+ -40292963,
+ 2548996,
+ -4413,
+ -366277,
+ 10948170,
+ 86556317,
+ 55683904,
+ 525224394,
+ 121679663,
+ 5172016,
+ -754169,
+ -41007,
+ -40422145,
+ -119931980,
+ 1803052870,
+ -262915094,
+ -40007117,
+ 2634098,
+ -4707,
+ -358543,
+ 10994731,
+ 85285245,
+ 46199362,
+ 538193236,
+ 121966967,
+ 4929190,
+ -764716,
+ -84815,
+ -40187229,
+ -116155097,
+ 1799209549,
+ -265728262,
+ -39705715,
+ 2720096,
+ -5018,
+ -350908,
+ 11037340,
+ 84002010,
+ 36825913,
+ 551209135,
+ 122220233,
+ 4681361,
+ -775268,
+ -127629,
+ -39943157,
+ -112381570,
+ 1795188742,
+ -268490249,
+ -39388668,
+ 2806978,
+ -5344,
+ -343372,
+ 11076043,
+ 82707138,
+ 27564476,
+ 564269981,
+ 122439022,
+ 4428537,
+ -785822,
+ -169458,
+ -39690126,
+ -108612487,
+ 1790991472,
+ -271199697,
+ -39055893,
+ 2894732,
+ -5685,
+ -335937,
+ 11110888,
+ 81401149,
+ 18415926,
+ 577373920,
+ 122622918,
+ 4170725,
+ -796374,
+ -210306,
+ -39428324,
+ -104848926,
+ 1786618505,
+ -273855279,
+ -38707302,
+ 2983343,
+ -6042,
+ -328603,
+ 11141924,
+ 80084555,
+ 9381115,
+ 590518906,
+ 122771490,
+ 3907937,
+ -806918,
+ -250180,
+ -39157939,
+ -101091951,
+ 1782070610,
+ -276455620,
+ -38342827,
+ 3072798,
+ -6415,
+ -321369,
+ 11169201,
+ 78757891,
+ 460868,
+ 603702829,
+ 122884329,
+ 3640185,
+ -817452,
+ -289085,
+ -38879166,
+ -97342616,
+ 1777348680,
+ -278999345,
+ -37962388,
+ 3163082,
+ -6806,
+ -314237,
+ 11192765,
+ 77421661,
+ -8344024,
+ 616923707,
+ 122961036,
+ 3367485,
+ -827968,
+ -327029,
+ -38592197,
+ -93601952,
+ 1772453740,
+ -281485177,
+ -37565916,
+ 3254181,
+ -7217,
+ -307206,
+ 11212670,
+ 76076383,
+ -17032794,
+ 630179430,
+ 123001196,
+ 3089851,
+ -838465,
+ -364017,
+ -38297220,
+ -89870991,
+ 1767386684,
+ -283911708,
+ -37153345,
+ 3346077,
+ -7642,
+ -300277,
+ 11228964,
+ 74722571,
+ -25604710,
+ 643467888,
+ 123004432,
+ 2807304,
+ -848933,
+ -400059,
+ -37994432,
+ -86150747,
+ 1762148536,
+ -286277660,
+ -36724623,
+ 3438755,
+ -8090,
+ -293448,
+ 11241699,
+ 73360726,
+ -34059059,
+ 656787099,
+ 122970355,
+ 2519863,
+ -859371,
+ -435158,
+ -37684022,
+ -82442219,
+ 1756740189,
+ -288581657,
+ -36279688,
+ 3532197,
+ -8555,
+ -286722,
+ 11250926,
+ 71991353,
+ -42395174,
+ 670134826,
+ 122898586,
+ 2227550,
+ -869771,
+ -469326,
+ -37366188,
+ -78746391,
+ 1751162796,
+ -290822359,
+ -35818490,
+ 3626389,
+ -9041,
+ -280096,
+ 11256697,
+ 70614962,
+ -50612405,
+ 683508959,
+ 122788760,
+ 1930390,
+ -880130,
+ -502568,
+ -37041114,
+ -75064245,
+ 1745417379,
+ -292998452,
+ -35340984,
+ 3721309,
+ -9548,
+ -273571,
+ 11259065,
+ 69232051,
+ -58710131,
+ 696907387,
+ 122640509,
+ 1628409,
+ -890442,
+ -534893,
+ -36709002,
+ -71396732,
+ 1739505218,
+ -295108628,
+ -34847130,
+ 3816940,
+ -10077,
+ -267148,
+ 11258081,
+ 67843113,
+ -66687765,
+ 710327937,
+ 122453488,
+ 1321634,
+ -900699,
+ -566307,
+ -36370038,
+ -67744803,
+ 1733427206,
+ -297151575,
+ -34336885,
+ 3913263,
+ -10627,
+ -260826,
+ 11253798,
+ 66448641,
+ -74544749,
+ 723768435,
+ 122227354,
+ 1010098,
+ -910898,
+ -596822,
+ -36024420,
+ -64109386,
+ 1727184750,
+ -299125919,
+ -33810228,
+ 4010257,
+ -11201,
+ -254603,
+ 11246271,
+ 65049126,
+ -82280549,
+ 737226771,
+ 121961772,
+ 693831,
+ -921033,
+ -626443,
+ -35672332,
+ -60491408,
+ 1720779002,
+ -301030412,
+ -33267126,
+ 4107902,
+ -11797,
+ -248482,
+ 11235553,
+ 63645055,
+ -89894671,
+ 750700644,
+ 121656414,
+ 372869,
+ -931097,
+ -655180,
+ -35313975,
+ -56891767,
+ 1714211113,
+ -302863713,
+ -32707558,
+ 4206178,
+ -12418,
+ -242460,
+ 11221697,
+ 62236909,
+ -97386636,
+ 764187943,
+ 121310952,
+ 47247,
+ -941085,
+ -683040,
+ -34949535,
+ -53311355,
+ 1707482360,
+ -304624574,
+ -32131508,
+ 4305060,
+ -13064,
+ -236539,
+ 11204758,
+ 60825166,
+ -104756011,
+ 777686367,
+ 120925098,
+ -282995,
+ -950989,
+ -710036,
+ -34579210,
+ -49751051,
+ 1700594279,
+ -306311654,
+ -31538967,
+ 4404529,
+ -13735,
+ -230716,
+ 11184790,
+ 59410302,
+ -112002374,
+ 791193806,
+ 120498533,
+ -617817,
+ -960804,
+ -736173,
+ -34203179,
+ -46211710,
+ 1693547893,
+ -307923704,
+ -30929927,
+ 4504561,
+ -14434,
+ -224993,
+ 11161846,
+ 57992785,
+ -119125347,
+ 804707895,
+ 120030985,
+ -957175,
+ -970524,
+ -761462,
+ -33821644,
+ -42694187,
+ 1686344735,
+ -309459447,
+ -30304389,
+ 4605132,
+ -15158,
+ -219366,
+ 11135984,
+ 56573082,
+ -126124581,
+ 818226458,
+ 119522166,
+ -1301026,
+ -980142,
+ -785911,
+ -33434792,
+ -39199309,
+ 1678986085,
+ -310917635,
+ -29662356,
+ 4706218,
+ -15911,
+ -213840,
+ 11107255,
+ 55151661,
+ -132999747,
+ 831747260,
+ 118971813,
+ -1649321,
+ -989649,
+ -809533,
+ -33042808,
+ -35727896,
+ 1671473477,
+ -312296958,
+ -29003839,
+ 4807794,
+ -16691,
+ -208409,
+ 11075717,
+ 53728973,
+ -139750542,
+ 845267998,
+ 118379662,
+ -2002012,
+ -999043,
+ -832332,
+ -32645881,
+ -32280747,
+ 1663808318,
+ -313596202,
+ -28328855,
+ 4909835,
+ -17503,
+ -203077,
+ 11041424,
+ 52305470,
+ -146376709,
+ 858786434,
+ 117745465,
+ -2359046,
+ -1008314,
+ -854323,
+ -32244204,
+ -28858652,
+ 1655992142,
+ -314814119,
+ -27637425,
+ 5012316,
+ -18344,
+ -197839,
+ 11004431,
+ 50881607,
+ -152878009,
+ 872300267,
+ 117068990,
+ -2720370,
+ -1017456,
+ -875512,
+ -31837958,
+ -25462384,
+ 1648026356,
+ -315949462,
+ -26929575,
+ 5115207,
+ -19217,
+ -192697,
+ 10964792,
+ 49457825,
+ -159254218,
+ 885807194,
+ 116349998,
+ -3085927,
+ -1026460,
+ -895911,
+ -31427333,
+ -22092697,
+ 1639912494,
+ -317001050,
+ -26205336,
+ 5218483,
+ -20120,
+ -187650,
+ 10922566,
+ 48034561,
+ -165505177,
+ 899305043,
+ 115588280,
+ -3455662,
+ -1035321,
+ -915529,
+ -31012512,
+ -18750337,
+ 1631652218,
+ -317967666,
+ -25464752,
+ 5322116,
+ -21057,
+ -182698,
+ 10877804,
+ 46612253,
+ -171630725,
+ 912791319,
+ 114783629,
+ -3829511,
+ -1044030,
+ -934377,
+ -30593684,
+ -15436029,
+ 1623246936,
+ -318848065,
+ -24707861,
+ 5426076,
+ -22027,
+ -177839,
+ 10830565,
+ 45191323,
+ -177630735,
+ 926263913,
+ 113935854,
+ -4207412,
+ -1052580,
+ -952464,
+ -30171023,
+ -12150482,
+ 1614698437,
+ -319641095,
+ -23934717,
+ 5530335,
+ -23032,
+ -173073,
+ 10780901,
+ 43772208,
+ -183505111,
+ 939720395,
+ 113044762,
+ -4589302,
+ -1060965,
+ -969801,
+ -29744720,
+ -8894395,
+ 1606008384,
+ -320345606,
+ -23145373,
+ 5634863,
+ -24070,
+ -168398,
+ 10728869,
+ 42355318,
+ -189253789,
+ 953158527,
+ 112110194,
+ -4975113,
+ -1069176,
+ -986399,
+ -29314952,
+ -5668445,
+ 1597178183,
+ -320960350,
+ -22339894,
+ 5739630,
+ -25146,
+ -163816,
+ 10674526,
+ 40941074,
+ -194876736,
+ 966575945,
+ 111131981,
+ -5364775,
+ -1077205,
+ -1002267,
+ -28881897,
+ -2473298,
+ 1588209880,
+ -321484242,
+ -21518342,
+ 5844605,
+ -26258,
+ -159323,
+ 10617923,
+ 39529875,
+ -200373937,
+ 979970409,
+ 110109980,
+ -5758216,
+ -1085044,
+ -1017416,
+ -28445738,
+ 690397,
+ 1579104882,
+ -321916130,
+ -20680795,
+ 5949753,
+ -27408,
+ -154921,
+ 10559119,
+ 38122132,
+ -205745393,
+ 993339490,
+ 109044055,
+ -6155362,
+ -1092684,
+ -1031856,
+ -28006651,
+ 3822006,
+ 1569864980,
+ -322254863,
+ -19827333,
+ 6055046,
+ -28595,
+ -150606,
+ 10498167,
+ 36718245,
+ -210991182,
+ 1006680887,
+ 107934078,
+ -6556139,
+ -1100120,
+ -1045599,
+ -27564812,
+ 6920914,
+ 1560492090,
+ -322499354,
+ -18958039,
+ 6160448,
+ -29825,
+ -146380,
+ 10435121,
+ 35318598,
+ -216111352,
+ 1019992363,
+ 106779945,
+ -6960467,
+ -1107341,
+ -1058655,
+ -27120392,
+ 9986517,
+ 1550987876,
+ -322648485,
+ -18073009,
+ 6265928,
+ -31093,
+ -142241,
+ 10370039,
+ 33923586,
+ -221106001,
+ 1033271486,
+ 105581553,
+ -7368264,
+ -1114340,
+ -1071034,
+ -26673572,
+ 13018232,
+ 1541354127,
+ -322701168,
+ -17172334,
+ 6371449,
+ -32404,
+ -138188,
+ 10302971,
+ 32533586,
+ -225975271,
+ 1046516020,
+ 104338821,
+ -7779450,
+ -1121107,
+ -1082748,
+ -26224519,
+ 16015486,
+ 1531592762,
+ -322656317,
+ -16256125,
+ 6476979,
+ -33755,
+ -134219,
+ 10233975,
+ 31148974,
+ -230719322,
+ 1059723600,
+ 103051661,
+ -8193936,
+ -1127635,
+ -1093806,
+ -25773405,
+ 18977727,
+ 1521705571,
+ -322512908,
+ -15324489,
+ 6582480,
+ -35152,
+ -130336,
+ 10163103,
+ 29770122,
+ -235338298,
+ 1072891858,
+ 101720034,
+ -8611637,
+ -1133914,
+ -1104220,
+ -25320398,
+ 21904418,
+ 1511694472,
+ -322269856,
+ -14377543,
+ 6687917,
+ -36591,
+ -126534,
+ 10090409,
+ 28397394,
+ -239832455,
+ 1086018558,
+ 100343876,
+ -9032461,
+ -1139937,
+ -1114000,
+ -24865665,
+ 24795032,
+ 1501561384,
+ -321926168,
+ -13415411,
+ 6793254,
+ -38078,
+ -122817,
+ 10015949,
+ 27031146,
+ -244201986,
+ 1099101271,
+ 98923154,
+ -9456318,
+ -1145692,
+ -1123158,
+ -24409374,
+ 27649067,
+ 1491308095,
+ -321480821,
+ -12438222,
+ 6898454,
+ -39609,
+ -119180,
+ 9939774,
+ 25671735,
+ -248447176,
+ 1112137821,
+ 97457853,
+ -9883112,
+ -1151174,
+ -1131703,
+ -23951688,
+ 30466029,
+ 1480936653,
+ -320932794,
+ -11446110,
+ 7003477,
+ -41189,
+ -115623,
+ 9861937,
+ 24319500,
+ -252568299,
+ 1125125780,
+ 95947972,
+ -10312747,
+ -1156370,
+ -1139648,
+ -23492772,
+ 33245445,
+ 1470448975,
+ -320281158,
+ -10439219,
+ 7108286,
+ -42815,
+ -112146,
+ 9782494,
+ 22974786,
+ -256565658,
+ 1138062846,
+ 94393496,
+ -10745123,
+ -1161275,
+ -1147002,
+ -23032782,
+ 35986861,
+ 1459846980,
+ -319524891,
+ -9417698,
+ 7212841,
+ -44492,
+ -108748,
+ 9701493,
+ 21637928,
+ -260439620,
+ 1150946717,
+ 92794473,
+ -11180141,
+ -1165876,
+ -1153777,
+ -22571882,
+ 38689823,
+ 1449132841,
+ -318663098,
+ -8381698,
+ 7317105,
+ -46219,
+ -105425,
+ 9618989,
+ 20309254,
+ -264190537,
+ 1163775092,
+ 91150910,
+ -11617694,
+ -1170166,
+ -1159982,
+ -22110228,
+ 41353917,
+ 1438308348,
+ -317694819,
+ -7331384,
+ 7421035,
+ -47997,
+ -102182,
+ 9535034,
+ 18989084,
+ -267818777,
+ 1176545541,
+ 89462880,
+ -12057678,
+ -1174134,
+ -1165630,
+ -21647974,
+ 43978721,
+ 1427375676,
+ -316619160,
+ -6266922,
+ 7524591,
+ -49827,
+ -99011,
+ 9449680,
+ 17677733,
+ -271324788,
+ 1189256018,
+ 87730422,
+ -12499986,
+ -1177771,
+ -1170730,
+ -21185278,
+ 46563850,
+ 1416336742,
+ -315435225,
+ -5188485,
+ 7627732,
+ -51711,
+ -95917,
+ 9362977,
+ 16375512,
+ -274708984,
+ 1201904093,
+ 85953624,
+ -12944506,
+ -1181067,
+ -1175296,
+ -20722285,
+ 49108914,
+ 1405193720,
+ -314142119,
+ -4096257,
+ 7730417,
+ -53648,
+ -92894,
+ 9274977,
+ 15082724,
+ -277971830,
+ 1214487465,
+ 84132583,
+ -13391125,
+ -1184013,
+ -1179333,
+ -20259153,
+ 51613555,
+ 1393948784,
+ -312739044,
+ -2990422,
+ 7832601,
+ -55642,
+ -89945,
+ 9185728,
+ 13799668,
+ -281113805,
+ 1227003960,
+ 82267394,
+ -13839729,
+ -1186599,
+ -1182857,
+ -19796026,
+ 54077424,
+ 1382603724,
+ -311225071,
+ -1871174,
+ 7934244,
+ -57691,
+ -87066,
+ 9095284,
+ 12526631,
+ -284135420,
+ 1239451148,
+ 80358177,
+ -14290202,
+ -1188815,
+ -1185876,
+ -19333052,
+ 56500187,
+ 1371160970,
+ -309599467,
+ -738715,
+ 8035300,
+ -59798,
+ -84258,
+ 9003691,
+ 11263899,
+ -287037251,
+ 1251826856,
+ 78405068,
+ -14742424,
+ -1190651,
+ -1188402,
+ -18870371,
+ 58881532,
+ 1359622441,
+ -307861430,
+ 406752,
+ 8135726,
+ -61963,
+ -81518,
+ 8911001,
+ 10011750,
+ -289819810,
+ 1264128782,
+ 76408219,
+ -15196274,
+ -1192098,
+ -1190444,
+ -18408131,
+ 61221150,
+ 1347990436,
+ -306010132,
+ 1565010,
+ 8235478,
+ -64189,
+ -78847,
+ 8817262,
+ 8770455,
+ -292483704,
+ 1276354752,
+ 74367790,
+ -15651626,
+ -1193143,
+ -1192015,
+ -17946472,
+ 63518766,
+ 1336267003,
+ -304044867,
+ 2735841,
+ 8334510,
+ -66473,
+ -76243,
+ 8722523,
+ 7540279,
+ -295029507,
+ 1288502592,
+ 72283964,
+ -16108357,
+ -1193779,
+ -1193123,
+ -17485529,
+ 65774100,
+ 1324454316,
+ -301964869,
+ 3919020,
+ 8432777,
+ -68821,
+ -73704,
+ 8626830,
+ 6321481,
+ -297457860,
+ 1300569872,
+ 70156933,
+ -16566338,
+ -1193995,
+ -1193779,
+ -17025440,
+ 67986905,
+ 1312554548,
+ -299769434,
+ 5114314,
+ 8530232,
+ -71231,
+ -71231,
+ 8530232,
+ 5114314,
+ -299769434,
+ 1312554548,
+ 67986905,
+ -17025440,
+ -1193779,
+ -1193995,
+ -16566338,
+ 70156933,
+ 1300569872,
+ -297457860,
+ 6321481,
+ 8626830,
+ -73704,
+ -68821,
+ 8432777,
+ 3919020,
+ -301964869,
+ 1324454316,
+ 65774100,
+ -17485529,
+ -1193123,
+ -1193779,
+ -16108357,
+ 72283964,
+ 1288502592,
+ -295029507,
+ 7540279,
+ 8722523,
+ -76243,
+ -66473,
+ 8334510,
+ 2735841,
+ -304044867,
+ 1336267003,
+ 63518766,
+ -17946472,
+ -1192015,
+ -1193143,
+ -15651626,
+ 74367790,
+ 1276354752,
+ -292483704,
+ 8770455,
+ 8817262,
+ -78847,
+ -64189,
+ 8235478,
+ 1565010,
+ -306010132,
+ 1347990436,
+ 61221150,
+ -18408131,
+ -1190444,
+ -1192098,
+ -15196274,
+ 76408219,
+ 1264128782,
+ -289819810,
+ 10011750,
+ 8911001,
+ -81518,
+ -61963,
+ 8135726,
+ 406752,
+ -307861430,
+ 1359622441,
+ 58881532,
+ -18870371,
+ -1188402,
+ -1190651,
+ -14742424,
+ 78405068,
+ 1251826856,
+ -287037251,
+ 11263899,
+ 9003691,
+ -84258,
+ -59798,
+ 8035300,
+ -738715,
+ -309599467,
+ 1371160970,
+ 56500187,
+ -19333052,
+ -1185876,
+ -1188815,
+ -14290202,
+ 80358177,
+ 1239451148,
+ -284135420,
+ 12526631,
+ 9095284,
+ -87066,
+ -57691,
+ 7934244,
+ -1871174,
+ -311225071,
+ 1382603724,
+ 54077424,
+ -19796026,
+ -1182857,
+ -1186599,
+ -13839729,
+ 82267394,
+ 1227003960,
+ -281113805,
+ 13799668,
+ 9185728,
+ -89945,
+ -55642,
+ 7832601,
+ -2990422,
+ -312739044,
+ 1393948784,
+ 51613555,
+ -20259153,
+ -1179333,
+ -1184013,
+ -13391125,
+ 84132583,
+ 1214487465,
+ -277971830,
+ 15082724,
+ 9274977,
+ -92894,
+ -53648,
+ 7730417,
+ -4096257,
+ -314142119,
+ 1405193720,
+ 49108914,
+ -20722285,
+ -1175296,
+ -1181067,
+ -12944506,
+ 85953624,
+ 1201904093,
+ -274708984,
+ 16375512,
+ 9362977,
+ -95917,
+ -51711,
+ 7627732,
+ -5188485,
+ -315435225,
+ 1416336742,
+ 46563850,
+ -21185278,
+ -1170730,
+ -1177771,
+ -12499986,
+ 87730422,
+ 1189256018,
+ -271324788,
+ 17677733,
+ 9449680,
+ -99011,
+ -49827,
+ 7524591,
+ -6266922,
+ -316619160,
+ 1427375676,
+ 43978721,
+ -21647974,
+ -1165630,
+ -1174134,
+ -12057678,
+ 89462880,
+ 1176545541,
+ -267818777,
+ 18989084,
+ 9535034,
+ -102182,
+ -47997,
+ 7421035,
+ -7331384,
+ -317694819,
+ 1438308348,
+ 41353917,
+ -22110228,
+ -1159982,
+ -1170166,
+ -11617694,
+ 91150910,
+ 1163775092,
+ -264190537,
+ 20309254,
+ 9618989,
+ -105425,
+ -46219,
+ 7317105,
+ -8381698,
+ -318663098,
+ 1449132841,
+ 38689823,
+ -22571882,
+ -1153777,
+ -1165876,
+ -11180141,
+ 92794473,
+ 1150946717,
+ -260439620,
+ 21637928,
+ 9701493,
+ -108748,
+ -44492,
+ 7212841,
+ -9417698,
+ -319524891,
+ 1459846980,
+ 35986861,
+ -23032782,
+ -1147002,
+ -1161275,
+ -10745123,
+ 94393496,
+ 1138062846,
+ -256565658,
+ 22974786,
+ 9782494,
+ -112146,
+ -42815,
+ 7108286,
+ -10439219,
+ -320281158,
+ 1470448975,
+ 33245445,
+ -23492772,
+ -1139648,
+ -1156370,
+ -10312747,
+ 95947972,
+ 1125125780,
+ -252568299,
+ 24319500,
+ 9861937,
+ -115623,
+ -41189,
+ 7003477,
+ -11446110,
+ -320932794,
+ 1480936653,
+ 30466029,
+ -23951688,
+ -1131703,
+ -1151174,
+ -9883112,
+ 97457853,
+ 1112137821,
+ -248447176,
+ 25671735,
+ 9939774,
+ -119180,
+ -39609,
+ 6898454,
+ -12438222,
+ -321480821,
+ 1491308095,
+ 27649067,
+ -24409374,
+ -1123158,
+ -1145692,
+ -9456318,
+ 98923154,
+ 1099101271,
+ -244201986,
+ 27031146,
+ 10015949,
+ -122817,
+ -38078,
+ 6793254,
+ -13415411,
+ -321926168,
+ 1501561384,
+ 24795032,
+ -24865665,
+ -1114000,
+ -1139937,
+ -9032461,
+ 100343876,
+ 1086018558,
+ -239832455,
+ 28397394,
+ 10090409,
+ -126534,
+ -36591,
+ 6687917,
+ -14377543,
+ -322269856,
+ 1511694472,
+ 21904418,
+ -25320398,
+ -1104220,
+ -1133914,
+ -8611637,
+ 101720034,
+ 1072891858,
+ -235338298,
+ 29770122,
+ 10163103,
+ -130336,
+ -35152,
+ 6582480,
+ -15324489,
+ -322512908,
+ 1521705571,
+ 18977727,
+ -25773405,
+ -1093806,
+ -1127635,
+ -8193936,
+ 103051661,
+ 1059723600,
+ -230719322,
+ 31148974,
+ 10233975,
+ -134219,
+ -33755,
+ 6476979,
+ -16256125,
+ -322656317,
+ 1531592762,
+ 16015486,
+ -26224519,
+ -1082748,
+ -1121107,
+ -7779450,
+ 104338821,
+ 1046516020,
+ -225975271,
+ 32533586,
+ 10302971,
+ -138188,
+ -32404,
+ 6371449,
+ -17172334,
+ -322701168,
+ 1541354127,
+ 13018232,
+ -26673572,
+ -1071034,
+ -1114340,
+ -7368264,
+ 105581553,
+ 1033271486,
+ -221106001,
+ 33923586,
+ 10370039,
+ -142241,
+ -31093,
+ 6265928,
+ -18073009,
+ -322648485,
+ 1550987876,
+ 9986517,
+ -27120392,
+ -1058655,
+ -1107341,
+ -6960467,
+ 106779945,
+ 1019992363,
+ -216111352,
+ 35318598,
+ 10435121,
+ -146380,
+ -29825,
+ 6160448,
+ -18958039,
+ -322499354,
+ 1560492090,
+ 6920914,
+ -27564812,
+ -1045599,
+ -1100120,
+ -6556139,
+ 107934078,
+ 1006680887,
+ -210991182,
+ 36718245,
+ 10498167,
+ -150606,
+ -28595,
+ 6055046,
+ -19827333,
+ -322254863,
+ 1569864980,
+ 3822006,
+ -28006651,
+ -1031856,
+ -1092684,
+ -6155362,
+ 109044055,
+ 993339490,
+ -205745393,
+ 38122132,
+ 10559119,
+ -154921,
+ -27408,
+ 5949753,
+ -20680795,
+ -321916130,
+ 1579104882,
+ 690397,
+ -28445738,
+ -1017416,
+ -1085044,
+ -5758216,
+ 110109980,
+ 979970409,
+ -200373937,
+ 39529875,
+ 10617923,
+ -159323,
+ -26258,
+ 5844605,
+ -21518342,
+ -321484242,
+ 1588209880,
+ -2473298,
+ -28881897,
+ -1002267,
+ -1077205,
+ -5364775,
+ 111131981,
+ 966575945,
+ -194876736,
+ 40941074,
+ 10674526,
+ -163816,
+ -25146,
+ 5739630,
+ -22339894,
+ -320960350,
+ 1597178183,
+ -5668445,
+ -29314952,
+ -986399,
+ -1069176,
+ -4975113,
+ 112110194,
+ 953158527,
+ -189253789,
+ 42355318,
+ 10728869,
+ -168398,
+ -24070,
+ 5634863,
+ -23145373,
+ -320345606,
+ 1606008384,
+ -8894395,
+ -29744720,
+ -969801,
+ -1060965,
+ -4589302,
+ 113044762,
+ 939720395,
+ -183505111,
+ 43772208,
+ 10780901,
+ -173073,
+ -23032,
+ 5530335,
+ -23934717,
+ -319641095,
+ 1614698437,
+ -12150482,
+ -30171023,
+ -952464,
+ -1052580,
+ -4207412,
+ 113935854,
+ 926263913,
+ -177630735,
+ 45191323,
+ 10830565,
+ -177839,
+ -22027,
+ 5426076,
+ -24707861,
+ -318848065,
+ 1623246936,
+ -15436029,
+ -30593684,
+ -934377,
+ -1044030,
+ -3829511,
+ 114783629,
+ 912791319,
+ -171630725,
+ 46612253,
+ 10877804,
+ -182698,
+ -21057,
+ 5322116,
+ -25464752,
+ -317967666,
+ 1631652218,
+ -18750337,
+ -31012512,
+ -915529,
+ -1035321,
+ -3455662,
+ 115588280,
+ 899305043,
+ -165505177,
+ 48034561,
+ 10922566,
+ -187650,
+ -20120,
+ 5218483,
+ -26205336,
+ -317001050,
+ 1639912494,
+ -22092697,
+ -31427333,
+ -895911,
+ -1026460,
+ -3085927,
+ 116349998,
+ 885807194,
+ -159254218,
+ 49457825,
+ 10964792,
+ -192697,
+ -19217,
+ 5115207,
+ -26929575,
+ -315949462,
+ 1648026356,
+ -25462384,
+ -31837958,
+ -875512,
+ -1017456,
+ -2720370,
+ 117068990,
+ 872300267,
+ -152878009,
+ 50881607,
+ 11004431,
+ -197839,
+ -18344,
+ 5012316,
+ -27637425,
+ -314814119,
+ 1655992142,
+ -28858652,
+ -32244204,
+ -854323,
+ -1008314,
+ -2359046,
+ 117745465,
+ 858786434,
+ -146376709,
+ 52305470,
+ 11041424,
+ -203077,
+ -17503,
+ 4909835,
+ -28328855,
+ -313596202,
+ 1663808318,
+ -32280747,
+ -32645881,
+ -832332,
+ -999043,
+ -2002012,
+ 118379662,
+ 845267998,
+ -139750542,
+ 53728973,
+ 11075717,
+ -208409,
+ -16691,
+ 4807794,
+ -29003839,
+ -312296958,
+ 1671473477,
+ -35727896,
+ -33042808,
+ -809533,
+ -989649,
+ -1649321,
+ 118971813,
+ 831747260,
+ -132999747,
+ 55151661,
+ 11107255,
+ -213840,
+ -15911,
+ 4706218,
+ -29662356,
+ -310917635,
+ 1678986085,
+ -39199309,
+ -33434792,
+ -785911,
+ -980142,
+ -1301026,
+ 119522166,
+ 818226458,
+ -126124581,
+ 56573082,
+ 11135984,
+ -219366,
+ -15158,
+ 4605132,
+ -30304389,
+ -309459447,
+ 1686344735,
+ -42694187,
+ -33821644,
+ -761462,
+ -970524,
+ -957175,
+ 120030985,
+ 804707895,
+ -119125347,
+ 57992785,
+ 11161846,
+ -224993,
+ -14434,
+ 4504561,
+ -30929927,
+ -307923704,
+ 1693547893,
+ -46211710,
+ -34203179,
+ -736173,
+ -960804,
+ -617817,
+ 120498533,
+ 791193806,
+ -112002374,
+ 59410302,
+ 11184790,
+ -230716,
+ -13735,
+ 4404529,
+ -31538967,
+ -306311654,
+ 1700594279,
+ -49751051,
+ -34579210,
+ -710036,
+ -950989,
+ -282995,
+ 120925098,
+ 777686367,
+ -104756011,
+ 60825166,
+ 11204758,
+ -236539,
+ -13064,
+ 4305060,
+ -32131508,
+ -304624574,
+ 1707482360,
+ -53311355,
+ -34949535,
+ -683040,
+ -941085,
+ 47247,
+ 121310952,
+ 764187943,
+ -97386636,
+ 62236909,
+ 11221697,
+ -242460,
+ -12418,
+ 4206178,
+ -32707558,
+ -302863713,
+ 1714211113,
+ -56891767,
+ -35313975,
+ -655180,
+ -931097,
+ 372869,
+ 121656414,
+ 750700644,
+ -89894671,
+ 63645055,
+ 11235553,
+ -248482,
+ -11797,
+ 4107902,
+ -33267126,
+ -301030412,
+ 1720779002,
+ -60491408,
+ -35672332,
+ -626443,
+ -921033,
+ 693831,
+ 121961772,
+ 737226771,
+ -82280549,
+ 65049126,
+ 11246271,
+ -254603,
+ -11201,
+ 4010257,
+ -33810228,
+ -299125919,
+ 1727184750,
+ -64109386,
+ -36024420,
+ -596822,
+ -910898,
+ 1010098,
+ 122227354,
+ 723768435,
+ -74544749,
+ 66448641,
+ 11253798,
+ -260826,
+ -10627,
+ 3913263,
+ -34336885,
+ -297151575,
+ 1733427206,
+ -67744803,
+ -36370038,
+ -566307,
+ -900699,
+ 1321634,
+ 122453488,
+ 710327937,
+ -66687765,
+ 67843113,
+ 11258081,
+ -267148,
+ -10077,
+ 3816940,
+ -34847130,
+ -295108628,
+ 1739505218,
+ -71396732,
+ -36709002,
+ -534893,
+ -890442,
+ 1628409,
+ 122640509,
+ 696907387,
+ -58710131,
+ 69232051,
+ 11259065,
+ -273571,
+ -9548,
+ 3721309,
+ -35340984,
+ -292998452,
+ 1745417379,
+ -75064245,
+ -37041114,
+ -502568,
+ -880130,
+ 1930390,
+ 122788760,
+ 683508959,
+ -50612405,
+ 70614962,
+ 11256697,
+ -280096,
+ -9041,
+ 3626389,
+ -35818490,
+ -290822359,
+ 1751162796,
+ -78746391,
+ -37366188,
+ -469326,
+ -869771,
+ 2227550,
+ 122898586,
+ 670134826,
+ -42395174,
+ 71991353,
+ 11250926,
+ -286722,
+ -8555,
+ 3532197,
+ -36279688,
+ -288581657,
+ 1756740189,
+ -82442219,
+ -37684022,
+ -435158,
+ -859371,
+ 2519863,
+ 122970355,
+ 656787099,
+ -34059059,
+ 73360726,
+ 11241699,
+ -293448,
+ -8090,
+ 3438755,
+ -36724623,
+ -286277660,
+ 1762148536,
+ -86150747,
+ -37994432,
+ -400059,
+ -848933,
+ 2807304,
+ 123004432,
+ 643467888,
+ -25604710,
+ 74722571,
+ 11228964,
+ -300277,
+ -7642,
+ 3346077,
+ -37153345,
+ -283911708,
+ 1767386684,
+ -89870991,
+ -38297220,
+ -364017,
+ -838465,
+ 3089851,
+ 123001196,
+ 630179430,
+ -17032794,
+ 76076383,
+ 11212670,
+ -307206,
+ -7217,
+ 3254181,
+ -37565916,
+ -281485177,
+ 1772453740,
+ -93601952,
+ -38592197,
+ -327029,
+ -827968,
+ 3367485,
+ 122961036,
+ 616923707,
+ -8344024,
+ 77421661,
+ 11192765,
+ -314237,
+ -6806,
+ 3163082,
+ -37962388,
+ -278999345,
+ 1777348680,
+ -97342616,
+ -38879166,
+ -289085,
+ -817452,
+ 3640185,
+ 122884329,
+ 603702829,
+ 460868,
+ 78757891,
+ 11169201,
+ -321369,
+ -6415,
+ 3072798,
+ -38342827,
+ -276455620,
+ 1782070610,
+ -101091951,
+ -39157939,
+ -250180,
+ -806918,
+ 3907937,
+ 122771490,
+ 590518906,
+ 9381115,
+ 80084555,
+ 11141924,
+ -328603,
+ -6042,
+ 2983343,
+ -38707302,
+ -273855279,
+ 1786618505,
+ -104848926,
+ -39428324,
+ -210306,
+ -796374,
+ 4170725,
+ 122622918,
+ 577373920,
+ 18415926,
+ 81401149,
+ 11110888,
+ -335937,
+ -5685,
+ 2894732,
+ -39055893,
+ -271199697,
+ 1790991472,
+ -108612487,
+ -39690126,
+ -169458,
+ -785822,
+ 4428537,
+ 122439022,
+ 564269981,
+ 27564476,
+ 82707138,
+ 11076043,
+ -343372,
+ -5344,
+ 2806978,
+ -39388668,
+ -268490249,
+ 1795188742,
+ -112381570,
+ -39943157,
+ -127629,
+ -775268,
+ 4681361,
+ 122220233,
+ 551209135,
+ 36825913,
+ 84002010,
+ 11037340,
+ -350908,
+ -5018,
+ 2720096,
+ -39705715,
+ -265728262,
+ 1799209549,
+ -116155097,
+ -40187229,
+ -84815,
+ -764716,
+ 4929190,
+ 121966967,
+ 538193236,
+ 46199362,
+ 85285245,
+ 10994731,
+ -358543,
+ -4707,
+ 2634098,
+ -40007117,
+ -262915094,
+ 1803052870,
+ -119931980,
+ -40422145,
+ -41007,
+ -754169,
+ 5172016,
+ 121679663,
+ 525224394,
+ 55683904,
+ 86556317,
+ 10948170,
+ -366277,
+ -4413,
+ 2548996,
+ -40292963,
+ -260052088,
+ 1806718193,
+ -123711125,
+ -40647720,
+ 3797,
+ -743634,
+ 5409833,
+ 121358760,
+ 512304559,
+ 65278608,
+ 87814697,
+ 10897610,
+ -374112,
+ -4131,
+ 2464803,
+ -40563352,
+ -257140602,
+ 1810204623,
+ -127491421,
+ -40863767,
+ 49604,
+ -733113,
+ 5642637,
+ 121004698,
+ 499435680,
+ 74982502,
+ 89059859,
+ 10843005,
+ -382044,
+ -3864,
+ 2381529,
+ -40818381,
+ -254181996,
+ 1813511649,
+ -131271741,
+ -41070101,
+ 96418,
+ -722610,
+ 5870428,
+ 120617933,
+ 486619645,
+ 84794593,
+ 90291282,
+ 10784310,
+ -390075,
+ -3606,
+ 2299185,
+ -41058145,
+ -251177611,
+ 1816638503,
+ -135050942,
+ -41266524,
+ 144245,
+ -712130,
+ 6093205,
+ 120198921,
+ 473858435,
+ 94713863,
+ 91508424,
+ 10721481,
+ -398201,
+ -3368,
+ 2217781,
+ -41282756,
+ -248128823,
+ 1819584546,
+ -138827913,
+ -41452866,
+ 193087,
+ -701676,
+ 6310969,
+ 119748124,
+ 461153873,
+ 104739244,
+ 92710756,
+ 10654473,
+ -406426,
+ -3132,
+ 2137327,
+ -41492322,
+ -245036958,
+ 1822349267,
+ -142601464,
+ -41628929,
+ 242949,
+ -691252,
+ 6523724,
+ 119265999,
+ 448507875,
+ 114869663,
+ 93897752,
+ 10583245,
+ -414746,
+ -2912,
+ 2057831,
+ -41686951,
+ -241903374,
+ 1824932281,
+ -146370443,
+ -41794536,
+ 293834,
+ -680861,
+ 6731474,
+ 118753032,
+ 435922297,
+ 125104011,
+ 95068884,
+ 10507753,
+ -423160,
+ -2712,
+ 1979304,
+ -41866767,
+ -238729432,
+ 1827332694,
+ -150133668,
+ -41949505,
+ 345746,
+ -670508,
+ 6934227,
+ 118209688,
+ 423398929,
+ 135441143,
+ 96223608,
+ 10427958,
+ -431669,
+ -2511,
+ 1901751,
+ -42031886,
+ -235516456,
+ 1829550506,
+ -153889956,
+ -42093652,
+ 398687,
+ -660194,
+ 7131990,
+ 117636454,
+ 410939657,
+ 145879910,
+ 97361389,
+ 10343818,
+ -440270,
+ -2325,
+ 1825182,
+ -42182431,
+ -232265822,
+ 1831584822,
+ -157638124,
+ -42226799,
+ 452661,
+ -649924,
+ 7324772,
+ 117033809,
+ 398546175,
+ 156419120,
+ 98481700,
+ 10255294,
+ -448963,
+ -2146,
+ 1749604,
+ -42318527,
+ -228978840,
+ 1833435641,
+ -161376958,
+ -42348769,
+ 507668,
+ -639701,
+ 7512586,
+ 116402257,
+ 386220337,
+ 167057527,
+ 99584012,
+ 10162347,
+ -457747,
+ -1983,
+ 1675021,
+ -42440309,
+ -225656869,
+ 1835102325,
+ -165105241,
+ -42459386,
+ 563713,
+ -629527,
+ 7695443,
+ 115742278,
+ 373963838,
+ 177793900,
+ 100667775,
+ 10064942,
+ -466619,
+ -1826,
+ 1601442,
+ -42547906,
+ -222301236,
+ 1836584617,
+ -168821761,
+ -42558471,
+ 620794,
+ -619405,
+ 7873360,
+ 115054374,
+ 361778403,
+ 188626976,
+ 101732478,
+ 9963039,
+ -475581,
+ -1680,
+ 1528871,
+ -42641448,
+ -218913268,
+ 1837882262,
+ -172525270,
+ -42645851,
+ 678915,
+ -609339,
+ 8046349,
+ 114339050,
+ 349665760,
+ 199555429,
+ 102777568,
+ 9856605,
+ -484628,
+ -1538,
+ 1457313,
+ -42721084,
+ -215494306,
+ 1838995132,
+ -176214553,
+ -42721356,
+ 738075,
+ -599330,
+ 8214429,
+ 113596801,
+ 337627602,
+ 210577947,
+ 103802518,
+ 9745603,
+ -493761,
+ -1408,
+ 1386774,
+ -42786950,
+ -212045678,
+ 1839922716,
+ -179888332,
+ -42784820,
+ 798277,
+ -589384,
+ 8377620,
+ 112828147,
+ 325665528,
+ 221693189,
+ 104806800,
+ 9630001,
+ -502977,
+ -1282,
+ 1317256,
+ -42839190,
+ -208568679,
+ 1840665012,
+ -183545359,
+ -42836069,
+ 859518,
+ -579499,
+ 8535941,
+ 112033582,
+ 313781201,
+ 232899731,
+ 105789888,
+ 9509767,
+ -512275,
+ -1167,
+ 1248765,
+ -42877955,
+ -205064634,
+ 1841221895,
+ -187184388,
+ -42874938,
+ 921799,
+ -569681,
+ 8689411,
+ 111213643,
+ 301976218,
+ 244196199,
+ 106751238,
+ 9384870,
+ -521653,
+ -1056,
+ 1181304,
+ -42903390,
+ -201534855,
+ 1841593235,
+ -190804125,
+ -42901268,
+ 985120,
+ -559931,
+ 8838056,
+ 110368825,
+ 290252177,
+ 255581155,
+ 107690338,
+ 9255277,
+ -531109,
+ -5103,
+ 1114874,
+ -42915649,
+ -197980653,
+ 1841778905,
+ -194403322,
+ -42914890,
+ 1049478,
+ -550250,
+ 8981898,
+ 109499655,
+ 278610646,
+ 267053128,
+ 108606645,
+ 9120963,
+ -540643
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/OS.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/OS.dat
new file mode 100644
index 0000000..85498ce
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/OS.dat
@@ -0,0 +1,34 @@
+ -124544,
+ -978521,
+ -2864821,
+ -2389124,
+ 6366098,
+ 16084768,
+ -241818,
+ -42361868,
+ -36460933,
+ 67595695,
+ 130198976,
+ -51663260,
+ -316629932,
+ -108234652,
+ 789670921,
+ 1696367320,
+ 1696367320,
+ 789670921,
+ -108234652,
+ -316629932,
+ -51663260,
+ 130198976,
+ 67595695,
+ -36460933,
+ -42361868,
+ -241818,
+ 16084768,
+ 6366098,
+ -2389124,
+ -2864821,
+ -978521,
+ -124544
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/OS.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/OS.sfp
new file mode 100644
index 0000000..d3ae310
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/OS.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/OS_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/OS_xs3.dat
new file mode 100644
index 0000000..9d2d2d5
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/OS_xs3.dat
@@ -0,0 +1,34 @@
+ -124544,
+ -2864821,
+ 6366098,
+ -241818,
+ -36460933,
+ 130198976,
+ -316629932,
+ 789670921,
+ -978521,
+ -2389124,
+ 16084768,
+ -42361868,
+ 67595695,
+ -51663260,
+ -108234652,
+ 1696367320,
+ 1696367320,
+ -108234652,
+ -51663260,
+ 67595695,
+ -42361868,
+ 16084768,
+ -2389124,
+ -978521,
+ 789670921,
+ -316629932,
+ 130198976,
+ -36460933,
+ -241818,
+ 6366098,
+ -2864821,
+ -124544
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP.dat
new file mode 100644
index 0000000..23b352e
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP.dat
@@ -0,0 +1,146 @@
+ 8168,
+ 45708,
+ 104359,
+ 78790,
+ -157243,
+ -486601,
+ -505401,
+ -55371,
+ 319514,
+ 23334,
+ -495493,
+ -231365,
+ 560238,
+ 430786,
+ -662347,
+ -744123,
+ 711275,
+ 1140300,
+ -706745,
+ -1642174,
+ 610188,
+ 2248225,
+ -391670,
+ -2960767,
+ 11311,
+ 3772536,
+ 572122,
+ -4670739,
+ -1403146,
+ 5635772,
+ 2529989,
+ -6638802,
+ -4002844,
+ 7641083,
+ 5872419,
+ -8594514,
+ -8190637,
+ 9440468,
+ 11011273,
+ -10106790,
+ -14386944,
+ 10510762,
+ 18374698,
+ -10552841,
+ -23033874,
+ 10117820,
+ 28433200,
+ -9067944,
+ -34655486,
+ 7237223,
+ 41810347,
+ -4416679,
+ -50049382,
+ 336639,
+ 59602091,
+ 5377387,
+ -70825878,
+ -13272841,
+ 84313039,
+ 24215471,
+ -101102529,
+ -39701697,
+ 123153244,
+ 62603844,
+ -154587408,
+ -99312971,
+ 205619439,
+ 167571156,
+ -309977862,
+ -341932252,
+ 681648246,
+ 1890204772,
+ 1890204772,
+ 681648246,
+ -341932252,
+ -309977862,
+ 167571156,
+ 205619439,
+ -99312971,
+ -154587408,
+ 62603844,
+ 123153244,
+ -39701697,
+ -101102529,
+ 24215471,
+ 84313039,
+ -13272841,
+ -70825878,
+ 5377387,
+ 59602091,
+ 336639,
+ -50049382,
+ -4416679,
+ 41810347,
+ 7237223,
+ -34655486,
+ -9067944,
+ 28433200,
+ 10117820,
+ -23033874,
+ -10552841,
+ 18374698,
+ 10510762,
+ -14386944,
+ -10106790,
+ 11011273,
+ 9440468,
+ -8190637,
+ -8594514,
+ 5872419,
+ 7641083,
+ -4002844,
+ -6638802,
+ 2529989,
+ 5635772,
+ -1403146,
+ -4670739,
+ 572122,
+ 3772536,
+ 11311,
+ -2960767,
+ -391670,
+ 2248225,
+ 610188,
+ -1642174,
+ -706745,
+ 1140300,
+ 711275,
+ -744123,
+ -662347,
+ 430786,
+ 560238,
+ -231365,
+ -495493,
+ 23334,
+ 319514,
+ -55371,
+ -505401,
+ -486601,
+ -157243,
+ 78790,
+ 104359,
+ 45708,
+ 8168
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/UP.sfp
new file mode 100644
index 0000000..fe34f51
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/UP.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.dat
new file mode 100644
index 0000000..664e2bb
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.dat
@@ -0,0 +1,98 @@
+ -9280,
+ -69184,
+ -243503,
+ -509739,
+ -627274,
+ -269382,
+ 478284,
+ 835727,
+ 66146,
+ -1221562,
+ -1185708,
+ 848520,
+ 2508966,
+ 774186,
+ -3098464,
+ -3534824,
+ 1796692,
+ 6386661,
+ 2120203,
+ -7414022,
+ -8170726,
+ 4491866,
+ 14200377,
+ 3563677,
+ -16632488,
+ -15770738,
+ 11622051,
+ 28288646,
+ 3081582,
+ -34834755,
+ -26194077,
+ 28427897,
+ 51723055,
+ -4137048,
+ -69273494,
+ -37988092,
+ 66029462,
+ 90837395,
+ -29794865,
+ -139666686,
+ -48492895,
+ 162394133,
+ 176084478,
+ -125919140,
+ -375489380,
+ -54732726,
+ 843524404,
+ 1649372999,
+ 1649372999,
+ 843524404,
+ -54732726,
+ -375489380,
+ -125919140,
+ 176084478,
+ 162394133,
+ -48492895,
+ -139666686,
+ -29794865,
+ 90837395,
+ 66029462,
+ -37988092,
+ -69273494,
+ -4137048,
+ 51723055,
+ 28427897,
+ -26194077,
+ -34834755,
+ 3081582,
+ 28288646,
+ 11622051,
+ -15770738,
+ -16632488,
+ 3563677,
+ 14200377,
+ 4491866,
+ -8170726,
+ -7414022,
+ 2120203,
+ 6386661,
+ 1796692,
+ -3534824,
+ -3098464,
+ 774186,
+ 2508966,
+ 848520,
+ -1185708,
+ -1221562,
+ 66146,
+ 835727,
+ 478284,
+ -269382,
+ -627274,
+ -509739,
+ -243503,
+ -69184,
+ -9280
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.sfp
new file mode 100644
index 0000000..58ad38e
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176_xs3.dat
new file mode 100644
index 0000000..a833df1
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP192176_xs3.dat
@@ -0,0 +1,98 @@
+ -9280,
+ -243503,
+ -627274,
+ 478284,
+ 66146,
+ -1185708,
+ 2508966,
+ -3098464,
+ -69184,
+ -509739,
+ -269382,
+ 835727,
+ -1221562,
+ 848520,
+ 774186,
+ -3534824,
+ 1796692,
+ 2120203,
+ -8170726,
+ 14200377,
+ -16632488,
+ 11622051,
+ 3081582,
+ -26194077,
+ 6386661,
+ -7414022,
+ 4491866,
+ 3563677,
+ -15770738,
+ 28288646,
+ -34834755,
+ 28427897,
+ 51723055,
+ -69273494,
+ 66029462,
+ -29794865,
+ -48492895,
+ 176084478,
+ -375489380,
+ 843524404,
+ -4137048,
+ -37988092,
+ 90837395,
+ -139666686,
+ 162394133,
+ -125919140,
+ -54732726,
+ 1649372999,
+ 1649372999,
+ -54732726,
+ -125919140,
+ 162394133,
+ -139666686,
+ 90837395,
+ -37988092,
+ -4137048,
+ 843524404,
+ -375489380,
+ 176084478,
+ -48492895,
+ -29794865,
+ 66029462,
+ -69273494,
+ 51723055,
+ 28427897,
+ -34834755,
+ 28288646,
+ -15770738,
+ 3563677,
+ 4491866,
+ -7414022,
+ 6386661,
+ -26194077,
+ 3081582,
+ 11622051,
+ -16632488,
+ 14200377,
+ -8170726,
+ 2120203,
+ 1796692,
+ -3534824,
+ 774186,
+ 848520,
+ -1221562,
+ 835727,
+ -269382,
+ -509739,
+ -69184,
+ -3098464,
+ 2508966,
+ -1185708,
+ 66146,
+ 478284,
+ -627274,
+ -243503,
+ -9280
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.dat
new file mode 100644
index 0000000..89f0b37
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.dat
@@ -0,0 +1,162 @@
+ -365,
+ 5082,
+ 43209,
+ 152526,
+ 317105,
+ 402859,
+ 245647,
+ -105299,
+ -306449,
+ -84688,
+ 303103,
+ 274481,
+ -233352,
+ -482075,
+ 47555,
+ 657118,
+ 275752,
+ -721224,
+ -718026,
+ 587626,
+ 1211486,
+ -185662,
+ -1640383,
+ -514063,
+ 1852565,
+ 1476015,
+ -1683074,
+ -2582508,
+ 990033,
+ 3631311,
+ 304192,
+ -4350713,
+ -2172739,
+ 4433711,
+ 4452422,
+ -3591564,
+ -6831260,
+ 1619448,
+ 8862205,
+ 1535508,
+ -10006431,
+ -5714956,
+ 9706801,
+ 10513117,
+ -7484687,
+ -15275312,
+ 3048122,
+ 19138608,
+ 3603870,
+ -21117203,
+ -12098913,
+ 20227352,
+ 21647758,
+ -15639559,
+ -31052146,
+ 6840083,
+ 38770014,
+ 6219859,
+ -43034268,
+ -23008064,
+ 42011218,
+ 42344720,
+ -33973438,
+ -62390887,
+ 17449585,
+ 80679177,
+ 8701642,
+ -94142322,
+ -45379445,
+ 99027170,
+ 93670333,
+ -90393772,
+ -156125604,
+ 60221314,
+ 240823166,
+ 10225113,
+ -378988070,
+ -195715864,
+ 781991600,
+ 1763451008,
+ 1763451008,
+ 781991600,
+ -195715864,
+ -378988070,
+ 10225113,
+ 240823166,
+ 60221314,
+ -156125604,
+ -90393772,
+ 93670333,
+ 99027170,
+ -45379445,
+ -94142322,
+ 8701642,
+ 80679177,
+ 17449585,
+ -62390887,
+ -33973438,
+ 42344720,
+ 42011218,
+ -23008064,
+ -43034268,
+ 6219859,
+ 38770014,
+ 6840083,
+ -31052146,
+ -15639559,
+ 21647758,
+ 20227352,
+ -12098913,
+ -21117203,
+ 3603870,
+ 19138608,
+ 3048122,
+ -15275312,
+ -7484687,
+ 10513117,
+ 9706801,
+ -5714956,
+ -10006431,
+ 1535508,
+ 8862205,
+ 1619448,
+ -6831260,
+ -3591564,
+ 4452422,
+ 4433711,
+ -2172739,
+ -4350713,
+ 304192,
+ 3631311,
+ 990033,
+ -2582508,
+ -1683074,
+ 1476015,
+ 1852565,
+ -514063,
+ -1640383,
+ -185662,
+ 1211486,
+ 587626,
+ -718026,
+ -721224,
+ 275752,
+ 657118,
+ 47555,
+ -482075,
+ -233352,
+ 274481,
+ 303103,
+ -84688,
+ -306449,
+ -105299,
+ 245647,
+ 402859,
+ 317105,
+ 152526,
+ 43209,
+ 5082,
+ -365
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.sfp
new file mode 100644
index 0000000..4b1e1fc
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844_xs3.dat
new file mode 100644
index 0000000..6e800de
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP4844_xs3.dat
@@ -0,0 +1,162 @@
+ -365,
+ 43209,
+ 317105,
+ 245647,
+ -306449,
+ 303103,
+ -233352,
+ 47555,
+ 5082,
+ 152526,
+ 402859,
+ -105299,
+ -84688,
+ 274481,
+ -482075,
+ 657118,
+ 275752,
+ -718026,
+ 1211486,
+ -1640383,
+ 1852565,
+ -1683074,
+ 990033,
+ 304192,
+ -721224,
+ 587626,
+ -185662,
+ -514063,
+ 1476015,
+ -2582508,
+ 3631311,
+ -4350713,
+ -2172739,
+ 4452422,
+ -6831260,
+ 8862205,
+ -10006431,
+ 9706801,
+ -7484687,
+ 3048122,
+ 4433711,
+ -3591564,
+ 1619448,
+ 1535508,
+ -5714956,
+ 10513117,
+ -15275312,
+ 19138608,
+ 3603870,
+ -12098913,
+ 21647758,
+ -31052146,
+ 38770014,
+ -43034268,
+ 42011218,
+ -33973438,
+ -21117203,
+ 20227352,
+ -15639559,
+ 6840083,
+ 6219859,
+ -23008064,
+ 42344720,
+ -62390887,
+ 17449585,
+ 8701642,
+ -45379445,
+ 93670333,
+ -156125604,
+ 240823166,
+ -378988070,
+ 781991600,
+ 80679177,
+ -94142322,
+ 99027170,
+ -90393772,
+ 60221314,
+ 10225113,
+ -195715864,
+ 1763451008,
+ 1763451008,
+ -195715864,
+ 10225113,
+ 60221314,
+ -90393772,
+ 99027170,
+ -94142322,
+ 80679177,
+ 781991600,
+ -378988070,
+ 240823166,
+ -156125604,
+ 93670333,
+ -45379445,
+ 8701642,
+ 17449585,
+ -62390887,
+ 42344720,
+ -23008064,
+ 6219859,
+ 6840083,
+ -15639559,
+ 20227352,
+ -21117203,
+ -33973438,
+ 42011218,
+ -43034268,
+ 38770014,
+ -31052146,
+ 21647758,
+ -12098913,
+ 3603870,
+ 19138608,
+ -15275312,
+ 10513117,
+ -5714956,
+ 1535508,
+ 1619448,
+ -3591564,
+ 4433711,
+ 3048122,
+ -7484687,
+ 9706801,
+ -10006431,
+ 8862205,
+ -6831260,
+ 4452422,
+ -2172739,
+ -4350713,
+ 3631311,
+ -2582508,
+ 1476015,
+ -514063,
+ -185662,
+ 587626,
+ -721224,
+ 304192,
+ 990033,
+ -1683074,
+ 1852565,
+ -1640383,
+ 1211486,
+ -718026,
+ 275752,
+ 657118,
+ -482075,
+ 274481,
+ -84688,
+ -105299,
+ 402859,
+ 152526,
+ 5082,
+ 47555,
+ -233352,
+ 303103,
+ -306449,
+ 245647,
+ 317105,
+ 43209,
+ -365
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.dat
new file mode 100644
index 0000000..ec4f0ca
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.dat
@@ -0,0 +1,98 @@
+ -9101,
+ -76622,
+ -283224,
+ -581742,
+ -628302,
+ -79124,
+ 674186,
+ 544815,
+ -666054,
+ -1217237,
+ 345915,
+ 2043431,
+ 513892,
+ -2808116,
+ -2068690,
+ 3176637,
+ 4364163,
+ -2709876,
+ -7269386,
+ 917972,
+ 10423128,
+ 2656858,
+ -13206880,
+ -8340864,
+ 14745735,
+ 16213379,
+ -13953535,
+ -26000121,
+ 9613564,
+ 36989031,
+ -478022,
+ -47973074,
+ -14636595,
+ 57219085,
+ 36809756,
+ -62423286,
+ -67114393,
+ 60549499,
+ 107029521,
+ -47261256,
+ -159681699,
+ 14972710,
+ 233854440,
+ 54822464,
+ -361545837,
+ -236889832,
+ 754902385,
+ 1798647991,
+ 1798647991,
+ 754902385,
+ -236889832,
+ -361545837,
+ 54822464,
+ 233854440,
+ 14972710,
+ -159681699,
+ -47261256,
+ 107029521,
+ 60549499,
+ -67114393,
+ -62423286,
+ 36809756,
+ 57219085,
+ -14636595,
+ -47973074,
+ -478022,
+ 36989031,
+ 9613564,
+ -26000121,
+ -13953535,
+ 16213379,
+ 14745735,
+ -8340864,
+ -13206880,
+ 2656858,
+ 10423128,
+ 917972,
+ -7269386,
+ -2709876,
+ 4364163,
+ 3176637,
+ -2068690,
+ -2808116,
+ 513892,
+ 2043431,
+ 345915,
+ -1217237,
+ -666054,
+ 544815,
+ 674186,
+ -79124,
+ -628302,
+ -581742,
+ -283224,
+ -76622,
+ -9101
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.sfp b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.sfp
new file mode 100644
index 0000000..bda5910
Binary files /dev/null and b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF.sfp differ
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UPF_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF_xs3.dat
new file mode 100644
index 0000000..19f4d08
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UPF_xs3.dat
@@ -0,0 +1,98 @@
+ -9101,
+ -283224,
+ -628302,
+ 674186,
+ -666054,
+ 345915,
+ 513892,
+ -2068690,
+ -76622,
+ -581742,
+ -79124,
+ 544815,
+ -1217237,
+ 2043431,
+ -2808116,
+ 3176637,
+ 4364163,
+ -7269386,
+ 10423128,
+ -13206880,
+ 14745735,
+ -13953535,
+ 9613564,
+ -478022,
+ -2709876,
+ 917972,
+ 2656858,
+ -8340864,
+ 16213379,
+ -26000121,
+ 36989031,
+ -47973074,
+ -14636595,
+ 36809756,
+ -67114393,
+ 107029521,
+ -159681699,
+ 233854440,
+ -361545837,
+ 754902385,
+ 57219085,
+ -62423286,
+ 60549499,
+ -47261256,
+ 14972710,
+ 54822464,
+ -236889832,
+ 1798647991,
+ 1798647991,
+ -236889832,
+ 54822464,
+ 14972710,
+ -47261256,
+ 60549499,
+ -62423286,
+ 57219085,
+ 754902385,
+ -361545837,
+ 233854440,
+ -159681699,
+ 107029521,
+ -67114393,
+ 36809756,
+ -14636595,
+ -47973074,
+ 36989031,
+ -26000121,
+ 16213379,
+ -8340864,
+ 2656858,
+ 917972,
+ -2709876,
+ -478022,
+ 9613564,
+ -13953535,
+ 14745735,
+ -13206880,
+ 10423128,
+ -7269386,
+ 4364163,
+ 3176637,
+ -2808116,
+ 2043431,
+ -1217237,
+ 544815,
+ -79124,
+ -581742,
+ -76622,
+ -2068690,
+ 513892,
+ 345915,
+ -666054,
+ 674186,
+ -628302,
+ -283224,
+ -9101
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/UP_xs3.dat b/lib_src/lib_src/src/multirate_hifi/FilterData/UP_xs3.dat
new file mode 100644
index 0000000..6b966c2
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/UP_xs3.dat
@@ -0,0 +1,146 @@
+ 8168,
+ 104359,
+ -157243,
+ -505401,
+ 319514,
+ -495493,
+ 560238,
+ -662347,
+ 45708,
+ 78790,
+ -486601,
+ -55371,
+ 23334,
+ -231365,
+ 430786,
+ -744123,
+ 711275,
+ -706745,
+ 610188,
+ -391670,
+ 11311,
+ 572122,
+ -1403146,
+ 2529989,
+ 1140300,
+ -1642174,
+ 2248225,
+ -2960767,
+ 3772536,
+ -4670739,
+ 5635772,
+ -6638802,
+ -4002844,
+ 5872419,
+ -8190637,
+ 11011273,
+ -14386944,
+ 18374698,
+ -23033874,
+ 28433200,
+ 7641083,
+ -8594514,
+ 9440468,
+ -10106790,
+ 10510762,
+ -10552841,
+ 10117820,
+ -9067944,
+ -34655486,
+ 41810347,
+ -50049382,
+ 59602091,
+ -70825878,
+ 84313039,
+ -101102529,
+ 123153244,
+ 7237223,
+ -4416679,
+ 336639,
+ 5377387,
+ -13272841,
+ 24215471,
+ -39701697,
+ 62603844,
+ -154587408,
+ 205619439,
+ -309977862,
+ 681648246,
+ 1890204772,
+ -341932252,
+ 167571156,
+ -99312971,
+ -99312971,
+ 167571156,
+ -341932252,
+ 1890204772,
+ 681648246,
+ -309977862,
+ 205619439,
+ -154587408,
+ 62603844,
+ -39701697,
+ 24215471,
+ -13272841,
+ 5377387,
+ 336639,
+ -4416679,
+ 7237223,
+ 123153244,
+ -101102529,
+ 84313039,
+ -70825878,
+ 59602091,
+ -50049382,
+ 41810347,
+ -34655486,
+ -9067944,
+ 10117820,
+ -10552841,
+ 10510762,
+ -10106790,
+ 9440468,
+ -8594514,
+ 7641083,
+ 28433200,
+ -23033874,
+ 18374698,
+ -14386944,
+ 11011273,
+ -8190637,
+ 5872419,
+ -4002844,
+ -6638802,
+ 5635772,
+ -4670739,
+ 3772536,
+ -2960767,
+ 2248225,
+ -1642174,
+ 1140300,
+ 2529989,
+ -1403146,
+ 572122,
+ 11311,
+ -391670,
+ 610188,
+ -706745,
+ 711275,
+ -744123,
+ 430786,
+ -231365,
+ 23334,
+ -55371,
+ -486601,
+ 78790,
+ 45708,
+ -662347,
+ 560238,
+ -495493,
+ 319514,
+ -505401,
+ -157243,
+ 104359,
+ 8168
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/FilterData/scale_dat.py b/lib_src/lib_src/src/multirate_hifi/FilterData/scale_dat.py
new file mode 100644
index 0000000..b499604
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/FilterData/scale_dat.py
@@ -0,0 +1,17 @@
+from argparse import ArgumentParser
+from pathlib import Path
+
+parse = ArgumentParser()
+
+parse.add_argument("SCALE_FACTOR", type=float, help="number to scale all the filters by")
+args = parse.parse_args()
+
+
+for filepath in Path(__file__).parent.glob("*.dat"):
+ data_txt = filepath.read_text()
+ data = list(float(d.strip()) for d in data_txt.strip().split(",") if len(d))
+ data = [int(round(args.SCALE_FACTOR * i)) for i in data]
+ data = " " + ",\n ".join(str(d) for d in data) + "\n\n\n"
+ filepath.write_text(data)
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.c b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.c
new file mode 100644
index 0000000..679e4d5
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.c
@@ -0,0 +1,732 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// File: asrc.c
+//
+//
+// Top level implementation file for the ASRC
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+#include "use_vpu.h"
+
+// Integer arithmetic include
+#include "src_mrhf_int_arithmetic.h"
+// ASRC include
+#include "src.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+// State init value
+#define ASRC_STATE_INIT 0
+
+// Nominal Fs Ratio values
+#define ASRC_FS_44_F (44100.0)
+#define ASRC_FS_48_F (48000.0)
+#define ASRC_FS_88_F (88200.0)
+#define ASRC_FS_96_F (96000.0)
+#define ASRC_FS_176_F (176400.0)
+#define ASRC_FS_192_F (192000.0)
+
+#define ASRC_FS_RATIO_44_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_44_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_44_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_44_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_44_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_44_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_44_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_44_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_48_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_48_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_48_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_48_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_48_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_48_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_48_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_48_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_88_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_88_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_88_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_88_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_88_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_88_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_88_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_88_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_96_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_96_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_96_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_96_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_96_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_96_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_96_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_96_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_176_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_176_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_176_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_176_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_176_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_176_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_176_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_176_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_192_44 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_44_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_44_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_192_48 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_48_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_48_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_192_88 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_88_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_88_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_192_96 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_96_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_96_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_192_176 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_176_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_176_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+#define ASRC_FS_RATIO_192_192 (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))) >> 32)
+#define ASRC_FS_RATIO_192_192_LO (uint32_t)((unsigned long long)(((double)ASRC_FS_192_F / ASRC_FS_192_F) * ((unsigned long long)1 << (ASRC_FS_RATIO_UNIT_BIT + 32))))
+
+#define ASRC_FS_RATIO_MIN_FACTOR (0.99)
+#define ASRC_FS_RATIO_MAX_FACTOR (1.01)
+
+#define ASRC_ADFIR_INITIAL_PHASE 32
+
+// Time ratio shift values
+#define ASRC_FS_RATIO_PHASE_N_BITS 7
+#define ASRC_FS_RATIO_BASE_SHIFT (ASRC_FS_RATIO_UNIT_BIT - ASRC_FS_RATIO_PHASE_N_BITS)
+#define ASRC_FS_RATIO_SHIFT_M1 (ASRC_FS_RATIO_BASE_SHIFT + 1)
+#define ASRC_FS_RATIO_SHIFT_0 (ASRC_FS_RATIO_BASE_SHIFT)
+#define ASRC_FS_RATIO_SHIFT_P1 (ASRC_FS_RATIO_BASE_SHIFT - 1)
+
+
+// Random number generator / dithering
+#define ASRC_R_CONS 32767
+#define ASRC_R_BASE 1664525
+#define ASRC_RPDF_BITS_SHIFT 16 // Shift to select bits in pseudo-random number
+#define ASRC_RPDF_MASK 0x0000007F // For dithering at 24bits (in 2.30)
+#define ASRC_DATA24_MASK 0xFFFFFF00 // Mask for 24bits data (once rescaled to 1.31)
+#define ASRC_DITHER_BIAS 0xFFFFFFC0 // TPDF dither bias for compensating masking at 24bits but expressed in 2.30
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+ASRCFiltersIDs_t sASRCFiltersIDs[ASRC_N_FS][ASRC_N_FS] = // Filter configuration table [Fsin][Fsout]
+{
+ { // Fsin = 44.1kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 48kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ },
+ { // Fsin = 48kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_UP4844_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 48kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ },
+ { // Fsin = 88.2kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_BL_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_BL8848_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 48kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ },
+ { // Fsin = 96kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_BL9644_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_BL_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 48kHz
+ {{FILTER_DEFS_ASRC_FIR_UP4844_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UP_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ },
+ { // Fsin = 176.4kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_DS_ID, FILTER_DEFS_ASRC_FIR_BL_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_DS_ID, FILTER_DEFS_ASRC_FIR_BL8848_ID}}, // Fsout = 48kHz
+ {{FITLER_DEFS_ASRC_FIR_BLF_ID, FILTER_DEFS_ASRC_FIR_NONE_ID,}}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_ASRC_FIR_BL17696_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UPF_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UPF_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ },
+ { // Fsin = 192kHz
+ // F1 F2
+ {{FILTER_DEFS_ASRC_FIR_DS_ID, FILTER_DEFS_ASRC_FIR_BL9644_ID}}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_ASRC_FIR_DS_ID, FILTER_DEFS_ASRC_FIR_BL_ID}}, // Fsout = 48kHz
+ {{FITLER_DEFS_ASRC_FIR_BL19288_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 88.2kHz
+ {{FITLER_DEFS_ASRC_FIR_BLF_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 96kHz
+ {{FILTER_DEFS_ASRC_FIR_UP192176_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_ASRC_FIR_UPF_ID, FILTER_DEFS_ASRC_FIR_NONE_ID}} // Fsout = 192kHz
+ }
+};
+
+
+ASRCFsRatioConfigs_t sFsRatioConfigs[ASRC_N_FS][ASRC_N_FS] = // Fs ratio configuration table [Fsin][Fsout]
+{
+ { // Fsin = 44.1kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_44_44, ASRC_FS_RATIO_44_44_LO, (unsigned int)(ASRC_FS_RATIO_44_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_44_48, ASRC_FS_RATIO_44_48_LO, (unsigned int)(ASRC_FS_RATIO_44_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_44_88, ASRC_FS_RATIO_44_88_LO, (unsigned int)(ASRC_FS_RATIO_44_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_44_96, ASRC_FS_RATIO_44_96_LO, (unsigned int)(ASRC_FS_RATIO_44_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_44_176, ASRC_FS_RATIO_44_176_LO, (unsigned int)(ASRC_FS_RATIO_44_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_44_192, ASRC_FS_RATIO_44_192_LO, (unsigned int)(ASRC_FS_RATIO_44_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_44_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ },
+ { // Fsin = 48kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_48_44, ASRC_FS_RATIO_48_44_LO, (unsigned int)(ASRC_FS_RATIO_48_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_48_48, ASRC_FS_RATIO_48_48_LO, (unsigned int)(ASRC_FS_RATIO_48_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_48_88, ASRC_FS_RATIO_48_88_LO, (unsigned int)(ASRC_FS_RATIO_48_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_48_96, ASRC_FS_RATIO_48_96_LO, (unsigned int)(ASRC_FS_RATIO_48_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_48_176, ASRC_FS_RATIO_48_176_LO, (unsigned int)(ASRC_FS_RATIO_48_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_48_192, ASRC_FS_RATIO_48_192_LO, (unsigned int)(ASRC_FS_RATIO_48_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_48_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ },
+ { // Fsin = 88.2kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_88_44, ASRC_FS_RATIO_88_44_LO, (unsigned int)(ASRC_FS_RATIO_88_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_88_48, ASRC_FS_RATIO_88_48_LO, (unsigned int)(ASRC_FS_RATIO_88_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_88_88, ASRC_FS_RATIO_88_88_LO, (unsigned int)(ASRC_FS_RATIO_88_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_88_96, ASRC_FS_RATIO_88_96_LO, (unsigned int)(ASRC_FS_RATIO_88_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_88_176, ASRC_FS_RATIO_88_176_LO, (unsigned int)(ASRC_FS_RATIO_88_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_88_192, ASRC_FS_RATIO_88_192_LO, (unsigned int)(ASRC_FS_RATIO_88_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_88_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ },
+ { // Fsin = 96kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_96_44, ASRC_FS_RATIO_96_44_LO, (unsigned int)(ASRC_FS_RATIO_96_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_96_48, ASRC_FS_RATIO_96_48_LO, (unsigned int)(ASRC_FS_RATIO_96_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_96_88, ASRC_FS_RATIO_96_88_LO, (unsigned int)(ASRC_FS_RATIO_96_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_96_96, ASRC_FS_RATIO_96_96_LO, (unsigned int)(ASRC_FS_RATIO_96_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_96_176, ASRC_FS_RATIO_96_176_LO, (unsigned int)(ASRC_FS_RATIO_96_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_96_192, ASRC_FS_RATIO_96_192_LO, (unsigned int)(ASRC_FS_RATIO_96_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_96_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ },
+ { // Fsin = 176.4kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_176_44, ASRC_FS_RATIO_176_44_LO, (unsigned int)(ASRC_FS_RATIO_176_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_M1}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_176_48, ASRC_FS_RATIO_176_48_LO, (unsigned int)(ASRC_FS_RATIO_176_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_M1}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_176_88, ASRC_FS_RATIO_176_88_LO, (unsigned int)(ASRC_FS_RATIO_176_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_176_96, ASRC_FS_RATIO_176_96_LO, (unsigned int)(ASRC_FS_RATIO_176_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_176_176, ASRC_FS_RATIO_176_176_LO, (unsigned int)(ASRC_FS_RATIO_176_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_176_192, ASRC_FS_RATIO_176_192_LO, (unsigned int)(ASRC_FS_RATIO_176_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_176_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ },
+ { // Fsin = 192kHz
+ // Nominal Fs Ratio // Minimal Fs Ratio // Maximal Fs Ratio Shift for time step
+ {ASRC_FS_RATIO_192_44, ASRC_FS_RATIO_192_44_LO, (unsigned int)(ASRC_FS_RATIO_192_44 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_44 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_M1}, // Fsout = 44.1kHz
+ {ASRC_FS_RATIO_192_48, ASRC_FS_RATIO_192_48_LO, (unsigned int)(ASRC_FS_RATIO_192_48 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_48 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_M1}, // Fsout = 48kHz
+ {ASRC_FS_RATIO_192_88, ASRC_FS_RATIO_192_88_LO, (unsigned int)(ASRC_FS_RATIO_192_88 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_88 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 88.2kHz
+ {ASRC_FS_RATIO_192_96, ASRC_FS_RATIO_192_96_LO, (unsigned int)(ASRC_FS_RATIO_192_96 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_96 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_0}, // Fsout = 96kHz
+ {ASRC_FS_RATIO_192_176, ASRC_FS_RATIO_192_176_LO, (unsigned int)(ASRC_FS_RATIO_192_176 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_176 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1}, // Fsout = 176.4kHz
+ {ASRC_FS_RATIO_192_192, ASRC_FS_RATIO_192_192_LO, (unsigned int)(ASRC_FS_RATIO_192_192 * ASRC_FS_RATIO_MIN_FACTOR), (unsigned int)(ASRC_FS_RATIO_192_192 * ASRC_FS_RATIO_MAX_FACTOR), ASRC_FS_RATIO_SHIFT_P1} // Fsout = 192kHz
+ }
+};
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+#if SRC_USE_VPU
+#define xs3_index_shuffle(a,b) [(b)^7][a]
+#else
+#define xs3_index_shuffle(a,b) [a][b]
+#endif
+
+// ==================================================================== //
+// Function: ASRC_prepare_coefs //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Prepares the ASRC coefficients from the prototype //
+// Needs to be called only once //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_prepare_coefs(void)
+{
+ unsigned int ui, uj;
+ int* piPrototypeCoefs = iADFirPrototypeCoefs + FILTER_DEFS_ADFIR_PROTOTYPE_N_TAPS - FILTER_DEFS_ADFIR_N_PHASES;
+
+ // First fill in the phases which start normally
+ for(ui = 0; ui < FILTER_DEFS_ADFIR_N_PHASES; ui++)
+ {
+ // Copy phase information
+ for(uj = 0; uj < FILTER_DEFS_ADFIR_PHASE_N_TAPS - 1; uj++)
+ iADFirCoefs xs3_index_shuffle(ui, uj) = *(piPrototypeCoefs + ui - uj * FILTER_DEFS_ADFIR_N_PHASES);
+ // Zero fill last coefficient
+ iADFirCoefs xs3_index_shuffle(ui, FILTER_DEFS_ADFIR_PHASE_N_TAPS - 1) = 0;
+ }
+
+ // Then fill in the two phases which start delayed
+ for(ui = 0; ui < 2; ui++)
+ {
+ // Zero fill first coefficient
+ iADFirCoefs xs3_index_shuffle(FILTER_DEFS_ADFIR_N_PHASES + ui, 0) = 0;
+ // Copy phase informaiton
+ for(uj = 0; uj < FILTER_DEFS_ADFIR_PHASE_N_TAPS - 1; uj++)
+ iADFirCoefs xs3_index_shuffle(FILTER_DEFS_ADFIR_N_PHASES + ui,uj + 1) = *(piPrototypeCoefs + ui - uj * FILTER_DEFS_ADFIR_N_PHASES);
+ }
+
+ return ASRC_NO_ERROR;
+}
+
+// ==================================================================== //
+// Function: ASRC_init //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Inits the ASRC passed as argument //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_init(asrc_ctrl_t* pasrc_ctrl)
+{
+ ASRCFiltersIDs_t* psFiltersID;
+ FIRDescriptor_t* psFIRDescriptor;
+ ADFIRDescriptor_t* psADFIRDescriptor;
+
+
+ // Check if state is allocated
+ if(pasrc_ctrl->psState == 0)
+ return ASRC_ERROR;
+
+ // Check if stack is allocated
+ if(pasrc_ctrl->piStack == 0)
+ return ASRC_ERROR;
+
+ // Check if valid Fsin and Fsout have been provided
+ if( (pasrc_ctrl->eInFs < ASRC_FS_MIN) || (pasrc_ctrl->eInFs > ASRC_FS_MAX))
+ return ASRC_ERROR;
+ if( (pasrc_ctrl->eOutFs < ASRC_FS_MIN) || (pasrc_ctrl->eOutFs > ASRC_FS_MAX))
+ return ASRC_ERROR;
+
+ // Set nominal fs ratio
+ pasrc_ctrl->uiFsRatio = sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].uiNominalFsRatio;
+ pasrc_ctrl->uiFsRatio_lo = sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].uiNominalFsRatio_lo;
+
+ // Check that number of input samples is allocated and is a multiple of 4
+ if(pasrc_ctrl->uiNInSamples == 0)
+ return ASRC_ERROR;
+ if((pasrc_ctrl->uiNInSamples & 0x3) != 0x0)
+ return ASRC_ERROR;
+
+ // Load filters ID and number of samples
+ psFiltersID = &sASRCFiltersIDs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs];
+
+
+ // Configure filters F1 and F2 from filters ID and number of samples
+
+ // Filter F1
+ // ---------
+ psFIRDescriptor = &sASRCFirDescriptor[psFiltersID->uiFID[ASRC_F1_INDEX]];
+ // Set number of input samples and input samples step
+ pasrc_ctrl->sFIRF1Ctrl.uiNInSamples = pasrc_ctrl->uiNInSamples;
+ pasrc_ctrl->sFIRF1Ctrl.uiInStep = pasrc_ctrl->uiNchannels;
+ // Set delay line base pointer
+ if( psFiltersID->uiFID[ASRC_F1_INDEX] == FILTER_DEFS_ASRC_FIR_DS_ID )
+ pasrc_ctrl->sFIRF1Ctrl.piDelayB = pasrc_ctrl->psState->iDelayFIRShort;
+ else
+ pasrc_ctrl->sFIRF1Ctrl.piDelayB = pasrc_ctrl->psState->iDelayFIRLong;
+ // Set output buffer step
+ pasrc_ctrl->sFIRF1Ctrl.uiOutStep = 1;//ASRC_N_CHANNELS; //TODO confirm this
+
+ // Call init for FIR F1
+ if(FIR_init_from_desc(&pasrc_ctrl->sFIRF1Ctrl, psFIRDescriptor) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Update synchronous number of samples
+ if( psFiltersID->uiFID[ASRC_F1_INDEX] != FILTER_DEFS_ASRC_FIR_NONE_ID )
+ pasrc_ctrl->uiNSyncSamples = pasrc_ctrl->sFIRF1Ctrl.uiNOutSamples;
+
+
+ // Filter F2
+ // ---------
+ psFIRDescriptor = &sASRCFirDescriptor[psFiltersID->uiFID[ASRC_F2_INDEX]];
+ // Set number of input samples and input samples step
+ pasrc_ctrl->sFIRF2Ctrl.uiNInSamples = pasrc_ctrl->sFIRF1Ctrl.uiNOutSamples;
+ pasrc_ctrl->sFIRF2Ctrl.uiInStep = pasrc_ctrl->sFIRF1Ctrl.uiOutStep;
+ // Set delay line base pointer (second filter is always long with ASRC)
+ pasrc_ctrl->sFIRF2Ctrl.piDelayB = pasrc_ctrl->psState->iDelayFIRLong;
+ // Set output buffer step
+ pasrc_ctrl->sFIRF2Ctrl.uiOutStep = 1;//ASRC_N_CHANNELS; //TODO confirm this. Looks like 1 = channel per instance
+
+ // Call init for FIR F2
+ if(FIR_init_from_desc(&pasrc_ctrl->sFIRF2Ctrl, psFIRDescriptor) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Update synchronous number of samples
+ if( psFiltersID->uiFID[ASRC_F2_INDEX] != FILTER_DEFS_ASRC_FIR_NONE_ID )
+ pasrc_ctrl->uiNSyncSamples = pasrc_ctrl->sFIRF2Ctrl.uiNOutSamples;
+
+
+ // Setup fixed input/output buffers for F1 and F2
+ // ----------------------------------------------
+ // We set all fixed items (to stack base)
+ // F1 input is never from stack, so don't set it
+ pasrc_ctrl->sFIRF2Ctrl.piIn = pasrc_ctrl->piStack;
+ pasrc_ctrl->sFIRF1Ctrl.piOut = pasrc_ctrl->piStack;
+ pasrc_ctrl->sFIRF2Ctrl.piOut = pasrc_ctrl->piStack;
+
+
+
+ // Filter F3
+ // ---------
+ psADFIRDescriptor = &sADFirDescriptor;
+
+ // Set delay line base pointer
+ pasrc_ctrl->sADFIRF3Ctrl.piDelayB = pasrc_ctrl->psState->iDelayADFIR;
+ // Set AD coefficients pointer
+ pasrc_ctrl->sADFIRF3Ctrl.piADCoefs = pasrc_ctrl->piADCoefs;
+
+ // Call init for ADFIR F3
+ if(ADFIR_init_from_desc(&pasrc_ctrl->sADFIRF3Ctrl, psADFIRDescriptor) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Call sync function
+ if(ASRC_sync(pasrc_ctrl) != ASRC_NO_ERROR)
+ return ASRC_ERROR;
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_sync //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Syncs the ASRC passed as argument //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_sync(asrc_ctrl_t* pasrc_ctrl)
+{
+ // Sync the FIR and ADFIR
+ if(FIR_sync(&pasrc_ctrl->sFIRF1Ctrl) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+ if(FIR_sync(&pasrc_ctrl->sFIRF2Ctrl) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ if(ADFIR_sync(&pasrc_ctrl->sADFIRF3Ctrl) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Reset time
+ pasrc_ctrl->iTimeInt = FILTER_DEFS_ADFIR_N_PHASES + ASRC_ADFIR_INITIAL_PHASE;
+ pasrc_ctrl->uiTimeFract = 0;
+
+ // Reset random seeds to initial values
+ pasrc_ctrl->psState->uiRndSeed = pasrc_ctrl->uiRndSeedInit;
+
+ // Update time step based on Fs ratio
+ if(ASRC_update_fs_ratio(pasrc_ctrl) != ASRC_NO_ERROR)
+ return ASRC_ERROR;
+
+ return ASRC_NO_ERROR;
+}
+
+
+
+// ==================================================================== //
+// Function: ASRC_proc_F1_F2 //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Processes F1 and F2 for a channel //
+// ==================================================================== //
+#if (XCC_VERSION_MAJOR < 1402) //Beyond 14.2.0 we have proper function pointer support for C
+#pragma stackfunction 64 //Generous stack allocation (probably needs just a handful through F1_F2, ASM etc).
+#endif
+ASRCReturnCodes_t ASRC_proc_F1_F2(asrc_ctrl_t* pasrc_ctrl)
+{
+
+ // Setup variable input / output buffers
+ pasrc_ctrl->sFIRF1Ctrl.piIn = pasrc_ctrl->piIn;
+
+ // F1 is always enabled, so call F1
+ __attribute__((fptrgroup("MRHF_G1")))
+ FIRReturnCodes_t ret = pasrc_ctrl->sFIRF1Ctrl.pvProc((int *)&pasrc_ctrl->sFIRF1Ctrl);
+ if(ret != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Check if F2 is enabled
+ if(pasrc_ctrl->sFIRF2Ctrl.eEnable == FIR_ON)
+ {
+ // F2 is enabled, so call F2
+ __attribute__((fptrgroup("MRHF_G1")))
+ FIRReturnCodes_t ret = pasrc_ctrl->sFIRF2Ctrl.pvProc((int *)&pasrc_ctrl->sFIRF2Ctrl);
+ if(ret != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ }
+
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_update_fs_ratio //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Updates the ASRC with the new Fs ratio //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_update_fs_ratio(asrc_ctrl_t* pasrc_ctrl)
+{
+ unsigned int uiFsRatio = pasrc_ctrl->uiFsRatio;
+ unsigned int uiFsRatio_low = pasrc_ctrl->uiFsRatio_lo;
+
+ // Check for bounds of new Fs ratio
+ if( (uiFsRatio < sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].uiMinFsRatio) ||
+ (uiFsRatio > sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].uiMaxFsRatio) )
+ return ASRC_ERROR;
+
+ // Apply shift to time ratio to build integer and fractional parts of time step
+ pasrc_ctrl->iTimeStepInt = uiFsRatio >> (sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].iFsRatioShift);
+ pasrc_ctrl->uiTimeStepFract = uiFsRatio << (32 - sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].iFsRatioShift);
+ pasrc_ctrl->uiTimeStepFract |= (uint32_t)(uiFsRatio_low >> sFsRatioConfigs[pasrc_ctrl->eInFs][pasrc_ctrl->eOutFs].iFsRatioShift);
+
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_proc_F3_in_spl //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// int iInSample: new input sample //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Writes new input sample to F3 delay line //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_proc_F3_in_spl(asrc_ctrl_t* pasrc_ctrl, int iInSample)
+{
+ pasrc_ctrl->sADFIRF3Ctrl.iIn = iInSample;
+ if(ADFIR_proc_in_spl(&pasrc_ctrl->sADFIRF3Ctrl) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ // Decrease next output time (this is an integer value, so no influence on fractional part)
+ pasrc_ctrl->iTimeInt -= FILTER_DEFS_ADFIR_N_PHASES;
+
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_proc_F3_time //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR if an output sample must be produced //
+// ASRC_ERROR if no output sample needs to be produced //
+// Description: Processes F3 time //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_proc_F3_time(asrc_ctrl_t* pasrc_ctrl)
+{
+ unsigned int uiTemp;
+ int iAlpha;
+ int iH[3]; //iH0, iH1, iH2;
+ int iZero;
+ __int64_t i64Acc0;
+ int* piPhase0;
+ int* piADCoefs;
+
+ // Check if the next output time instant is in the current time slot
+ // -----------------------------------------------------------------
+ // if not return value showing that no output sample needs to be produced
+ // Update cycle count
+ if(pasrc_ctrl->iTimeInt >= FILTER_DEFS_ADFIR_N_PHASES)
+ return ASRC_ERROR;
+
+
+ // Update adaptive filter coefficients
+ // -----------------------------------
+ // Coefficients computation load approximation: 15 instructions
+ // Loop load approximation: 5.625 instructions per sample + 15 instructions overhead => 5.625 * 16 + 15 = 90 + 15 = 105 Instructions
+ // Total: 125 instructions
+
+ // Set register to zero
+ iZero = 0;
+
+ // Compute adative coefficients spline factors
+ // The fractional part of time gives alpha
+ iAlpha = pasrc_ctrl->uiTimeFract>>1; // Now alpha can be seen as a signed number
+ i64Acc0 = (long long)iAlpha * (long long)iAlpha;
+
+#if SRC_USE_VPU
+ iH[2] = (int)(i64Acc0>>32);
+ iH[0] = 0x40000000; // Load H2 with 0.5;
+ iH[1] = iH[0] - iH[2]; // H1 = 0.5 - 0.5 * alpha * alpha;
+ iH[1] = iH[1] - iH[2]; // H1 = 0.5 - alpha * alpha
+ iH[1] = iH[1] + iAlpha; // H1 = 0.5 + alpha - alpha * alpha;
+ iH[0] = iH[0] - iAlpha; // H2 = 0.5 - alpha
+ iH[0] = iH[0] + iH[2]; // H2 = 0.5 - alpha + 0.5 * alpha * alpha
+
+ // The integer part of time gives the phase
+ piPhase0 = &iADFirCoefs[0][pasrc_ctrl->iTimeInt];
+ piADCoefs = pasrc_ctrl->piADCoefs; // Given limited number of registers, this should be DP
+ src_mrhf_spline_coeff_gen_inner_loop_asm_xs3(piPhase0, iH, piADCoefs, FILTER_DEFS_ADFIR_PHASE_N_TAPS);
+#else
+ iH[0] = (int)(i64Acc0>>32);
+ iH[2] = 0x40000000; // Load H2 with 0.5;
+ iH[1] = iH[2] - iH[0]; // H1 = 0.5 - 0.5 * alpha * alpha;
+ iH[1] = iH[1] - iH[0]; // H1 = 0.5 - alpha * alpha
+ iH[1] = iH[1] + iAlpha; // H1 = 0.5 + alpha - alpha * alpha;
+ iH[2] = iH[2] - iAlpha; // H2 = 0.5 - alpha
+ iH[2] = iH[2] + iH[0]; // H2 = 0.5 - alpha + 0.5 * alpha * alpha
+
+ // The integer part of time gives the phase
+ piPhase0 = iADFirCoefs[pasrc_ctrl->iTimeInt];
+ piADCoefs = pasrc_ctrl->piADCoefs; // Given limited number of registers, this should be DP
+
+ src_mrhf_spline_coeff_gen_inner_loop_asm(piPhase0, iH, piADCoefs, FILTER_DEFS_ADFIR_PHASE_N_TAPS);
+#endif
+
+ // Step time for next output sample
+ // --------------------------------
+ // Step to next output time (add integer and fractional parts)
+ pasrc_ctrl->iTimeInt += pasrc_ctrl->iTimeStepInt;
+ // For fractional part, this can be optimized using the add with carry instruction of XS2
+ uiTemp = pasrc_ctrl->uiTimeFract;
+ pasrc_ctrl->uiTimeFract += pasrc_ctrl->uiTimeStepFract;
+ if(pasrc_ctrl->uiTimeFract < uiTemp)
+ pasrc_ctrl->iTimeInt++;
+
+ //printf("TimeInt = %x TimeFract = %x", pasrc_ctrl->iTimeInt, pasrc_ctrl->uiTimeFract);
+
+ //int result=0; for (int i=0; i<16; i++)result += piADCoefs[i];printf("ASRC_proc_F3_time checksum=0x%x\n", result);
+
+
+ // Return value showing that an output sample must be produced
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_proc_F3_macc //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// int* piOutSample: Address of output sample //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Processes F3 for a channel //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_proc_F3_macc(asrc_ctrl_t* pasrc_ctrl, int* piOutSample)
+{
+ pasrc_ctrl->sADFIRF3Ctrl.piOut = piOutSample;
+ // Call processing function
+ if(ADFIR_proc_macc(&pasrc_ctrl->sADFIRF3Ctrl) != FIR_NO_ERROR)
+ return ASRC_ERROR;
+
+ pasrc_ctrl->uiNASRCOutSamples++;
+
+ return ASRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ASRC_proc_dither //
+// Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+// Return values: ASRC_NO_ERROR on success //
+// ASRC_ERROR on failure //
+// Description: Processes dither for a channel //
+// ==================================================================== //
+ASRCReturnCodes_t ASRC_proc_dither(asrc_ctrl_t* pasrc_ctrl)
+{
+ int* piData;
+ unsigned int uiR;
+ int iDither;
+ __int64_t i64Acc;
+ unsigned int ui;
+
+
+ // Apply dither if required
+ if(pasrc_ctrl->uiDitherOnOff == ASRC_DITHER_ON)
+ {
+ // Get data buffer
+ piData = pasrc_ctrl->piOut;
+ // Get random seed
+ uiR = pasrc_ctrl->psState->uiRndSeed;
+
+ // Loop through samples
+ for(ui = 0; ui < pasrc_ctrl->uiNASRCOutSamples * pasrc_ctrl->uiNchannels; ui += pasrc_ctrl->uiNchannels)
+ {
+ // Compute dither sample (TPDF)
+ iDither = ASRC_DITHER_BIAS;
+
+ uiR = (unsigned int)(ASRC_R_BASE * uiR);
+ uiR = (unsigned int)(ASRC_R_CONS + uiR);
+ iDither += ((uiR>>ASRC_RPDF_BITS_SHIFT) & ASRC_RPDF_MASK);
+
+ uiR = (unsigned int)(ASRC_R_BASE * uiR);
+ uiR = (unsigned int)(ASRC_R_CONS + uiR);
+ iDither += ((uiR>>ASRC_RPDF_BITS_SHIFT) & ASRC_RPDF_MASK);
+
+ //unsigned iACCl = 0;
+ //int iACCh = iDither;
+ //pi_Data[ui] = dither_maths_asm(piData[ui],iACCh, iACCl);
+
+ // Use MACC instruction to saturate and dither + signal
+ i64Acc = ((__int64_t)iDither <<32); // On XMOS this is not necessary, just load dither in the top word of the ACC register
+ MACC(&i64Acc, piData[ui], 0x7FFFFFFF);
+ LSAT30(&i64Acc);
+ // Extract 32bits result
+ EXT30(&piData[ui], i64Acc);
+
+ // Mask to 24bits
+ piData[ui] &= ASRC_DATA24_MASK;
+
+ }
+
+ // Write random seed back
+ pasrc_ctrl->psState->uiRndSeed = uiR;
+ }
+
+ return ASRC_NO_ERROR;
+}
diff --git a/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.h b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.h
new file mode 100644
index 0000000..4783f2f
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc.h
@@ -0,0 +1,298 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// Top level definition file for the ASRC
+//
+// Target: MS Windows
+// Version: 1.0
+//
+// ===========================================================================
+// ===========================================================================
+
+#ifndef _SRC_MRHF_ASRC_H_
+#define _SRC_MRHF_ASRC_H_
+
+ // ===========================================================================
+ //
+ // Includes
+ //
+ // ===========================================================================
+ #include "src_mrhf_fir.h"
+ #include "src_mrhf_filter_defs.h"
+ #include "src.h"
+ #include "src_mrhf_spline_coeff_gen_inner_loop_asm.h"
+ #include "src_mrhf_adfir_inner_loop_asm.h"
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+ // General defines
+ // ---------------
+ #define ASRC_FS_RATIO_UNIT_BIT 28
+ #define ASRC_STACK_LENGTH_MULT (ASRC_N_CHANNELS * 4) // Multiplier for stack length (stack length = this value x the number of input samples to process)
+ #define ASRC_ADFIR_COEFS_LENGTH FILTER_DEFS_ADFIR_PHASE_N_TAPS // Length of AD FIR coefficients buffer
+ #define ASRC_NOMINAL_FS_SCALE (1 << ASRC_FS_RATIO_UNIT_BIT)
+
+
+ // Parameter values
+ // ----------------
+ #define ASRC_DITHER_OFF 0
+ #define ASRC_DITHER_ON 1
+ #define ASRC_DITHER_ON_OFF_MIN ASRC_DITHER_OFF
+ #define ASRC_DITHER_ON_OFF_MAX ASRC_DITHER_ON
+
+
+
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+
+ // ===========================================================================
+ //
+ // TypeDefs
+ //
+ // ===========================================================================
+
+ // To avoid C type definitions when including this file from assembler
+ #ifndef INCLUDE_FROM_ASM
+
+ // ASRC Return Codes
+ // -----------------
+ typedef enum _ASRCReturnCodes
+ {
+ ASRC_NO_ERROR = 0,
+ ASRC_ERROR = 1
+ } ASRCReturnCodes_t;
+
+
+ // Sampling rate codes
+ // -------------------
+ typedef enum _ASRCFs
+ {
+ ASRC_FS_44 = 0, // Fs = 44.1kHz code
+ ASRC_FS_48 = 1, // Fs = 48kHz code
+ ASRC_FS_88 = 2, // Fs = 88.2kHz code
+ ASRC_FS_96 = 3, // Fs = 96kHz code
+ ASRC_FS_176 = 4, // Fs = 176.4kHz code
+ ASRC_FS_192 = 5, // Fs = 192kHz code
+ } ASRCFs_t;
+ #define ASRC_N_FS (ASRC_FS_192 + 1)
+ #define ASRC_FS_MIN ASRC_FS_44
+ #define ASRC_FS_MAX ASRC_FS_192
+
+
+ // ASRC Filters IDs structure
+ // --------------------------
+ #define ASRC_F1_INDEX 0
+ #define ASRC_F2_INDEX 1
+ #define ASRC_N_F (ASRC_F2_INDEX + 1)
+
+ typedef struct _ASRCFiltersIDs
+ {
+ unsigned int uiFID[ASRC_N_F];
+ } ASRCFiltersIDs_t;
+
+ // ASRC time ratio configurations
+ // ------------------------------
+ typedef struct _ASRCFsRatioConfigs
+ {
+ unsigned int uiNominalFsRatio;
+ unsigned int uiNominalFsRatio_lo;
+ unsigned int uiMinFsRatio;
+ unsigned int uiMaxFsRatio;
+ int iFsRatioShift;
+ } ASRCFsRatioConfigs_t;
+
+ // ASRC State structure
+ // --------------------
+ typedef struct _ASRCState
+ {
+ long long pad_to_64b_alignment; //Force compiler to 64b align
+ unsigned int uiRndSeed; // Dither random seeds current values
+ int iDelayFIRLong[2 * FILTER_DEFS_FIR_MAX_TAPS_LONG]; // Doubled length for circular buffer simulation
+ int iDelayFIRShort[2 * FILTER_DEFS_FIR_MAX_TAPS_SHORT]; // Doubled length for circular buffer simulation
+ int iDelayADFIR[2 * FILTER_DEFS_ADFIR_PHASE_N_TAPS]; // Doubled length for circular buffer simulation
+ } asrc_state_t;
+
+
+ // ASRC Control structure
+ // ----------------------
+ typedef struct _ASRCCtrl
+ {
+#ifdef __XC__
+ long long pad_to_64b_alignment; //Force compiler to 64b align
+ unsigned int uiNchannels; // Number of channels in this instance
+ int* unsafe piIn; // Input buffer pointer (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNInSamples; // Number of input samples to process in one call to the processing function
+ unsigned int uiNSyncSamples; // Number of synchronous samples produced in one call to the processing function
+ ASRCFs_t eInFs; // Input sampling rate code
+ int* unsafe piOut; // Output buffer poin ter (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNASRCOutSamples; // Number of output samples produced during last call to the asynchronous processing function
+ ASRCFs_t eOutFs; // Output sampling rate code
+
+ FIRCtrl_t sFIRF1Ctrl; // F1 FIR controller
+ FIRCtrl_t sFIRF2Ctrl; // F2 FIR controller
+ ADFIRCtrl_t sADFIRF3Ctrl; // F3 ADFIR controller
+
+ unsigned int uiFsRatio; // Fs ratio: Fsin / Fsout
+ unsigned int uiFsRatio_lo;
+
+ int iTimeInt; // Integer part of time
+ unsigned int uiTimeFract; // Fractional part of time
+ int iTimeStepInt; // Integer part of time step
+ unsigned int uiTimeStepFract; // Fractional part of time step
+
+ unsigned int uiDitherOnOff; // Dither on/off flag
+ unsigned int uiRndSeedInit; // Dither random seed initial value
+
+ asrc_state_t* unsafe psState; // Pointer to state structure
+ int* unsafe piStack; // Pointer to stack buffer
+ int* unsafe piADCoefs; // Pointer to AD coefficients
+#else
+ long long pad_to_64b_alignment; //Force compiler to 64b align
+ unsigned int uiNchannels; // Number of channels in this instance
+ int* piIn; // Input buffer pointer (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNInSamples; // Number of input samples to process in one call to the processing function
+ unsigned int uiNSyncSamples; // Number of synchronous samples produced in one call to the processing function
+ ASRCFs_t eInFs; // Input sampling rate code
+ int* piOut; // Output buffer poin ter (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNASRCOutSamples; // Number of output samples produced during last call to the asynchronous processing function
+ ASRCFs_t eOutFs; // Output sampling rate code
+
+ FIRCtrl_t sFIRF1Ctrl; // F1 FIR controller
+ FIRCtrl_t sFIRF2Ctrl; // F2 FIR controller
+ ADFIRCtrl_t sADFIRF3Ctrl; // F3 ADFIR controller
+
+ unsigned int uiFsRatio; // Fs ratio: Fsin / Fsout
+ unsigned int uiFsRatio_lo;
+
+ int iTimeInt; // Integer part of time
+ unsigned int uiTimeFract; // Fractional part of time
+ int iTimeStepInt; // Integer part of time step
+ unsigned int uiTimeStepFract; // Fractional part of time step
+
+ unsigned int uiDitherOnOff; // Dither on/off flag
+ unsigned int uiRndSeedInit; // Dither random seed initial value
+
+ asrc_state_t* psState; // Pointer to state structure
+ int* piStack; // Pointer to stack buffer
+ int* piADCoefs; // Pointer to AD coefficients
+#endif
+ } asrc_ctrl_t;
+
+
+ // Adaptive filter coefficients. Note this is a workaround to force the compiler to align the array to 64b boundary (required by inner loop assembler that uses load/store double)
+ // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+
+ typedef struct _asrc_adfir_coefs_t
+ {
+ long long padding_to_64b; //Force 64b alignment
+ int iASRCADFIRCoefs[ASRC_ADFIR_COEFS_LENGTH]; //Adaptive FIR coefficients (one per instance)
+ } asrc_adfir_coefs_t;
+
+
+
+
+
+ // ===========================================================================
+ //
+ // Function prototypes
+ //
+ // ===========================================================================
+
+ // ==================================================================== //
+ // Function: ASRC_prepare_coefs //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Prepares the ASRC coefficients from the prototype //
+ // Needs to be called only once //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_prepare_coefs(void);
+
+ // ==================================================================== //
+ // Function: ASRC_init //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Inits the ASRC passed as argument //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_init(asrc_ctrl_t* pasrc_ctrl);
+
+ // ==================================================================== //
+ // Function: ASRC_sync //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Syncs the ASRC passed as argument //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_sync(asrc_ctrl_t* pasrc_ctrl);
+
+ // ==================================================================== //
+ // Function: ASRC_proc_F1_F2 //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Processes F1 and F2 for a channel //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_proc_F1_F2(asrc_ctrl_t* pasrc_ctrl);
+
+ // ==================================================================== //
+ // Function: ASRC_update_fs_ratio //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Updates the ASRC with the new Fs ratio //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_update_fs_ratio(asrc_ctrl_t* pasrc_ctrl);
+
+ // ==================================================================== //
+ // Function: ASRC_proc_F3_in_spl //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // int iInSample: new input sample //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Writes new input sample to F3 delay line //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_proc_F3_in_spl(asrc_ctrl_t* pasrc_ctrl, int iInSample);
+
+ // ==================================================================== //
+ // Function: ASRC_proc_F3_time //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR if an output sample must be produced //
+ // ASRC_ERROR if no output sample needs to be produced //
+ // Description: Processes F3 time //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_proc_F3_time(asrc_ctrl_t* pasrc_ctrl);
+
+ // ==================================================================== //
+ // Function: ASRC_proc_F3_macc //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // int* piOutSample: Address of output sample //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Processes F3 for a channel //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_proc_F3_macc(asrc_ctrl_t* pasrc_ctrl, int* piOutSample);
+
+ // ==================================================================== //
+ // Function: ASRC_proc_dither //
+ // Arguments: asrc_ctrl_t *pasrc_ctrl: Ctrl strct. //
+ // Return values: ASRC_NO_ERROR on success //
+ // ASRC_ERROR on failure //
+ // Description: Processes dither for a channel //
+ // ==================================================================== //
+ ASRCReturnCodes_t ASRC_proc_dither(asrc_ctrl_t* pasrc_ctrl);
+
+ #endif // nINCLUDE_FROM_ASM
+
+#endif // _SRC_MRHF_ASRC_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_checks.h b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_checks.h
new file mode 100644
index 0000000..1dbe7a4
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_checks.h
@@ -0,0 +1,37 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_MRHF_ASRC_CHECKS_H_
+#define _SRC_MRHF_ASRC_CHECKS_H_
+
+#include "src.h"
+
+//Compile time checks on SRC configuration defines
+#if (ASRC_N_CHANNELS % ASRC_N_INSTANCES != 0)
+#error "Each core must process an integer number of channels. Check ASRC_N_CHANNELS & ASRC_N_INSTANCES."
+#endif
+#if (ASRC_N_CHANNELS < ASRC_N_INSTANCES)
+#error "Each instance (logical core) must process at least one channel. Check ASRC_N_CHANNELS & ASRC_N_INSTANCES."
+#endif
+#if (ASRC_N_INSTANCES < 1)
+#error "Number of instances (logical cores) must be at least 1. Check ASRC_N_INSTANCES."
+#endif
+#if (ASRC_N_CHANNELS < 1)
+#error "Number of audio channels must be at least 1. Check ASRC_N_CHANNELS."
+#endif
+#if (ASRC_N_IN_SAMPLES < 4)
+#error "Number of input audio samples in each block must be at least 4. Check ASRC_N_IN_SAMPLES."
+#endif
+#if ((ASRC_N_IN_SAMPLES & (ASRC_N_IN_SAMPLES - 1)) != 0)
+#error "Number of input audio samples in each block must be a power of two. Check ASRC_N_IN_SAMPLES."
+#endif
+#if (ASRC_N_OUT_IN_RATIO_MAX < 5)
+#warning "SRC buffering configured so that fs out <= 4 * fs in"
+#endif
+#if (ASRC_N_OUT_IN_RATIO_MAX < 3)
+#warning "SRC buffering configured so that fs out <= 2 * fs in"
+#endif
+#if (ASRC_N_OUT_IN_RATIO_MAX < 1)
+#warning "SRC buffering configured so that fs out <= fs in"
+#endif
+
+#endif // _SRC_MRHF_ASRC_CHECKS_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_wrapper.c b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_wrapper.c
new file mode 100644
index 0000000..a01a94a
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/asrc/src_mrhf_asrc_wrapper.c
@@ -0,0 +1,280 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// General includes
+#include
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+
+// ASRC includes
+#include "src.h"
+#include "use_vpu.h"
+
+extern ASRCFsRatioConfigs_t sFsRatioConfigs[ASRC_N_FS][ASRC_N_FS];
+
+#define DO_FS_BOUNDS_CHECK 1 //This is important to prevent pointers going out of bounds when invalid fs_ratios are sent
+
+static void asrc_error(int code)
+{
+ debug_printf("ASRC_proc Error code %d\n", code);
+ delay_milliseconds(1); //Allow xscope to display message before quit
+ _Exit(code);
+}
+
+
+uint64_t asrc_init(const fs_code_t sr_in, const fs_code_t sr_out, asrc_ctrl_t asrc_ctrl[], const unsigned n_channels_per_instance,
+ const unsigned n_in_samples, const dither_flag_t dither_on_off)
+{
+ unsigned ui;
+
+ ASRCReturnCodes_t ret_code;
+
+ ret_code = ASRC_prepare_coefs();
+
+ if (ret_code != ASRC_NO_ERROR) asrc_error(10);
+
+ //Check to see if n_channels_per_instance, n_in_samples are reasonable
+ if ((n_in_samples & 0x1) || (n_in_samples < 4)) asrc_error(100);
+ if (n_channels_per_instance < 1) asrc_error(101);
+
+ for(ui = 0; ui < n_channels_per_instance; ui++)
+ {
+ // Set number of channels per instance
+ asrc_ctrl[ui].uiNchannels = n_channels_per_instance;
+
+ // Set input/output sampling rate codes
+ asrc_ctrl[ui].eInFs = (int)sr_in;
+ asrc_ctrl[ui].eOutFs = (int)sr_out;
+
+ // Set number of samples
+ asrc_ctrl[ui].uiNInSamples = n_in_samples;
+
+ // Set dither flag and random seeds
+ asrc_ctrl[ui].uiDitherOnOff = dither_on_off;
+ asrc_ctrl[ui].uiRndSeedInit = 12345 * ui; //Some randomish numbers. Value not critical
+
+ // Init ASRC instances
+ ret_code = ASRC_init(&asrc_ctrl[ui]);
+
+ if (ret_code != ASRC_NO_ERROR) asrc_error(11);
+ }
+
+ // Sync
+ // ----
+ // Sync ASRC. This is just to show that the function works and returns success
+
+ for(ui = 0; ui < n_channels_per_instance; ui++) {
+ ret_code = ASRC_sync(&asrc_ctrl[ui]);
+ if (ret_code != ASRC_NO_ERROR) asrc_error(12);
+ }
+
+ return (uint64_t)((((uint64_t)asrc_ctrl[0].uiFsRatio) << 32) | asrc_ctrl[0].uiFsRatio_lo);
+}
+
+unsigned asrc_process(int *in_buff, int *out_buff, uint64_t fs_ratio, asrc_ctrl_t asrc_ctrl[]){
+
+ int ui, uj; //General counters
+ int uiSplCntr; //Spline counter
+
+ // Get the number of channels per instance from first channel
+ const unsigned n_channels_per_instance = asrc_ctrl[0].uiNchannels;
+
+ uint32_t fs_ratio_hi = (uint32_t)(fs_ratio >> 32);
+ uint32_t fs_ratio_lo = (uint32_t)(fs_ratio);
+
+ for(ui = 0; ui < n_channels_per_instance; ui++)
+ {
+ // Update Fs Ratio
+ asrc_ctrl[ui].uiFsRatio = fs_ratio_hi;
+ asrc_ctrl[ui].uiFsRatio_lo = fs_ratio_lo;
+
+#if DO_FS_BOUNDS_CHECK
+ // Check for bounds of new Fs ratio
+ if( (fs_ratio_hi < sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].uiMinFsRatio) ||
+ (fs_ratio_hi > sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].uiMaxFsRatio) )
+ {
+ //debug_printf("Passed = %x, Nominal = 0x%x\n", fs_ratio_hi, sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].uiNominalFsRatio);
+ fs_ratio_hi = sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].uiNominalFsRatio; //Important to prevent buffer overflow if fs_ratio requests too many samples.
+ fs_ratio_lo = sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].uiNominalFsRatio_lo;
+ //debug_printf("!");
+ }
+#endif
+ // Apply shift to time ratio to build integer and fractional parts of time step
+ asrc_ctrl[ui].iTimeStepInt = fs_ratio_hi >> (sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].iFsRatioShift);
+ asrc_ctrl[ui].uiTimeStepFract = fs_ratio_hi << (32 - sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].iFsRatioShift);
+ asrc_ctrl[ui].uiTimeStepFract |= (uint32_t)(fs_ratio_lo >> sFsRatioConfigs[asrc_ctrl[ui].eInFs][asrc_ctrl[ui].eOutFs].iFsRatioShift);
+
+
+
+
+ // Set input and output data pointers
+ asrc_ctrl[ui].piIn = in_buff + ui;
+ asrc_ctrl[ui].piOut = out_buff + ui;
+
+
+ // Process synchronous part (F1 + F2)
+ // ==================================
+
+ // Note: this is block based similar to SSRC, output will be on stack
+ // and there will be asrc_ctrl[chan_start].uiNSyncSamples samples per channel produced
+ if(ASRC_proc_F1_F2(&asrc_ctrl[ui]) != ASRC_NO_ERROR)
+ {
+ asrc_error(12);
+ }
+
+
+
+ // Run the asynchronous part (F3)
+ // ==============================
+ // Clear number of output samples (note that this sample counter would actually not be needed if all was sample by sampe)
+
+ asrc_ctrl[ui].uiNASRCOutSamples = 0;
+ }
+
+ uiSplCntr = 0; // This is actually only used because of the bizarre mix of block and sample based processing
+
+ // Driven by samples produced during the synchronous phase
+ for(ui = 0; ui < asrc_ctrl[0].uiNSyncSamples; ui++)
+ {
+ // Push new samples into F3 delay line (input from stack) for each new "synchronous" sample (i.e. output of F1, respectively F2)
+ for(uj = 0; uj < n_channels_per_instance; uj++)
+ {
+
+ //The following is replicated/inlined code from ASRC_proc_F3_in_spl in ASRC.c
+ asrc_ctrl[uj].sADFIRF3Ctrl.iIn = asrc_ctrl[uj].piStack[ui];
+
+ //The following is replicated/inlined code from ADFIR_proc_in_spl in FIR.c
+ // Double write to simulate circular buffer
+ *asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI = asrc_ctrl[uj].sADFIRF3Ctrl.iIn;
+ *(asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI + asrc_ctrl[uj].sADFIRF3Ctrl.uiDelayO) = asrc_ctrl[uj].sADFIRF3Ctrl.iIn;
+ // Step delay (with circular simulation)
+ asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI++;
+ if(asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI >= asrc_ctrl[uj].sADFIRF3Ctrl.piDelayW)
+ asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI =asrc_ctrl[uj].sADFIRF3Ctrl.piDelayB;
+
+ // Decrease next output time (this is an integer value, so no influence on fractional part)
+ asrc_ctrl[uj].iTimeInt -= FILTER_DEFS_ADFIR_N_PHASES;
+
+
+ }
+ // Run macc loop for F3
+ // Check if a new output sample needs to be produced
+ // Note that this will also update the adaptive filter coefficients
+ // These must be computed for one channel only and reused in the macc loop of other channels
+ while(asrc_ctrl[0].iTimeInt < FILTER_DEFS_ADFIR_N_PHASES)
+ {
+ unsigned int uiTemp;
+ int iAlpha;
+
+ int iH[3]; //iH0, iH1, iH2;
+ long long i64Acc0;
+ int* piPhase0;
+ int* piADCoefs;
+
+ // Compute adative coefficients spline factors
+ // The fractional part of time gives alpha
+ iAlpha = asrc_ctrl[0].uiTimeFract>>1; // Now alpha can be seen as a signed number
+ i64Acc0 = (long long)iAlpha * (long long)iAlpha;
+
+#if SRC_USE_VPU
+ iH[2] = (int)(i64Acc0>>32);
+ iH[0] = 0x40000000; // Load H2 with 0.5;
+ iH[1] = iH[0] - iH[2]; // H1 = 0.5 - 0.5 * alpha * alpha;
+ iH[1] = iH[1] - iH[2]; // H1 = 0.5 - alpha * alpha
+ iH[1] = iH[1] + iAlpha; // H1 = 0.5 + alpha - alpha * alpha;
+ iH[0] = iH[0] - iAlpha; // H2 = 0.5 - alpha
+ iH[0] = iH[0] + iH[2]; // H2 = 0.5 - alpha + 0.5 * alpha * alpha
+
+ // The integer part of time gives the phase
+ piPhase0 = &iADFirCoefs[0][asrc_ctrl[0].iTimeInt];
+ // These are calculated by the asm funcion piPhase1 = piPhase0 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+ // piPhase2 = piPhase1 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+ piADCoefs = asrc_ctrl[0].piADCoefs; // Given limited number of registers, this could be DP
+ // Apply spline coefficients to filter coefficients
+ src_mrhf_spline_coeff_gen_inner_loop_asm_xs3(piPhase0, iH, piADCoefs, FILTER_DEFS_ADFIR_PHASE_N_TAPS);
+#else
+ iH[0] = (int)(i64Acc0>>32);
+ iH[2] = 0x40000000; // Load H2 with 0.5;
+ iH[1] = iH[2] - iH[0]; // H1 = 0.5 - 0.5 * alpha * alpha;
+ iH[1] = iH[1] - iH[0]; // H1 = 0.5 - alpha * alpha
+ iH[1] = iH[1] + iAlpha; // H1 = 0.5 + alpha - alpha * alpha;
+ iH[2] = iH[2] - iAlpha; // H2 = 0.5 - alpha
+ iH[2] = iH[2] + iH[0]; // H2 = 0.5 - alpha + 0.5 * alpha * alpha
+
+ // The integer part of time gives the phase
+ piPhase0 = iADFirCoefs[asrc_ctrl[0].iTimeInt];
+ // These are calculated by the asm funcion piPhase1 = piPhase0 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+ // piPhase2 = piPhase1 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+ piADCoefs = asrc_ctrl[0].piADCoefs; // Given limited number of registers, this could be DP
+
+ // Apply spline coefficients to filter coefficients
+ src_mrhf_spline_coeff_gen_inner_loop_asm(piPhase0, iH, piADCoefs, FILTER_DEFS_ADFIR_PHASE_N_TAPS);
+
+#endif
+
+ // Step time for next output sample
+ // --------------------------------
+ // Step to next output time (add integer and fractional parts)
+ asrc_ctrl[0].iTimeInt += asrc_ctrl[0].iTimeStepInt;
+ // For fractional part, this can be optimized using the add with carry instruction of XS2
+ uiTemp = asrc_ctrl[0].uiTimeFract;
+ asrc_ctrl[0].uiTimeFract += asrc_ctrl[0].uiTimeStepFract;
+ if(asrc_ctrl[0].uiTimeFract < uiTemp)
+ asrc_ctrl[0].iTimeInt++;
+
+
+ // Not really needed, just for the beauty of it...
+ //asrc_ctrl[0+1].iTimeInt = asrc_ctrl[0].iTimeInt;
+ //asrc_ctrl[0+1].uiTimeFract = asrc_ctrl[0].uiTimeFract;
+
+ // Apply filter F3 with just computed adaptive coefficients
+ for(uj = 0; uj < n_channels_per_instance; uj++) {
+
+ //The following is replicated/inlined code from ADFIR_F3_proc_macc in ASRC.c
+ asrc_ctrl[uj].sADFIRF3Ctrl.piOut = (asrc_ctrl[uj].piOut + n_channels_per_instance * uiSplCntr);
+
+ //The following is replicated/inlined code from ADFIR_proc_macc in FIR.c
+ int* piData;
+ int* piCoefs;
+ int iData;
+ // Clear accumulator and set access pointers
+ piData = asrc_ctrl[uj].sADFIRF3Ctrl.piDelayI;
+ piCoefs = asrc_ctrl[uj].sADFIRF3Ctrl.piADCoefs;
+
+ // Do FIR
+#if SRC_USE_VPU
+ src_mrhf_adfir_inner_loop_asm_xs3(piData, piCoefs, &iData, asrc_ctrl[uj].sADFIRF3Ctrl.uiNLoops);
+#else
+ if ((unsigned)piData & 0b0100) src_mrhf_adfir_inner_loop_asm_odd(piData, piCoefs, &iData, asrc_ctrl[uj].sADFIRF3Ctrl.uiNLoops);
+ else src_mrhf_adfir_inner_loop_asm(piData, piCoefs, &iData, asrc_ctrl[uj].sADFIRF3Ctrl.uiNLoops);
+#endif
+
+ // Write output
+ *(asrc_ctrl[uj].sADFIRF3Ctrl.piOut) = iData;
+ asrc_ctrl[uj].uiNASRCOutSamples++;
+ }
+ uiSplCntr++; // This is actually only used because of the bizarre mix of block and sample based processing
+ }
+ }
+
+
+#if (ASRC_DITHER_SETTING != ASRC_DITHER_OFF) //Removed for speed optimisation
+ // Process dither part
+ // ===================
+ // We are back to block based processing. This is where the number of ASRC output samples is required again
+ // (would not be used if sample by sample based (on output samples))
+ for(ui = 0; ui < n_channels_per_instance; ui++)
+ {
+ // Note: this is block based similar to SSRC
+ if(ASRC_proc_dither(&asrc_ctrl[ui]) != ASRC_NO_ERROR)
+ {
+ asrc_error(4);
+ }
+ }
+#endif
+
+ unsigned n_samps_out = asrc_ctrl[0].uiNASRCOutSamples;
+ return n_samps_out;
+}
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.S
new file mode 100644
index 0000000..4eae24e
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.S
@@ -0,0 +1,253 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_adfir_inner_loop_asm.function
+ .globl src_mrhf_adfir_inner_loop_asm
+ .align 8
+ .type src_mrhf_adfir_inner_loop_asm,@function
+
+src_mrhf_adfir_inner_loop_asm:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 8
+ {stw iDataRet_p, sp[6]; shr counter, counter, 3}
+
+ //Constant for adding onto stuff. Gets updated later
+ ldc step, 0x40
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+
+ bf counter, src_mrhf_adfir_done
+src_mrhf_adfir_main_loop:
+ sub counter, counter, 1
+
+ ldd iData0, iData1, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[1]
+ ldd iCoef0, iCoef1, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[2]
+ ldd iCoef0, iCoef1, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[3]
+ ldd iCoef0, iCoef1, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[4]
+ ldd iCoef0, iCoef1, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[5]
+ ldd iCoef0, iCoef1, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[6]
+ ldd iCoef0, iCoef1, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[7]
+ ldd iCoef0, iCoef1, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ //Decrement loop counter and increment pointers and branch if still running
+ {add piData_p, piData_p, step; add piCoefs_p, piCoefs_p, step}
+
+ bt counter, src_mrhf_adfir_main_loop
+
+src_mrhf_adfir_done:
+ //pop return value pointer from stack so we can use it to write back
+ //Write back the two return values
+ {ldw iDataRet_p, sp[6]; ldc counter, 30} //Reuse counter (r3)
+
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp:
+ .size src_mrhf_adfir_inner_loop_asm, .atmp-src_mrhf_adfir_inner_loop_asm
+ .align 8
+ .cc_bottom src_mrhf_adfir_inner_loop_asm.function
+
+ .set src_mrhf_adfir_inner_loop_asm.nstackwords, stack_size
+ .globl src_mrhf_adfir_inner_loop_asm.nstackwords
+ .set src_mrhf_adfir_inner_loop_asm.maxcores, 1
+ .globl src_mrhf_adfir_inner_loop_asm.maxcores
+ .set src_mrhf_adfir_inner_loop_asm.maxtimers,0
+ .globl src_mrhf_adfir_inner_loop_asm.maxtimers
+ .set src_mrhf_adfir_inner_loop_asm.maxchanends,0
+ .globl src_mrhf_adfir_inner_loop_asm.maxchanends
+
+
+// Odd data alignment (4byte odd instead of 8byte) version
+
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_adfir_inner_loop_asm_odd.function
+ .globl src_mrhf_adfir_inner_loop_asm_odd
+ .align 8
+ .type src_mrhf_adfir_inner_loop_asm_odd,@function
+
+src_mrhf_adfir_inner_loop_asm_odd:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 8
+ {stw iDataRet_p, sp[6]; shr counter, counter, 3}
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+ bf counter, src_mrhf_adfir_done_odd
+src_mrhf_adfir_main_loop_odd:
+
+ {sub counter, counter, 1; ldc step, 0x38}
+
+ //Constant for adding onto stuff. Gets updated later
+
+ {ldw iData0, piData_p[0]; add piData_p, piData_p, 4} //Now 64b aligned
+
+ ldd iCoef1, iCoef0, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[0]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[1]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[2]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[3]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[4]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[5]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[6]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+
+ add piData_p, piData_p, step
+
+ {ldw iData1, piData_p[0]; add piData_p, piData_p, 4} //0x4 + 0x38 + 0x4 = 0x40)
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+ //Increment pointers and branch if still running
+
+ ldc step, 0x40
+ {bt counter, src_mrhf_adfir_main_loop_odd; add piCoefs_p, piCoefs_p, step}
+
+src_mrhf_adfir_done_odd:
+ //pop return value pointer from stack so we can use it to write back
+ {ldw iDataRet_p, sp[6]; ldc counter, 30} //Reuse counter (r3)
+
+ //Write back the return value
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp_odd:
+ .size src_mrhf_adfir_inner_loop_asm_odd, .atmp_odd-src_mrhf_adfir_inner_loop_asm_odd
+ .align 8
+ .cc_bottom src_mrhf_adfir_inner_loop_asm_odd.function
+
+ .set src_mrhf_adfir_inner_loop_asm_odd.nstackwords, stack_size
+ .globl src_mrhf_adfir_inner_loop_asm_odd.nstackwords
+ .set src_mrhf_adfir_inner_loop_asm_odd.maxcores, 1
+ .globl src_mrhf_adfir_inner_loop_asm_odd.maxcores
+ .set src_mrhf_adfir_inner_loop_asm_odd.maxtimers,0
+ .globl src_mrhf_adfir_inner_loop_asm_odd.maxtimers
+ .set src_mrhf_adfir_inner_loop_asm_odd.maxchanends,0
+ .globl src_mrhf_adfir_inner_loop_asm_odd.maxchanends
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.h
new file mode 100644
index 0000000..3c5e311
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm.h
@@ -0,0 +1,10 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_
+#define _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_
+
+void src_mrhf_adfir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_adfir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_adfir_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count);
+
+#endif // _SRC_MRHF_ADFIR_INNER_LOOP_ASM_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm_xs3.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm_xs3.S
new file mode 100644
index 0000000..6f57ca7
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_adfir_inner_loop_asm_xs3.S
@@ -0,0 +1,241 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#if defined(__XS3A__)
+ .text
+
+#define NSTACKWORDS 8
+ .issue_mode dual
+
+ .align 16
+
+ .cc_top src_mrhf_adfir_inner_loop_asm_xs3.function
+ .globl src_mrhf_adfir_inner_loop_asm_xs3
+ .type src_mrhf_adfir_inner_loop_asm_xs3,@function
+
+src_mrhf_adfir_inner_loop_asm_xs3:
+ { DUALENTSP_u6 NSTACKWORDS ; ldc r11, 0 }
+ { vsetc r11 ; shr r3, r3, 3}
+ { ldc r11, 0x20 ; vclrdr }
+ { bf r3, src_mrhf_adfir_done2 ; sub r3, r3, 1 }
+
+src_mrhf_adfir_main_loop2:
+ { vldc r0[0] ; add r0, r0, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+ { vldc r0[0] ; add r0, r0, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+ { bt r3, src_mrhf_adfir_main_loop2 ; sub r3, r3, 1 }
+
+src_mrhf_adfir_done2:
+ ldap r11, shifts1
+ { vlsat r11[0] ; ldaw r0, sp[0] }
+ vstr r0[0]
+ { vldc r0[0] ; ldap r11, twos }
+ vclrdr
+ { vlmaccr r11[0] ; ldap r11, shifts0 }
+ { vlsat r11[0] ; mkmsk r0, 4 }
+ vstrpv r2[0], r0
+
+ retsp NSTACKWORDS
+
+.atmp:
+ .size src_mrhf_adfir_inner_loop_asm_xs3, .atmp-src_mrhf_adfir_inner_loop_asm_xs3
+
+ .set src_mrhf_adfir_inner_loop_asm_xs3.nstackwords, NSTACKWORDS
+ .globl src_mrhf_adfir_inner_loop_asm_xs3.nstackwords
+ .set src_mrhf_adfir_inner_loop_asm_xs3.maxcores, 1
+ .globl src_mrhf_adfir_inner_loop_asm_xs3.maxcores
+ .set src_mrhf_adfir_inner_loop_asm_xs3.maxtimers,0
+ .globl src_mrhf_adfir_inner_loop_asm_xs3.maxtimers
+ .set src_mrhf_adfir_inner_loop_asm_xs3.maxchanends,0
+ .globl src_mrhf_adfir_inner_loop_asm_xs3.maxchanends
+
+ .globl src_mrhf_fir_inner_loop_asm_xs3
+ .type src_mrhf_fir_inner_loop_asm_xs3,@function
+
+#undef NSTACKWORDS
+#define NSTACKWORDS 8
+
+
+twos:
+ .word 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff
+ .word 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff
+shifts0:
+ .word 0, 0, 0, 0, 0, 0, 0, 0
+shifts1:
+ .word 1, 1, 1, 1, 1, 1, 1, 1
+shifts2:
+ .word 2, 2, 2, 2, 2, 2, 2, 2
+
+ .align 16
+
+src_mrhf_fir_inner_loop_asm_xs3:
+ { DUALENTSP_u6 NSTACKWORDS ; ldc r11, 0 }
+ { vsetc r11 ; shr r3, r3, 3}
+ { ldc r11, 0x20 ; vclrdr }
+ { bf r3, src_mrhf_fir_done2 ; sub r3, r3, 1 }
+
+src_mrhf_fir_main_loop2:
+ { vldc r0[0] ; add r0, r0, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+ { vldc r0[0] ; add r0, r0, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+ { bt r3, src_mrhf_fir_main_loop2 ; sub r3, r3, 1 }
+
+src_mrhf_fir_done2:
+ ldap r11, shifts2
+ { vlsat r11[0] ; ldaw r0, sp[0] }
+ vstr r0[0]
+ { vldc r0[0] ; ldap r11, twos }
+ vclrdr
+ { vlmaccr r11[0] ; ldap r11, shifts0 }
+ { vlsat r11[0] ; mkmsk r0, 4 }
+ vstrpv r2[0], r0
+
+ retsp NSTACKWORDS
+
+.btmp:
+ .size src_mrhf_fir_inner_loop_asm_xs3, .btmp-src_mrhf_fir_inner_loop_asm_xs3
+
+ .set src_mrhf_fir_inner_loop_asm_xs3.nstackwords, NSTACKWORDS
+ .globl src_mrhf_fir_inner_loop_asm_xs3.nstackwords
+ .set src_mrhf_fir_inner_loop_asm_xs3.maxcores, 1
+ .globl src_mrhf_fir_inner_loop_asm_xs3.maxcores
+ .set src_mrhf_fir_inner_loop_asm_xs3.maxtimers,0
+ .globl src_mrhf_fir_inner_loop_asm_xs3.maxtimers
+ .set src_mrhf_fir_inner_loop_asm_xs3.maxchanends,0
+ .globl src_mrhf_fir_inner_loop_asm_xs3.maxchanends
+
+ .globl src_mrhf_fir_os_inner_loop_asm_xs3
+ .type src_mrhf_fir_os_inner_loop_asm_xs3,@function
+
+#undef NSTACKWORDS
+#define NSTACKWORDS 8
+
+evens:
+ .word 0x7fffffff
+odds:
+ .word 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff, 0, 0x7fffffff
+
+ .align 16
+src_mrhf_fir_os_inner_loop_asm_xs3:
+
+ { DUALENTSP_u6 NSTACKWORDS ; ldc r11, 0x0 }
+ { vsetc r11 ; shr r3, r3, 2 }
+ { ldc r11, 0x20 ; vclrdr }
+ { bf r3, src_mrhf_fir_os_done2 ; sub r3, r3, 1 }
+
+src_mrhf_fir_os_main_loop2:
+
+ { vldc r0[0] ; add r0, r0, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+ { vlmaccr r1[0] ; add r1, r1, r11 }
+
+ //Decrement loop r3
+ { bt r3, src_mrhf_fir_os_main_loop2 ; sub r3, r3, 1 }
+
+src_mrhf_fir_os_done2:
+ ldap r11, shifts2
+ { vlsat r11[0] ; ldaw r0, sp[0] }
+ vstr r0[0]
+ { vldc r0[0] ; ldap r11, evens }
+ vclrdr
+ { vlmaccr r11[0] ; add r11, r11, 4 }
+ { vlmaccr r11[0] ; ldap r11, shifts0 }
+ { vlsat r11[0] ; mkmsk r0, 8 }
+ vstrpv r2[0], r0
+
+ //Pop registers
+ retsp NSTACKWORDS
+
+.ctmp:
+ .size src_mrhf_fir_os_inner_loop_asm_xs3, .ctmp-src_mrhf_fir_os_inner_loop_asm_xs3
+
+ .set src_mrhf_fir_os_inner_loop_asm_xs3.nstackwords, NSTACKWORDS
+ .globl src_mrhf_fir_os_inner_loop_asm_xs3.nstackwords
+ .set src_mrhf_fir_os_inner_loop_asm_xs3.maxcores, 1
+ .globl src_mrhf_fir_os_inner_loop_asm_xs3.maxcores
+ .set src_mrhf_fir_os_inner_loop_asm_xs3.maxtimers,0
+ .globl src_mrhf_fir_os_inner_loop_asm_xs3.maxtimers
+ .set src_mrhf_fir_os_inner_loop_asm_xs3.maxchanends,0
+ .globl src_mrhf_fir_os_inner_loop_asm_xs3.maxchanends
+
+#define FILTER_DEFS_ADFIR_N_PHASES 128
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm_xs3
+ .align 16
+ .type src_mrhf_spline_coeff_gen_inner_loop_asm_xs3,@function
+
+#undef NSTACKWORDS
+#define NSTACKWORDS 8
+
+src_mrhf_spline_coeff_gen_inner_loop_asm_xs3:
+ DUALENTSP_lu6 NSTACKWORDS
+
+ ldc r3, (FILTER_DEFS_ADFIR_N_PHASES + 2)<< 2
+ // p0, p1, p2, p3, ..., p15
+ // p0+N, p1+N, p2+N, ....,p15+N
+ // p0+2N, p1+2N, p2+2N, ....,p15+2N
+ // p0+3N, p1+3N, p2+3N, ....,p15+3N
+ // ...
+ // p0+257N, p1+257N, p2+257N, ....,p15+257N
+
+ // ****
+ // p0, p0+N, p0+2N, ...., p0+257N
+ // p1, p1+N, p1+2N, ...., p1+257N
+ // ...
+
+// a0 = p[0] * H[2] + p[0+N] * H[1] * p[0+2N] * H[0]
+// a1 = p[1] * H[2] + p[1+N] * H[1] * p[1+2N] * H[0]
+// a2 = p[2] * H[2] + p[2+N] * H[1] * p[2+2N] * H[0]
+// a3 = p[3] * H[2] + p[3+N] * H[1] * p[3+2N] * H[0]
+
+ // Ensure that H is padded with five zeroes.
+ // There may be a faster way to achieve this with VLMUL
+
+ { vldd r1[0] ; ldaw r1, sp[0] }
+ { vstd r1[0] ; ldc r11, 0 }
+ vsetc r11
+ stw r11, sp[3]
+ std r11, r11, sp[2]
+ std r11, r11, sp[3]
+src_mrhf_spline_coeff_gen_main_loop2:
+ { vclrdr ; ldap r11, shifts2 }
+ vldc r1[0]
+
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ vlsat r11[0]
+ vstr r2[0]
+ ldaw r2, r2[8]
+ vclrdr
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ { vlmaccr r0[0] ; add r0, r0, r3 }
+ vlsat r11[0]
+ vstr r2[0]
+src_mrhf_spline_coeff_gen_done2:
+ retsp NSTACKWORDS
+
+.dtmp:
+ .size src_mrhf_spline_coeff_gen_inner_loop_asm_xs3, .dtmp-src_mrhf_spline_coeff_gen_inner_loop_asm_xs3
+ .cc_bottom src_mrhf_adfir_inner_loop_asm_xs3.function
+
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.nstackwords, NSTACKWORDS
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.nstackwords
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxcores, 1
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxcores
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxtimers,0
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxtimers
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxchanends,0
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm_xs3.maxchanends
+#endif
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_dither_maths_asm.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_dither_maths_asm.S
new file mode 100644
index 0000000..9f88f2a
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_dither_maths_asm.S
@@ -0,0 +1,73 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top dither_maths_asm.function
+ .globl dither_maths_asm
+ .align 8
+ .type dither_maths_asm,@function
+
+dither_maths_asm:
+
+#define piData r0
+#define ACCh r1
+#define ACCl r2
+
+
+//In 32b words
+#define stack_size 0
+
+#if 0
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 8
+ {stw iDataRet_p, sp[6]; shr counter, counter, 3}
+
+ //Constant for adding onto stuff. Gets updated later
+ ldc step, 0x40
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+ ldd iData0, iData1, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ //pop return value pointer from stack so we can use it to write back
+ //Write back the two return values
+ {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3)
+
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+#endif
+.atmp:
+ .size dither_maths_asm, .atmp-dither_maths_asm
+ .align 8
+ .cc_bottom dither_maths_asm.function
+
+ .set dither_maths_asm.nstackwords, stack_size
+ .globl dither_maths_asm.nstackwords
+ .set dither_maths_asm.maxcores, 1
+ .globl dither_maths_asm.maxcores
+ .set dither_maths_asm.maxtimers,0
+ .globl dither_maths_asm.maxtimers
+ .set dither_maths_asm.maxchanends,0
+ .globl dither_maths_asm.maxchanends
+
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.c b/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.c
new file mode 100644
index 0000000..b77d50b
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.c
@@ -0,0 +1,167 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// Filters Definitions implementation file for the SRC
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+// FIR and FilterDefs includes
+#include "src_mrhf_fir.h"
+#include "src_mrhf_filter_defs.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+// SSRC FIR filters descriptors (ordered by ID)
+FIRDescriptor_t sSSRCFirDescriptor[FILTER_DEFS_SSRC_N_FIR_ID] =
+{
+ {FIR_TYPE_DS2, FILTER_DEFS_FIR_BL_N_TAPS, iFirBLCoefs}, // FILTER_DEFS_FIR_BL_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL9644_N_TAPS, iFirBL9644Coefs}, // FILTER_DEFS_FIR_BL9644_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL8848_N_TAPS, iFirBL8848}, // FILTER_DEFS_FIR_BL8848_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL19288_N_TAPS, iFirBL19288Coefs}, // FILTER_DEFS_FIR_BL19288_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL17696_N_TAPS, iFirBL17696}, // FILTER_DEFS_FIR_BL17696_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP_N_TAPS, iFirUPCoefs}, // FILTER_DEFS_FIR_UP_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP4844_N_TAPS, iFirUP4844Coefs}, // FILTER_DEFS_FIR_UP4844_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UPF_N_TAPS, iFirUPFCoefs}, // FILTER_DEFS_FIR_UPF_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP192176_N_TAPS, iFirUP192176Coefs}, // FILTER_DEFS_FIR_UP192176_ID
+ {FIR_TYPE_DS2, FILTER_DEFS_FIR_DS_N_TAPS, iFirDSCoefs}, // FILTER_DEFS_FIR_DS_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_OS_N_TAPS, iFirOSCoefs}, // FILTER_DEFS_FIR_OS_ID
+ {FIR_TYPE_SYNC, 0, 0} // FILTER_DEFS_FIR_NONE_ID
+};
+// ASRC FIR filters descriptors (ordered by ID)
+FIRDescriptor_t sASRCFirDescriptor[FILTER_DEFS_ASRC_N_FIR_ID] =
+{
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL_N_TAPS, iFirBLCoefs}, // FILTER_DEFS_FIR_BL_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL9644_N_TAPS, iFirBL9644Coefs}, // FILTER_DEFS_FIR_BL9644_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL8848_N_TAPS, iFirBL8848}, // FILTER_DEFS_FIR_BL8848_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BLF_N_TAPS, iFirBLFCoefs}, // FILTER_DEFS_FIR_BLF_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL19288_N_TAPS, iFirBL19288Coefs}, // FILTER_DEFS_FIR_BL19288_ID
+ {FIR_TYPE_SYNC, FILTER_DEFS_FIR_BL17696_N_TAPS, iFirBL17696}, // FILTER_DEFS_FIR_BL17696_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP_N_TAPS, iFirUPCoefs}, // FILTER_DEFS_FIR_UP_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP4844_N_TAPS, iFirUP4844Coefs}, // FILTER_DEFS_FIR_UP4844_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UPF_N_TAPS, iFirUPFCoefs}, // FILTER_DEFS_FIR_UPF_ID
+ {FIR_TYPE_OS2, FILTER_DEFS_FIR_UP192176_N_TAPS, iFirUP192176Coefs}, // FILTER_DEFS_FIR_UP192176_ID
+ {FIR_TYPE_DS2, FILTER_DEFS_FIR_DS_N_TAPS, iFirDSCoefs}, // FILTER_DEFS_FIR_DS_ID
+ {FIR_TYPE_SYNC, 0, 0} // FILTER_DEFS_FIR_NONE_ID
+};
+
+// FIR filters coefficients
+int iFirBLCoefs[FILTER_DEFS_FIR_BL_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BL_FILE
+};
+int iFirBL9644Coefs[FILTER_DEFS_FIR_BL9644_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BL9644_FILE
+};
+int iFirBL8848[FILTER_DEFS_FIR_BL8848_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BL8848_FILE
+};
+int iFirBLFCoefs[FILTER_DEFS_FIR_BLF_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BLF_FILE
+};
+int iFirBL19288Coefs[FILTER_DEFS_FIR_BL19288_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BL19288_FILE
+};
+int iFirBL17696[FILTER_DEFS_FIR_BL17696_N_TAPS] = {
+ #include FILTER_DEFS_FIR_BL17696_FILE
+};
+int iFirUPCoefs[FILTER_DEFS_FIR_UP_N_TAPS] = {
+ #include FILTER_DEFS_FIR_UP_FILE
+};
+int iFirUP4844Coefs[FILTER_DEFS_FIR_UP4844_N_TAPS] = {
+ #include FILTER_DEFS_FIR_UP4844_FILE
+};
+int iFirUPFCoefs[FILTER_DEFS_FIR_UPF_N_TAPS] = {
+ #include FILTER_DEFS_FIR_UPF_FILE
+};
+int iFirUP192176Coefs[FILTER_DEFS_FIR_UP192176_N_TAPS] = {
+ #include FILTER_DEFS_FIR_UP192176_FILE
+};
+int iFirDSCoefs[FILTER_DEFS_FIR_DS_N_TAPS] = {
+ #include FILTER_DEFS_FIR_DS_FILE
+};
+int iFirOSCoefs[FILTER_DEFS_FIR_OS_N_TAPS] = {
+ #include FILTER_DEFS_FIR_OS_FILE
+};
+
+
+
+// ADFIR filters descriptor
+ADFIRDescriptor_t sADFirDescriptor =
+{
+ FILTER_DEFS_ADFIR_PHASE_N_TAPS, FILTER_DEFS_ADFIR_N_PHASES + 2, (int *)iADFirCoefs
+};
+
+// ADFIR filter coefficients
+int iADFirPrototypeCoefs[FILTER_DEFS_ADFIR_PROTOTYPE_N_TAPS] = {
+ #include FILTER_DEFS_ADFIR_PROTOTYPE_FILE
+};
+#if SRC_USE_VPU
+int iADFirCoefs[FILTER_DEFS_ADFIR_PHASE_N_TAPS][FILTER_DEFS_ADFIR_N_PHASES + 2];
+#else
+int iADFirCoefs[FILTER_DEFS_ADFIR_N_PHASES + 2][FILTER_DEFS_ADFIR_PHASE_N_TAPS];
+#endif
+
+// PPFIR filters descriptors (ordered by ID)
+PPFIRDescriptor_t sPPFirDescriptor[FILTER_DEFS_N_PPFIR_ID] =
+{
+ {FILTER_DEFS_PPFIR_HS294_N_TAPS, FILTER_DEFS_PPFIR_HS294_N_PHASES, iPPFirHS294Coefs}, // FILTER_DEFS_PPFIR_HS294_ID
+ {FILTER_DEFS_PPFIR_HS320_N_TAPS, FILTER_DEFS_PPFIR_HS320_N_PHASES, iPPFirHS320Coefs}, // FILTER_DEFS_PPFIR_HS320_ID
+ {0, 0, 0} // FILTER_DEFS_PPFIR_NONE_ID
+};
+
+// PPFIR filters coefficients
+int iPPFirHS294Coefs[FILTER_DEFS_PPFIR_HS294_N_TAPS] = {
+ #include FILTER_DEFS_PPFIR_HS294_FILE
+};
+int iPPFirHS320Coefs[FILTER_DEFS_PPFIR_HS320_N_TAPS] = {
+ #include FILTER_DEFS_PPFIR_HS320_FILE
+};
+
+
+
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+
+
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.h
new file mode 100644
index 0000000..b3083c0
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_filter_defs.h
@@ -0,0 +1,185 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// Filters Definitions definition file for the SRC
+//
+// ===========================================================================
+// ===========================================================================
+
+#ifndef _SRC_MRHF_FILTER_DEFS_H_
+#define _SRC_MRHF_FILTER_DEFS_H_
+
+#include "use_vpu.h"
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+ // General defines
+ // ---------------
+ // SSRC FIR filters IDs
+ #define FILTER_DEFS_SSRC_FIR_BL_ID 0 // ID of BL FIR filter
+ #define FILTER_DEFS_SSRC_FIR_BL9644_ID 1 // ID of BL9644 FIR filter
+ #define FILTER_DEFS_SSRC_FIR_BL8848_ID 2 // ID of BL8848 FIR filter
+ #define FITLER_DEFS_SSRC_FIR_BL19288_ID 3 // ID of BL19288 FIR filter
+ #define FILTER_DEFS_SSRC_FIR_BL17696_ID 4 // ID of BL17696 FIR filter
+ #define FILTER_DEFS_SSRC_FIR_UP_ID 5 // ID of UP FIR filter
+ #define FILTER_DEFS_SSRC_FIR_UP4844_ID 6 // ID of UP4844 FIR filter
+ #define FILTER_DEFS_SSRC_FIR_UPF_ID 7 // ID of UPF FIR filter
+ #define FILTER_DEFS_SSRC_FIR_UP192176_ID 8 // ID of UP192176 FIR filter
+ #define FILTER_DEFS_SSRC_FIR_DS_ID 9 // ID of DS FIR filter
+ #define FILTER_DEFS_SSRC_FIR_OS_ID 10 // ID of OS FIR filter
+ #define FILTER_DEFS_SSRC_FIR_NONE_ID 11 // ID of disabled FIR filter
+
+ // ASRC FIR filters IDs
+ #define FILTER_DEFS_ASRC_FIR_BL_ID 0 // ID of BL FIR filter
+ #define FILTER_DEFS_ASRC_FIR_BL9644_ID 1 // ID of BL9644 FIR filter
+ #define FILTER_DEFS_ASRC_FIR_BL8848_ID 2 // ID of BL8848 FIR filter
+ #define FITLER_DEFS_ASRC_FIR_BLF_ID 3 // ID of BLF FIR filter
+ #define FITLER_DEFS_ASRC_FIR_BL19288_ID 4 // ID of BL19288 FIR filter
+ #define FILTER_DEFS_ASRC_FIR_BL17696_ID 5 // ID of BL17696 FIR filter
+ #define FILTER_DEFS_ASRC_FIR_UP_ID 6 // ID of UP FIR filter
+ #define FILTER_DEFS_ASRC_FIR_UP4844_ID 7 // ID of UP4844 FIR filter
+ #define FILTER_DEFS_ASRC_FIR_UPF_ID 8 // ID of UPF FIR filter
+ #define FILTER_DEFS_ASRC_FIR_UP192176_ID 9 // ID of UP192176 FIR filter
+ #define FILTER_DEFS_ASRC_FIR_DS_ID 10 // ID of DS FIR filter
+ #define FILTER_DEFS_ASRC_FIR_NONE_ID 11 // ID of disabled FIR filter
+
+
+ #define FILTER_DEFS_SSRC_N_FIR_ID (FILTER_DEFS_SSRC_FIR_NONE_ID + 1) // Number of FIR IDs corresponding to real FIRs
+ #define FILTER_DEFS_ASRC_N_FIR_ID (FILTER_DEFS_ASRC_FIR_NONE_ID + 1) // Number of FIR IDs corresponding to real FIRs
+
+ // FIR filter number of taps
+ #define FILTER_DEFS_FIR_BL_N_TAPS 144 // Number of taps of BL FIR filter
+ #define FILTER_DEFS_FIR_BL9644_N_TAPS 160 // Number of taps of BL9644 FIR filter
+ #define FILTER_DEFS_FIR_BL8848_N_TAPS 144 // Number of taps of BL8848 filter
+ #define FILTER_DEFS_FIR_BLF_N_TAPS 96 // Number of taps of BLF FIR filter
+ #define FILTER_DEFS_FIR_BL19288_N_TAPS 96 // Number of taps of BL19288 filter
+ #define FILTER_DEFS_FIR_BL17696_N_TAPS 96 // Number of taps of BL17696 filter
+ #define FILTER_DEFS_FIR_UP_N_TAPS 144 // Number of taps of UP filter
+ #define FILTER_DEFS_FIR_UP4844_N_TAPS 160 // Number of taps of UP4844 filter
+ #define FILTER_DEFS_FIR_UPF_N_TAPS 96 // Number of taps of UPF filter
+ #define FILTER_DEFS_FIR_UP192176_N_TAPS 96 // Number of taps of UP192176 filter
+ #define FILTER_DEFS_FIR_DS_N_TAPS 32 // Number of taps of DS filter
+ #define FILTER_DEFS_FIR_OS_N_TAPS 32 // Number of taps of OS filter
+
+ #define FILTER_DEFS_FIR_MAX_TAPS_LONG FILTER_DEFS_FIR_BL9644_N_TAPS // Maximum number of taps for long FIR filter
+ #define FILTER_DEFS_FIR_MAX_TAPS_SHORT FILTER_DEFS_FIR_DS_N_TAPS // Maximum number of taps for short FIR filter
+
+ // FIR filter coefficients files
+#if SRC_USE_VPU
+ #define FILTER_DEFS_FIR_BL_FILE "FilterData/BL.dat" // Coefficients file for BL FIR filter
+ #define FILTER_DEFS_FIR_BL9644_FILE "FilterData/BL9644.dat" // Coefficients file for BL9644 FIR filter
+ #define FILTER_DEFS_FIR_BL8848_FILE "FilterData/BL8848.dat" // Coefficients file for BL8848 filter
+ #define FILTER_DEFS_FIR_BLF_FILE "FilterData/BLF.dat" // Coefficients file for BLF FIR filter
+ #define FILTER_DEFS_FIR_BL19288_FILE "FilterData/BL19288.dat" // Coefficients file for BL19288 FIR filter
+ #define FILTER_DEFS_FIR_BL17696_FILE "FilterData/BL17696.dat" // Coefficients file for BL17696 filter
+ #define FILTER_DEFS_FIR_UP_FILE "FilterData/UP_xs3.dat" // Coefficients file for UP filter
+ #define FILTER_DEFS_FIR_UP4844_FILE "FilterData/UP4844_xs3.dat" // Coefficients file for UP4844 filter
+ #define FILTER_DEFS_FIR_UPF_FILE "FilterData/UPF_xs3.dat" // Coefficients file for UPF filter
+ #define FILTER_DEFS_FIR_UP192176_FILE "FilterData/UP192176_xs3.dat" // Coefficients file for UP192176 filter
+ #define FILTER_DEFS_FIR_OS_FILE "FilterData/OS_xs3.dat" // Coefficients file for OS filter
+#else
+ #define FILTER_DEFS_FIR_BL_FILE "FilterData/BL.dat" // Coefficients file for BL FIR filter
+ #define FILTER_DEFS_FIR_BL9644_FILE "FilterData/BL9644.dat" // Coefficients file for BL9644 FIR filter
+ #define FILTER_DEFS_FIR_BL8848_FILE "FilterData/BL8848.dat" // Coefficients file for BL8848 filter
+ #define FILTER_DEFS_FIR_BLF_FILE "FilterData/BLF.dat" // Coefficients file for BLF FIR filter
+ #define FILTER_DEFS_FIR_BL19288_FILE "FilterData/BL19288.dat" // Coefficients file for BL19288 FIR filter
+ #define FILTER_DEFS_FIR_BL17696_FILE "FilterData/BL17696.dat" // Coefficients file for BL17696 filter
+ #define FILTER_DEFS_FIR_UP_FILE "FilterData/UP.dat" // Coefficients file for UP filter
+ #define FILTER_DEFS_FIR_UP4844_FILE "FilterData/UP4844.dat" // Coefficients file for UP4844 filter
+ #define FILTER_DEFS_FIR_UPF_FILE "FilterData/UPF.dat" // Coefficients file for UPF filter
+ #define FILTER_DEFS_FIR_UP192176_FILE "FilterData/UP192176.dat" // Coefficients file for UP192176 filter
+ #define FILTER_DEFS_FIR_OS_FILE "FilterData/OS.dat" // Coefficients file for OS filter
+#endif
+ #define FILTER_DEFS_FIR_DS_FILE "FilterData/DS.dat" // Coefficients file for DS filter
+
+ // ADFIR filter number of taps and phases
+ #define FILTER_DEFS_ADFIR_PROTOTYPE_N_TAPS 1920 // Number of taps of ADFIR filter prototype
+
+ #define FILTER_DEFS_ADFIR_N_PHASES 128 // Number of phases of ADFIR filter
+ #define FILTER_DEFS_ADFIR_PHASE_N_TAPS ((FILTER_DEFS_ADFIR_PROTOTYPE_N_TAPS / FILTER_DEFS_ADFIR_N_PHASES) + 1) // Number of taps per phase
+ #define FILTER_DEFS_ADFIR_N_TAPS (FILTER_DEFS_ADFIR_N_PHASES + 2) * FILTER_DEFS_ADFIR_PHASE_N_TAPS // Here 130 phases of 16 taps = 2080 coefs
+
+ // ADFIR filter coefficients files
+ #define FILTER_DEFS_ADFIR_PROTOTYPE_FILE "FilterData/ADFir.dat" // Coefficients file for the ADFIR filter (prototype)
+
+ // PPFIR filters IDs
+ #define FILTER_DEFS_PPFIR_HS294_ID 0 // ID of HS294 PPFIR filter
+ #define FILTER_DEFS_PPFIR_HS320_ID 1 // ID of HS320 PPFIR filter
+ #define FILTER_DEFS_PPFIR_NONE_ID 2 // ID of disabled PPFIR filter
+
+ #define FILTER_DEFS_N_PPFIR_ID (FILTER_DEFS_PPFIR_NONE_ID + 1) // Number of PPFIR IDs corresponding to real PPFIRs
+
+ // PPFIR filter number of taps and phases
+ #define FILTER_DEFS_PPFIR_HS294_N_TAPS 2352 // Number of taps of HS294 PPFIR filter
+ #define FILTER_DEFS_PPFIR_HS294_N_PHASES 147 // Number of phases of HS294 PPFIR filter
+ #define FILTER_DEFS_PPFIR_HS320_N_TAPS 2560 // Number of taps of HS320 PPFIR filter
+ #define FILTER_DEFS_PPFIR_HS320_N_PHASES 160 // Number of phases of HS284 PPFIR filter
+
+ #define FILTER_DEFS_PPFIR_PHASE_MAX_TAPS (FILTER_DEFS_PPFIR_HS320_N_TAPS / FILTER_DEFS_PPFIR_HS320_N_PHASES) // Maximum number of taps per phase
+
+ #define FILTER_DEFS_PPFIR_PHASE_STEP_0 0
+ #define FILTER_DEFS_PPFIR_PHASE_STEP_147 147
+ #define FILTER_DEFS_PPFIR_PHASE_STEP_294 294
+ #define FILTER_DEFS_PPFIR_PHASE_STEP_160 160
+ #define FILTER_DEFS_PPFIR_PHASE_STEP_320 320
+
+ // PPFIR filter coefficients files
+ #define FILTER_DEFS_PPFIR_HS294_FILE "FilterData/HS294.dat" // Coefficients file for HS294 PPFIR filter
+ #define FILTER_DEFS_PPFIR_HS320_FILE "FilterData/HS320.dat" // Coefficients file for HS320 PPFIR filter
+
+
+
+ // ===========================================================================
+ //
+ // Variables
+ //
+ // ===========================================================================
+
+ // FIR filters descriptors (ordered by ID)
+ extern FIRDescriptor_t sSSRCFirDescriptor[FILTER_DEFS_SSRC_N_FIR_ID];
+ extern FIRDescriptor_t sASRCFirDescriptor[FILTER_DEFS_ASRC_N_FIR_ID];
+
+ // FIR filters coefficients
+ extern int iFirBLCoefs[FILTER_DEFS_FIR_BL_N_TAPS];
+ extern int iFirBL9644Coefs[FILTER_DEFS_FIR_BL9644_N_TAPS];
+ extern int iFirBL8848[FILTER_DEFS_FIR_BL8848_N_TAPS];
+ extern int iFirBLFCoefs[FILTER_DEFS_FIR_BLF_N_TAPS];
+ extern int iFirBL19288Coefs[FILTER_DEFS_FIR_BL19288_N_TAPS];
+ extern int iFirBL17696[FILTER_DEFS_FIR_BL17696_N_TAPS];
+ extern int iFirUPCoefs[FILTER_DEFS_FIR_UP_N_TAPS];
+ extern int iFirUP4844Coefs[FILTER_DEFS_FIR_UP4844_N_TAPS];
+ extern int iFirUPFCoefs[FILTER_DEFS_FIR_UPF_N_TAPS];
+ extern int iFirUP192176Coefs[FILTER_DEFS_FIR_UP192176_N_TAPS];
+ extern int iFirDSCoefs[FILTER_DEFS_FIR_DS_N_TAPS];
+ extern int iFirOSCoefs[FILTER_DEFS_FIR_OS_N_TAPS];
+
+ // ADFIR filter descriptor
+ extern ADFIRDescriptor_t sADFirDescriptor;
+ // ADFIR filters coefficients
+ extern int iADFirPrototypeCoefs[FILTER_DEFS_ADFIR_PROTOTYPE_N_TAPS];
+#if SRC_USE_VPU
+ extern int iADFirCoefs[FILTER_DEFS_ADFIR_PHASE_N_TAPS][FILTER_DEFS_ADFIR_N_PHASES + 2];
+#else
+ extern int iADFirCoefs[FILTER_DEFS_ADFIR_N_PHASES + 2][FILTER_DEFS_ADFIR_PHASE_N_TAPS];
+#endif
+
+ // PPFIR filters descriptors (ordered by ID)
+ extern PPFIRDescriptor_t sPPFirDescriptor[FILTER_DEFS_N_PPFIR_ID];
+ // FIR filters coefficients
+ extern int iPPFirHS294Coefs[FILTER_DEFS_PPFIR_HS294_N_TAPS];
+ extern int iPPFirHS320Coefs[FILTER_DEFS_PPFIR_HS320_N_TAPS];
+
+ // ===========================================================================
+ //
+ // TypeDefs
+ //
+ // ===========================================================================
+
+
+#endif // _SRC_MRHF_FILTER_DEFS_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.c b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.c
new file mode 100644
index 0000000..525f585
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.c
@@ -0,0 +1,723 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// FIR functions implementation file for the ASRC and SSRC
+//
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+// Optimised assembler inner loop functions
+#include "src_mrhf_fir_os_inner_loop_asm.h"
+#include "src_mrhf_fir_inner_loop_asm.h"
+#include "src_mrhf_adfir_inner_loop_asm.h"
+#include "src_mrhf_spline_coeff_gen_inner_loop_asm.h"
+
+// FIR includes
+#include "src_mrhf_fir.h"
+#include "use_vpu.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+// State init value
+#define FIR_STATE_INIT 0
+
+
+
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+// ==================================================================== //
+// Function: FIR_init_from_desc //
+// Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+// FIRDescriptor_t *psFIRDescriptor: Desc. strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Inits the FIR from the Descriptor //
+// ==================================================================== //
+FIRReturnCodes_t FIR_init_from_desc(FIRCtrl_t* psFIRCtrl, FIRDescriptor_t* psFIRDescriptor)
+{
+
+ // Check if FIR is disabled (this is given by the number of coefficients being zero)
+ if( psFIRDescriptor->uiNCoefs == 0)
+ {
+ // Number of coefficients is zero, so disable FIR
+ psFIRCtrl->eEnable = FIR_OFF;
+ psFIRCtrl->uiNOutSamples = 0;
+ psFIRCtrl->pvProc = 0;
+ psFIRCtrl->uiDelayL = 0;
+ psFIRCtrl->piDelayW = 0;
+ psFIRCtrl->uiDelayO = 0;
+ psFIRCtrl->uiNLoops = 0;
+ psFIRCtrl->uiNCoefs = 0;
+ psFIRCtrl->piCoefs = 0;
+
+ return FIR_NO_ERROR;
+ }
+
+ // FIR is not disabled
+ // Check that delay line base has been set
+ if(psFIRCtrl->piDelayB == 0)
+ return FIR_ERROR;
+
+ // Check that number of samples has been set and is a multiple of 2
+ if(psFIRCtrl->uiNInSamples == 0)
+ return FIR_ERROR;
+ if((psFIRCtrl->uiNInSamples & 0x1) != 0x0)
+ return FIR_ERROR;
+
+ // Check the input and output samples steps have been set
+ if(psFIRCtrl->uiInStep == 0)
+ return FIR_ERROR;
+ if(psFIRCtrl->uiOutStep == 0)
+ return FIR_ERROR;
+
+ // Setup depending on FIR descriptor
+ switch(psFIRDescriptor->eType)
+ {
+ // Over-sampler by 2 type
+ case FIR_TYPE_OS2:
+ if( (psFIRDescriptor->uiNCoefs & 0x3) != 0x0) // Check that number of coefficients is a multiple of 4
+ return FIR_ERROR;
+ psFIRCtrl->eEnable = FIR_ON;
+ psFIRCtrl->uiNOutSamples = (psFIRCtrl->uiNInSamples)<<1; // Os2 FIR doubles the number of samples
+ psFIRCtrl->pvProc = (FIRReturnCodes_t (*)(int *)) FIR_proc_os2;
+ psFIRCtrl->uiDelayL = psFIRDescriptor->uiNCoefs; // Double length for circular buffer simulation, but only half length due to OS2
+ psFIRCtrl->piDelayW = psFIRCtrl->piDelayB + (psFIRDescriptor->uiNCoefs>>1);
+ psFIRCtrl->uiDelayO = psFIRDescriptor->uiNCoefs>>1;
+ psFIRCtrl->uiNLoops = psFIRDescriptor->uiNCoefs>>2; // Due to 2 x 32bits read for data and 4 x 32bits for coefs per inner loop
+ psFIRCtrl->uiNCoefs = psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->piCoefs = psFIRDescriptor->piCoefs;
+ break;
+
+ // Asynchronous type
+ case FIR_TYPE_SYNC:
+ if( (psFIRDescriptor->uiNCoefs & 0x1) != 0x0) // Check that number of coefficients is a multiple of 2
+ return FIR_ERROR;
+ // Non zero coefficients number, so it is a true filter
+ psFIRCtrl->eEnable = FIR_ON;
+ psFIRCtrl->uiNOutSamples = psFIRCtrl->uiNInSamples; // Sync FIR does not change number of samples
+ psFIRCtrl->pvProc = (FIRReturnCodes_t (*)(int *)) FIR_proc_sync;
+ psFIRCtrl->uiDelayL = psFIRDescriptor->uiNCoefs<<1; // Double length for circular buffer simulation
+ psFIRCtrl->piDelayW = psFIRCtrl->piDelayB + psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->uiDelayO = psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->uiNLoops = psFIRDescriptor->uiNCoefs>>1; // Due to 2 x 32bits read for data and coefs per inner loop
+ psFIRCtrl->uiNCoefs = psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->piCoefs = psFIRDescriptor->piCoefs;
+ break;
+
+ // Down-sample by 2 type
+ case FIR_TYPE_DS2:
+ if( (psFIRDescriptor->uiNCoefs & 0x1) != 0x0) // Check that number of coefficients is a multiple of 2
+ return FIR_ERROR;
+ psFIRCtrl->eEnable = FIR_ON;
+ psFIRCtrl->uiNOutSamples = psFIRCtrl->uiNInSamples>>1; // Ds2 FIR divides the number of samples by two
+ psFIRCtrl->pvProc = (FIRReturnCodes_t (*)(int *)) FIR_proc_ds2;
+ psFIRCtrl->uiDelayL = psFIRDescriptor->uiNCoefs<<1; // Double length for circular buffer simulation
+ psFIRCtrl->piDelayW = psFIRCtrl->piDelayB + psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->uiDelayO = psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->uiNLoops = psFIRDescriptor->uiNCoefs>>1; // Due to 2 x 32bits read for data and coefs per inner loop
+ psFIRCtrl->uiNCoefs = psFIRDescriptor->uiNCoefs;
+ psFIRCtrl->piCoefs = psFIRDescriptor->piCoefs;
+ break;
+
+ // Unrecognized type
+ default:
+ return FIR_ERROR;
+ }
+
+ // Sync the FIR
+ if(FIR_sync(psFIRCtrl) != FIR_NO_ERROR)
+ return FIR_ERROR;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: FIR_sync //
+// Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Syncs the FIR //
+// ==================================================================== //
+FIRReturnCodes_t FIR_sync(FIRCtrl_t* psFIRCtrl)
+{
+ unsigned int ui;
+
+ if(psFIRCtrl->eEnable == FIR_ON)
+ {
+ // Set delay line index back to base
+ psFIRCtrl->piDelayI = psFIRCtrl->piDelayB;
+
+ // Clear delay line
+ for(ui = 0; ui < psFIRCtrl->uiDelayL; ui++)
+ psFIRCtrl->piDelayB[ui] = FIR_STATE_INIT;
+ }
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: FIR_proc_os2 //
+// Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Processes the FIR in over-sample by 2 mode //
+// ==================================================================== //
+ __attribute__((fptrgroup("MRHF_G1")))
+FIRReturnCodes_t FIR_proc_os2(FIRCtrl_t* psFIRCtrl)
+{
+ int* piIn = psFIRCtrl->piIn;
+ unsigned int uiInStep = psFIRCtrl->uiInStep;
+ int* piOut = psFIRCtrl->piOut;
+ unsigned int uiOutStep = psFIRCtrl->uiOutStep;
+ int* piDelayB = psFIRCtrl->piDelayB;
+ int* piDelayI = psFIRCtrl->piDelayI;
+ int* piDelayW = psFIRCtrl->piDelayW;
+ unsigned int uiDelayO = psFIRCtrl->uiDelayO;
+ int* piCoefsB = psFIRCtrl->piCoefs;
+ unsigned int uiNLoops = psFIRCtrl->uiNLoops;
+ int* piData;
+ int* piCoefs;
+ int DWORD_ALIGNED iData[2];
+ unsigned ui;
+
+ for(ui = 0; ui < psFIRCtrl->uiNInSamples; ui+=2) //Note step by 2 as inner loop unrolled twice
+ {
+ // Get new data sample to delay line (double write for circular buffer simulation) with step
+ iData[0] = *piIn;
+ piIn += uiInStep;
+ // Double write to simulate circular buffer
+ *piDelayI = iData[0];
+ *(piDelayI + uiDelayO) = iData[0];
+
+ // Step delay (with circular simulation)
+ piDelayI++;
+ if(piDelayI >= piDelayW)
+ piDelayI = piDelayB;
+
+ // Set access pointers
+ piData = piDelayI;
+ piCoefs = piCoefsB;
+
+ //printf("piData = %p, piCoefs = %p\n", piData, piCoefs);
+#if SRC_USE_VPU
+ src_mrhf_fir_os_inner_loop_asm_xs3(piData, piCoefs, iData, uiNLoops);
+#else
+ if ((unsigned)piData & 0b0100)
+ src_mrhf_fir_os_inner_loop_asm_odd(piData, piCoefs, iData, uiNLoops);
+ else
+ src_mrhf_fir_os_inner_loop_asm(piData, piCoefs, iData, uiNLoops);
+#endif
+
+ // Write output with step
+ // NOTE OUTPUT WRITE ORDER: First iData[1], then iData[0]
+ *piOut = iData[1];
+ piOut += uiOutStep;
+ *piOut = iData[0];
+ piOut += uiOutStep;
+
+ // Get new data sample to delay line (double write for circular buffer simulation) with step
+ iData[0] = *piIn;
+ piIn += uiInStep;
+ // Double write to simulate circular buffer
+ *piDelayI = iData[0];
+ *(piDelayI + uiDelayO) = iData[0];
+
+ // Step delay (with circular simulation)
+ piDelayI++;
+ if(piDelayI >= piDelayW)
+ piDelayI = piDelayB;
+
+ // Set access pointers
+ piData = piDelayI;
+ piCoefs = piCoefsB;
+
+ //printf("piData = %p, piCoefs = %p\n", piData, piCoefs);
+#if SRC_USE_VPU
+ src_mrhf_fir_os_inner_loop_asm_xs3(piData, piCoefs, iData, uiNLoops);
+#else
+ if ((unsigned)piData & 0b0100)
+ src_mrhf_fir_os_inner_loop_asm_odd(piData, piCoefs, iData, uiNLoops);
+ else
+ src_mrhf_fir_os_inner_loop_asm(piData, piCoefs, iData, uiNLoops);
+#endif
+
+ // Write output with step
+ // NOTE OUTPUT WRITE ORDER: First iData[1], then iData[0]
+ *piOut = iData[1];
+ piOut += uiOutStep;
+ *piOut = iData[0];
+ piOut += uiOutStep;
+ }
+ // Write delay line index back for next round
+ psFIRCtrl->piDelayI = piDelayI;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: FIR_proc_sync //
+// Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Processes the FIR in asynchronous mode //
+// ==================================================================== //
+__attribute__((fptrgroup("MRHF_G1")))
+FIRReturnCodes_t FIR_proc_sync(FIRCtrl_t* psFIRCtrl)
+{
+ int* piIn = psFIRCtrl->piIn;
+ unsigned int uiInStep = psFIRCtrl->uiInStep;
+ int* piOut = psFIRCtrl->piOut;
+ unsigned int uiOutStep = psFIRCtrl->uiOutStep;
+ int* piDelayB = psFIRCtrl->piDelayB;
+ int* piDelayI = psFIRCtrl->piDelayI;
+ int* piDelayW = psFIRCtrl->piDelayW;
+ unsigned int uiDelayO = psFIRCtrl->uiDelayO;
+ int* piCoefsB = psFIRCtrl->piCoefs;
+ unsigned int uiNLoops = psFIRCtrl->uiNLoops;
+ int* piData;
+ int* piCoefs;
+ int iData0;
+ unsigned ui;
+
+ for(ui = 0; ui < psFIRCtrl->uiNInSamples; ui++)
+ {
+ // Get new data sample to delay line (double write for circular buffer simulation) with step
+ iData0 = *piIn;
+ piIn += uiInStep;
+ // Double write to simulate circular buffer
+ *piDelayI = iData0;
+ *(piDelayI + uiDelayO) = iData0;
+ // Step delay (with circular simulation)
+ piDelayI++;
+ if(piDelayI >= piDelayW)
+ piDelayI = piDelayB;
+
+ // Clear accumulator and set access pointers
+ piData = piDelayI;
+ piCoefs = piCoefsB;
+
+#if SRC_USE_VPU
+ src_mrhf_fir_inner_loop_asm_xs3(piData, piCoefs, &iData0, uiNLoops);
+#else
+ if ((unsigned)piData & 0b0100) src_mrhf_fir_inner_loop_asm_odd(piData, piCoefs, &iData0, uiNLoops);
+ else src_mrhf_fir_inner_loop_asm(piData, piCoefs, &iData0, uiNLoops);
+#endif
+
+ // Write output with step
+ *piOut = iData0;
+ piOut += uiOutStep;
+ }
+
+ // Write delay line index back for next round
+ psFIRCtrl->piDelayI = piDelayI;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: FIR_proc_ds2 //
+// Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Processes the FIR in down-sample by 2 mode //
+// ==================================================================== //
+__attribute__((fptrgroup("MRHF_G1")))
+FIRReturnCodes_t FIR_proc_ds2(FIRCtrl_t* psFIRCtrl)
+{
+ int* piIn = psFIRCtrl->piIn;
+ unsigned int uiInStep = psFIRCtrl->uiInStep;
+ int* piOut = psFIRCtrl->piOut;
+ unsigned int uiOutStep = psFIRCtrl->uiOutStep;
+ int* piDelayB = psFIRCtrl->piDelayB;
+ int* piDelayI = psFIRCtrl->piDelayI;
+ int* piDelayW = psFIRCtrl->piDelayW;
+ unsigned int uiDelayO = psFIRCtrl->uiDelayO;
+ int* piCoefsB = psFIRCtrl->piCoefs;
+ unsigned int uiNLoops = psFIRCtrl->uiNLoops;
+ int* piData;
+ int* piCoefs;
+ int iData0, iData1;
+ unsigned ui;
+
+ for(ui = 0; ui < psFIRCtrl->uiNInSamples>>1; ui++)
+ {
+ // Get two new data samples to delay line (double write for circular buffer simulation), with input buffer step
+ iData0 = *piIn;
+ piIn += uiInStep;
+ iData1 = *piIn;
+ piIn += uiInStep;
+ // Double write to simulate circular buffer with DUAL store instruction
+ *piDelayI = iData0;
+ *(piDelayI + 1) = iData1;
+ *(piDelayI + uiDelayO) = iData0;
+ *(piDelayI + uiDelayO + 1) = iData1;
+ // Step delay with circular simulation
+ piDelayI += 2;
+ if(piDelayI >= piDelayW)
+ piDelayI = piDelayB;
+
+ // Clear accumulator and set access pointers
+ piData = piDelayI;
+ piCoefs = piCoefsB;
+#if SRC_USE_VPU
+ src_mrhf_fir_inner_loop_asm_xs3(piData, piCoefs, &iData0, uiNLoops);
+#else
+ if ((unsigned)piData & 0b0100) src_mrhf_fir_inner_loop_asm_odd(piData, piCoefs, &iData0, uiNLoops);
+ else src_mrhf_fir_inner_loop_asm(piData, piCoefs, &iData0, uiNLoops);
+#endif
+ // Write output with step
+ *piOut = iData0;
+ piOut += uiOutStep;
+ }
+
+ // Write delay line index back for next round
+ psFIRCtrl->piDelayI = piDelayI;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: ADFIR_init_from_desc //
+// Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+// ADFIRDescriptor_t *psADFIRDescriptor: Desc. strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Inits the ADFIR from the Descriptor //
+// ==================================================================== //
+FIRReturnCodes_t ADFIR_init_from_desc(ADFIRCtrl_t* psADFIRCtrl, ADFIRDescriptor_t* psADFIRDescriptor)
+{
+ unsigned int uiPhaseLength;
+
+ // Check that delay line base has been set
+ if(psADFIRCtrl->piDelayB == 0)
+ return FIR_ERROR;
+
+ // Check that adaptive coefs buffer has been set
+ if(psADFIRCtrl->piADCoefs == 0)
+ return FIR_ERROR;
+
+ // Check that number of phases and number of coefficients per phaseare set
+ if(psADFIRDescriptor->uiNPhases == 0)
+ return FIR_ERROR;
+ if(psADFIRDescriptor->uiNCoefsPerPhase == 0)
+ return FIR_ERROR;
+
+ uiPhaseLength = psADFIRDescriptor->uiNCoefsPerPhase;
+ // Setup ADFIR
+ psADFIRCtrl->uiDelayL = uiPhaseLength<<1; // Double length for circular buffer simulation
+ psADFIRCtrl->piDelayW = psADFIRCtrl->piDelayB + uiPhaseLength;
+ psADFIRCtrl->uiDelayO = uiPhaseLength;
+ psADFIRCtrl->uiNLoops = uiPhaseLength>>1; // Due to 2 x 32bits read for data and coefs per inner loop
+
+ // Sync the ADFIR
+ if(ADFIR_sync(psADFIRCtrl) != FIR_NO_ERROR)
+ return FIR_ERROR;
+
+ return FIR_NO_ERROR;
+}
+
+// ==================================================================== //
+// Function: ADFIR_snyc //
+// Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Syncs the ADFIR filter //
+// ==================================================================== //
+FIRReturnCodes_t ADFIR_sync(ADFIRCtrl_t* psADFIRCtrl)
+{
+ unsigned int ui;
+
+ // Set delay line index back to base
+ psADFIRCtrl->piDelayI = psADFIRCtrl->piDelayB;
+
+ // Clear delay line
+ for(ui = 0; ui < psADFIRCtrl->uiDelayL; ui++)
+ psADFIRCtrl->piDelayB[ui] = FIR_STATE_INIT;
+
+ return FIR_NO_ERROR;
+}
+
+// ==================================================================== //
+// Function: ADFIR_proc_in_sample //
+// Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Gets new input sample to delay line with step //
+// ==================================================================== //
+FIRReturnCodes_t ADFIR_proc_in_spl(ADFIRCtrl_t* psADFIRCtrl)
+{
+ // Double write to simulate circular buffer
+ *psADFIRCtrl->piDelayI = psADFIRCtrl->iIn;
+ *(psADFIRCtrl->piDelayI + psADFIRCtrl->uiDelayO) = psADFIRCtrl->iIn;
+ // Step delay (with circular simulation)
+ psADFIRCtrl->piDelayI++;
+ if(psADFIRCtrl->piDelayI >= psADFIRCtrl->piDelayW)
+ psADFIRCtrl->piDelayI = psADFIRCtrl->piDelayB;
+
+ return FIR_NO_ERROR;
+}
+
+// ==================================================================== //
+// Function: ADFIR_proc_macc //
+// Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Processes the macc loop for the ADFIR filter //
+// ==================================================================== //
+FIRReturnCodes_t ADFIR_proc_macc(ADFIRCtrl_t* psADFIRCtrl)
+{
+ int* piData;
+ int* piCoefs;
+ int iData;
+
+
+
+ //*(psADFIRCtrl->piOut) = *psADFIRCtrl->piDelayI;
+
+ // Clear accumulator and set access pointers
+ piData = psADFIRCtrl->piDelayI;
+ piCoefs = psADFIRCtrl->piADCoefs;
+ if ((unsigned)piData & 0b0100) src_mrhf_adfir_inner_loop_asm_odd(piData, piCoefs, &iData, psADFIRCtrl->uiNLoops);
+ else src_mrhf_adfir_inner_loop_asm(piData, piCoefs, &iData, psADFIRCtrl->uiNLoops);
+
+ // Write output
+ *(psADFIRCtrl->piOut) = iData;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: PPFIR_init_from_desc //
+// Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+// PPFIRDescriptor_t *psPPFIRDescriptor: Desc. strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Inits the PPFIR from the Descriptor //
+// ==================================================================== //
+FIRReturnCodes_t PPFIR_init_from_desc(PPFIRCtrl_t* psPPFIRCtrl, PPFIRDescriptor_t* psPPFIRDescriptor)
+{
+ unsigned int uiPhaseLength;
+
+ // Check if PPFIR is disabled (this is given by the number of coefficients being zero)
+ if( psPPFIRDescriptor->uiNCoefs == 0)
+ {
+ // Number of coefficients is zero, so disable FIR
+ psPPFIRCtrl->eEnable = FIR_OFF;
+ psPPFIRCtrl->uiNOutSamples = 0;
+ psPPFIRCtrl->uiDelayL = 0;
+ psPPFIRCtrl->piDelayW = 0;
+ psPPFIRCtrl->uiDelayO = 0;
+ psPPFIRCtrl->uiNLoops = 0;
+ psPPFIRCtrl->uiNCoefs = 0;
+ psPPFIRCtrl->piCoefs = 0;
+ psPPFIRCtrl->uiNPhases = 0;
+ psPPFIRCtrl->uiPhaseStep = 0;
+ psPPFIRCtrl->uiCoefsPhaseStep = 0;
+ psPPFIRCtrl->uiCoefsPhase = 0;
+ return FIR_NO_ERROR;
+ }
+
+ // Check that delay line base has been set
+ if(psPPFIRCtrl->piDelayB == 0)
+ return FIR_ERROR;
+
+ // Check that number of samples has been set and is a multiple of 2
+ if(psPPFIRCtrl->uiNInSamples == 0)
+ return FIR_ERROR;
+
+ // Check the input and output samples steps have been set
+ if(psPPFIRCtrl->uiInStep == 0)
+ return FIR_ERROR;
+ if(psPPFIRCtrl->uiOutStep == 0)
+ return FIR_ERROR;
+
+ // Check that phase step has been set properly
+ if(psPPFIRCtrl->uiPhaseStep == 0)
+ return FIR_ERROR;
+
+ // Check that number of phases and number of coefficients are compatible
+ uiPhaseLength = (psPPFIRDescriptor->uiNCoefs / psPPFIRDescriptor->uiNPhases);
+ if(uiPhaseLength == 0)
+ return FIR_ERROR;
+ if((uiPhaseLength * psPPFIRDescriptor->uiNPhases) != psPPFIRDescriptor->uiNCoefs)
+ return FIR_ERROR;
+ if((uiPhaseLength & 0x1) != 0)
+ return FIR_ERROR;
+
+ // Setup PPFIR
+ psPPFIRCtrl->eEnable = FIR_ON;
+ psPPFIRCtrl->uiDelayL = uiPhaseLength<<1; // Double length for circular buffer simulation
+ psPPFIRCtrl->piDelayW = psPPFIRCtrl->piDelayB + uiPhaseLength;
+ psPPFIRCtrl->uiDelayO = uiPhaseLength;
+ psPPFIRCtrl->uiNLoops = uiPhaseLength>>1; // Due to 2 x 32bits read for data and coefs per inner loop
+ psPPFIRCtrl->uiNCoefs = psPPFIRDescriptor->uiNCoefs;
+ psPPFIRCtrl->piCoefs = psPPFIRDescriptor->piCoefs;
+ psPPFIRCtrl->uiNPhases = psPPFIRDescriptor->uiNPhases;
+ psPPFIRCtrl->uiCoefsPhaseStep = psPPFIRCtrl->uiPhaseStep * uiPhaseLength; // Length (number of coefs) of a phase step
+
+ // Sync the PPFIR
+ if(PPFIR_sync(psPPFIRCtrl) != FIR_NO_ERROR)
+ return FIR_ERROR;
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: PPFIR_snyc //
+// Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Syncs the PPFIR polyphase filter //
+// ==================================================================== //
+FIRReturnCodes_t PPFIR_sync(PPFIRCtrl_t* psPPFIRCtrl)
+{
+ unsigned int ui;
+
+ if(psPPFIRCtrl->eEnable == FIR_ON)
+ {
+ // Set delay line index back to base
+ psPPFIRCtrl->piDelayI = psPPFIRCtrl->piDelayB;
+
+ // Clear delay line
+ for(ui = 0; ui < psPPFIRCtrl->uiDelayL; ui++)
+ psPPFIRCtrl->piDelayB[ui] = FIR_STATE_INIT;
+
+ // Set coefficients phase to zero
+ psPPFIRCtrl->uiCoefsPhase = 0;
+
+ // Clear number of output sampes
+ psPPFIRCtrl->uiNOutSamples = 0;
+ }
+
+
+ return FIR_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: PPFIR_proc //
+// Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+// Return values: FIR_NO_ERROR on success //
+// FIR_ERROR on failure //
+// Description: Processes the PPFIR polyphase filter //
+// ==================================================================== //
+FIRReturnCodes_t PPFIR_proc(PPFIRCtrl_t* psPPFIRCtrl)
+{
+ int* piIn = psPPFIRCtrl->piIn;
+ unsigned int uiInStep = psPPFIRCtrl->uiInStep;
+ int* piOut = psPPFIRCtrl->piOut;
+ unsigned int uiOutStep = psPPFIRCtrl->uiOutStep;
+ int* piDelayB = psPPFIRCtrl->piDelayB;
+ int* piDelayI = psPPFIRCtrl->piDelayI;
+ int* piDelayW = psPPFIRCtrl->piDelayW;
+ unsigned int uiDelayO = psPPFIRCtrl->uiDelayO;
+ int* piCoefsB = psPPFIRCtrl->piCoefs;
+ unsigned int uiNLoops = psPPFIRCtrl->uiNLoops;
+ unsigned int uiNCoefs = psPPFIRCtrl->uiNCoefs;
+ unsigned int uiCoefsPhase = psPPFIRCtrl->uiCoefsPhase;
+ unsigned int uiCoefsPhaseStep = psPPFIRCtrl->uiCoefsPhaseStep;
+ int* piData;
+ int* piCoefs;
+ int iData[2];
+ unsigned int uiNOutSamples = 0;
+ unsigned ui;
+
+
+ for(ui = 0; ui < psPPFIRCtrl->uiNInSamples; ui++)
+ {
+ // Get new data sample to delay line (double write for circular buffer simulation) with step
+ iData[0] = *piIn;
+ piIn += uiInStep;
+ // Double write to simulate circular buffer
+ *piDelayI = iData[0];
+ *(piDelayI + uiDelayO) = iData[0];
+ // Step delay (with circular simulation)
+ piDelayI++;
+ if(piDelayI >= piDelayW)
+ piDelayI = piDelayB;
+
+ // Do while the current phase coefficient pointer points to phase coefficients
+ // This is equivalent to know if the output sample is between the current and next input sample
+
+ while(uiCoefsPhase < uiNCoefs)
+ {
+ // Clear accumulator and set access pointers
+ piData = piDelayI;
+ piCoefs = piCoefsB + uiCoefsPhase;
+
+ if ((unsigned)piData & 0b0100) src_mrhf_fir_inner_loop_asm_odd(piData, piCoefs, iData, uiNLoops);
+ else src_mrhf_fir_inner_loop_asm(piData, piCoefs, iData, uiNLoops);
+
+
+ // Write output with step
+ *piOut = iData[0];
+ piOut += uiOutStep;
+
+ // Step phase coefficient offset for next output phase
+ uiCoefsPhase += uiCoefsPhaseStep;
+
+ // Increase output sample counter
+ uiNOutSamples++;
+ }
+
+ // Reduce phase for next input sample (one input sample corresponds to all coefficients in the PP filter)
+ uiCoefsPhase -= uiNCoefs;
+ }
+
+ // Write delay line index back for next round
+ psPPFIRCtrl->piDelayI = piDelayI;
+ // Write coefs phase back for next round
+ psPPFIRCtrl->uiCoefsPhase = uiCoefsPhase;
+ // Write number of samples
+ psPPFIRCtrl->uiNOutSamples = uiNOutSamples;
+
+ return FIR_NO_ERROR;
+}
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.h
new file mode 100644
index 0000000..7ae4945
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir.h
@@ -0,0 +1,412 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// FIR functions definition file for the SRC
+//
+// ===========================================================================
+// ===========================================================================
+
+#ifndef _SRC_MRHF_FIR_H
+#define _SRC_MRHF_FIR_H
+#ifndef ALIGNMENT
+# ifdef __xcore__
+# define ALIGNMENT(N) __attribute__((aligned (N)))
+# else
+# define ALIGNMENT(N)
+# endif
+#endif
+
+/// (on xcore) Force variable to word alignment
+#ifndef WORD_ALIGNED
+# define WORD_ALIGNED ALIGNMENT(4)
+#endif
+
+/// (on xcore) Force variable to double word alignment
+#ifndef DWORD_ALIGNED
+# define DWORD_ALIGNED ALIGNMENT(8)
+#endif
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+ // General defines
+ // ---------------
+
+
+ // Parameter values
+ // ----------------
+
+
+
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+
+ // ===========================================================================
+ //
+ // TypeDefs
+ //
+ // ===========================================================================
+
+ // To avoid C type definitions when including this file from assembler
+ #ifndef INCLUDE_FROM_ASM
+
+ // FIR Return Codes
+ // ----------------
+ typedef enum _FIRReturnCodes
+ {
+ FIR_NO_ERROR = 0,
+ FIR_ERROR = 1
+ } FIRReturnCodes_t;
+
+ // FIR On/Off Codes
+ // ----------------
+ typedef enum _FIROnOffCodes
+ {
+ FIR_OFF = 0,
+ FIR_ON = 1
+ } FIROnOffCodes_t;
+
+
+ // FIR Type Codes
+ // --------------
+ typedef enum _FIRTypeCodes
+ {
+ FIR_TYPE_OS2 = 0, // Over-sampler by two FIR
+ FIR_TYPE_SYNC = 1, // Asynchronous (low-pass) FIR
+ FIR_TYPE_DS2 = 2, // Down-sampler by two FIR
+ } FIRTypeCodes_t;
+
+#ifdef __XC__
+ // FIR Descriptor
+ // --------------
+ typedef struct _FIRDescriptor
+ {
+ FIRTypeCodes_t eType; // Type of filter
+ unsigned int uiNCoefs; // Number of coefficients
+ int* unsafe piCoefs; // Pointer to coefficients
+ } FIRDescriptor_t;
+
+
+ // FIR Ctrl
+ // --------
+ typedef struct _FIRCtrl
+ {
+ FIROnOffCodes_t eEnable; // FIR on/off
+
+ int* unsafe piIn; // Pointer to input data
+ unsigned int uiNInSamples; // Number of input samples to process
+ unsigned int uiInStep; // Step between input data samples
+ int* unsafe piOut; // Pointer to output data
+ unsigned int uiNOutSamples; // Number of output samples produced
+ unsigned int uiOutStep; // Step between output data samples
+
+ FIRReturnCodes_t * unsafe pvProc; // Processing function address
+
+ int* unsafe piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* unsafe piDelayI; // Pointer to current position in delay line
+ int* unsafe piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ unsigned int uiNCoefs; // Number of coefficients
+ int* unsafe piCoefs; // Pointer to coefficients
+ } FIRCtrl_t;
+
+
+ // ADFIR Descriptor
+ // ----------------
+ typedef struct _ADFIRDescriptor
+ {
+ unsigned int uiNCoefsPerPhase; // Number of coefficients
+ unsigned int uiNPhases; // Number of phases
+ int* unsafe piCoefs; // Pointer to coefficients
+ } ADFIRDescriptor_t;
+
+ // ADFIR Ctrl
+ // ----------
+ typedef struct _ADFIRCtrl
+ {
+ int iIn; // Input sample
+ int* unsafe piOut; // Pointer to output sample
+
+ int* unsafe piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* unsafe piDelayI; // Pointer to current position in delay line
+ int* unsafe piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ int* unsafe piADCoefs; // Pointer to adaptive coefficients
+ } ADFIRCtrl_t;
+
+
+ // PPFIR Descriptor
+ // --------------
+ typedef struct _PPFIRDescriptor
+ {
+ unsigned int uiNCoefs; // Number of coefficients
+ unsigned int uiNPhases; // Number of phases
+ int* unsafe piCoefs; // Pointer to coefficients
+ } PPFIRDescriptor_t;
+
+ // PPFIR Ctrl
+ // ----------
+ typedef struct _PPFIRCtrl
+ {
+ FIROnOffCodes_t eEnable; // PPFIR on/off
+
+ int* unsafe piIn; // Pointer to input data
+ unsigned int uiNInSamples; // Number of input samples to process
+ unsigned int uiInStep; // Step between input data samples
+ int* unsafe piOut; // Pointer to output data
+ unsigned int uiNOutSamples; // Number of output samples produced
+ unsigned int uiOutStep; // Step between output data samples
+
+ int* unsafe piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* unsafe piDelayI; // Pointer to current position in delay line
+ int* unsafe piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ unsigned int uiNCoefs; // Number of coefficients
+ int* unsafe piCoefs; // Pointer to coefficients
+ unsigned int uiNPhases; // Number of phases
+ unsigned int uiPhaseStep; // Phase step
+ unsigned int uiCoefsPhaseStep; // Number of coefficients for a phase step
+ unsigned int uiCoefsPhase; // Current phase coefficient offset from base
+
+ } PPFIRCtrl_t;
+#else
+ // FIR Descriptor
+ // --------------
+ typedef struct _FIRDescriptor
+ {
+ FIRTypeCodes_t eType; // Type of filter
+ unsigned int uiNCoefs; // Number of coefficients
+ int* piCoefs; // Pointer to coefficients
+ } FIRDescriptor_t;
+
+
+ // FIR Ctrl
+ // --------
+ typedef struct _FIRCtrl
+ {
+ FIROnOffCodes_t eEnable; // FIR on/off
+
+ int* piIn; // Pointer to input data
+ unsigned int uiNInSamples; // Number of input samples to process
+ unsigned int uiInStep; // Step between input data samples
+ int* piOut; // Pointer to output data
+ unsigned int uiNOutSamples; // Number of output samples produced
+ unsigned int uiOutStep; // Step between output data samples
+
+__attribute__((fptrgroup("MRHF_G1")))
+ FIRReturnCodes_t (*pvProc)(int *);// Processing function address
+
+ int* piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* piDelayI; // Pointer to current position in delay line
+ int* piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ unsigned int uiNCoefs; // Number of coefficients
+ int* piCoefs; // Pointer to coefficients
+ } FIRCtrl_t;
+
+ // ADFIR Descriptor
+ // ----------------
+ typedef struct _ADFIRDescriptor
+ {
+ unsigned int uiNCoefsPerPhase; // Number of coefficients
+ unsigned int uiNPhases; // Number of phases
+ int* piCoefs; // Pointer to coefficients
+ } ADFIRDescriptor_t;
+
+ // ADFIR Ctrl
+ // ----------
+ typedef struct _ADFIRCtrl
+ {
+ int iIn; // Input sample
+ int* piOut; // Pointer to output sample
+
+ int* piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* piDelayI; // Pointer to current position in delay line
+ int* piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ int* piADCoefs; // Pointer to adaptive coefficients
+ } ADFIRCtrl_t;
+
+
+ // PPFIR Descriptor
+ // --------------
+ typedef struct _PPFIRDescriptor
+ {
+ unsigned int uiNCoefs; // Number of coefficients
+ unsigned int uiNPhases; // Number of phases
+ int* piCoefs; // Pointer to coefficients
+ } PPFIRDescriptor_t;
+
+ // PPFIR Ctrl
+ // ----------
+ typedef struct _PPFIRCtrl
+ {
+ FIROnOffCodes_t eEnable; // PPFIR on/off
+
+ int* piIn; // Pointer to input data
+ unsigned int uiNInSamples; // Number of input samples to process
+ unsigned int uiInStep; // Step between input data samples
+ int* piOut; // Pointer to output data
+ unsigned int uiNOutSamples; // Number of output samples produced
+ unsigned int uiOutStep; // Step between output data samples
+
+ int* piDelayB; // Pointer to delay line base
+ unsigned int uiDelayL; // Total length of delay line
+ int* piDelayI; // Pointer to current position in delay line
+ int* piDelayW; // Delay buffer wrap around address (for circular buffer simulation)
+ unsigned int uiDelayO; // Delay line offset for second write (for circular buffer simulation)
+
+ unsigned int uiNLoops; // Number of inner loop iterations
+ unsigned int uiNCoefs; // Number of coefficients
+ int* piCoefs; // Pointer to coefficients
+ unsigned int uiNPhases; // Number of phases
+ unsigned int uiPhaseStep; // Phase step
+ unsigned int uiCoefsPhaseStep; // Number of coefficients for a phase step
+ unsigned int uiCoefsPhase; // Current phase coefficient offset from base
+
+ } PPFIRCtrl_t;
+#endif
+
+ // ===========================================================================
+ //
+ // Function prototypes
+ //
+ // ===========================================================================
+
+ // ==================================================================== //
+ // Function: FIR_init_from_desc //
+ // Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+ // FIRDescriptor_t *psFIRDescriptor: Desc. strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Inits the FIR from the Descriptor //
+ // ==================================================================== //
+ FIRReturnCodes_t FIR_init_from_desc(FIRCtrl_t* psFIRCtrl, FIRDescriptor_t* psFIRDescriptor);
+
+ // ==================================================================== //
+ // Function: FIR_sync //
+ // Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Syncs the FIR //
+ // ==================================================================== //
+ FIRReturnCodes_t FIR_sync(FIRCtrl_t* psFIRCtrl);
+
+ // ==================================================================== //
+ // Function: FIR_proc_os2 //
+ // Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Processes the FIR in over-sample by 2 mode //
+ // ==================================================================== //
+ FIRReturnCodes_t FIR_proc_os2(FIRCtrl_t* psFIRCtrl);
+
+ // ==================================================================== //
+ // Function: FIR_proc_sync //
+ // Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Processes the FIR in asynchronous mode //
+ // ==================================================================== //
+ FIRReturnCodes_t FIR_proc_sync(FIRCtrl_t* psFIRCtrl);
+
+ // ==================================================================== //
+ // Function: FIR_proc_ds2 //
+ // Arguments: FIRCtrl_t *psFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Processes the FIR in down-sample by 2 mode //
+ // ==================================================================== //
+ FIRReturnCodes_t FIR_proc_ds2(FIRCtrl_t* psFIRCtrl);
+
+ // ==================================================================== //
+ // Function: ADFIR_init_from_desc //
+ // Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+ // ADFIRDescriptor_t *psADFIRDescriptor: Desc. strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Inits the ADFIR from the Descriptor //
+ // ==================================================================== //
+ FIRReturnCodes_t ADFIR_init_from_desc(ADFIRCtrl_t* psADFIRCtrl, ADFIRDescriptor_t* psADFIRDescriptor);
+
+ // ==================================================================== //
+ // Function: ADFIR_snyc //
+ // Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Syncs the ADFIR filter //
+ // ==================================================================== //
+ FIRReturnCodes_t ADFIR_sync(ADFIRCtrl_t* psADFIRCtrl);
+
+ // ==================================================================== //
+ // Function: ADFIR_proc_in_sample //
+ // Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Gets new input sample to delay line with step //
+ // ==================================================================== //
+ FIRReturnCodes_t ADFIR_proc_in_spl(ADFIRCtrl_t* psADFIRCtrl);
+
+ // ==================================================================== //
+ // Function: ADFIR_proc_macc //
+ // Arguments: ADFIRCtrl_t *psADFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Processes the macc loop for the ADFIR filter //
+ // ==================================================================== //
+ FIRReturnCodes_t ADFIR_proc_macc(ADFIRCtrl_t* psADFIRCtrl);
+
+ // ==================================================================== //
+ // Function: PPFIR_init_from_desc //
+ // Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+ // PPFIRDescriptor_t *psPPFIRDescriptor: Desc. strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Inits the PPFIR from the Descriptor //
+ // ==================================================================== //
+ FIRReturnCodes_t PPFIR_init_from_desc(PPFIRCtrl_t* psPPFIRCtrl, PPFIRDescriptor_t* psPPFIRDescriptor);
+
+ // ==================================================================== //
+ // Function: PPFIR_snyc //
+ // Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Syncs the PPFIR polyphase filter //
+ // ==================================================================== //
+ FIRReturnCodes_t PPFIR_sync(PPFIRCtrl_t* psPPFIRCtrl);
+
+ // ==================================================================== //
+ // Function: PPFIR_proc //
+ // Arguments: PPFIRCtrl_t *psPPFIRCtrl: Ctrl strct. //
+ // Return values: FIR_NO_ERROR on success //
+ // FIR_ERROR on failure //
+ // Description: Processes the PPFIR polyphase filter //
+ // ==================================================================== //
+ FIRReturnCodes_t PPFIR_proc(PPFIRCtrl_t* psPPFIRCtrl);
+ #endif // nINCLUDE_FROM_ASM
+
+#endif // _SRC_MRHF_FIR_H
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.S
new file mode 100644
index 0000000..cfc4c4a
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.S
@@ -0,0 +1,251 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_fir_inner_loop_asm.function
+ .globl src_mrhf_fir_inner_loop_asm
+ .align 8
+ .type src_mrhf_fir_inner_loop_asm,@function
+
+src_mrhf_fir_inner_loop_asm:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 8
+ {stw iDataRet_p, sp[6]; shr counter, counter, 3}
+
+ //Constant for adding onto stuff. Gets updated later
+ ldc step, 0x40
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+
+ bf counter, src_mrhf_fir_done
+src_mrhf_fir_main_loop:
+ sub counter, counter, 1
+
+ ldd iData0, iData1, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[1]
+ ldd iCoef0, iCoef1, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[2]
+ ldd iCoef0, iCoef1, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[3]
+ ldd iCoef0, iCoef1, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[4]
+ ldd iCoef0, iCoef1, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[5]
+ ldd iCoef0, iCoef1, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[6]
+ ldd iCoef0, iCoef1, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iData0, iData1, piData_p[7]
+ ldd iCoef0, iCoef1, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ //Decrement loop counter and increment pointers and branch if still running
+ {add piData_p, piData_p, step; add piCoefs_p, piCoefs_p, step}
+
+ bt counter, src_mrhf_fir_main_loop
+
+src_mrhf_fir_done:
+ //pop return value pointer from stack so we can use it to write back
+ //Write back the two return values
+ {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3)
+
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp:
+ .size src_mrhf_fir_inner_loop_asm, .atmp-src_mrhf_fir_inner_loop_asm
+ .align 8
+ .cc_bottom src_mrhf_fir_inner_loop_asm.function
+
+ .set src_mrhf_fir_inner_loop_asm.nstackwords, stack_size
+ .globl src_mrhf_fir_inner_loop_asm.nstackwords
+ .set src_mrhf_fir_inner_loop_asm.maxcores, 1
+ .globl src_mrhf_fir_inner_loop_asm.maxcores
+ .set src_mrhf_fir_inner_loop_asm.maxtimers,0
+ .globl src_mrhf_fir_inner_loop_asm.maxtimers
+ .set src_mrhf_fir_inner_loop_asm.maxchanends,0
+ .globl src_mrhf_fir_inner_loop_asm.maxchanends
+
+
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_fir_inner_loop_asm_odd.function
+ .globl src_mrhf_fir_inner_loop_asm_odd
+ .align 8
+ .type src_mrhf_fir_inner_loop_asm_odd,@function
+
+src_mrhf_fir_inner_loop_asm_odd:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+
+
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 8
+ {stw iDataRet_p, sp[6]; shr counter, counter, 3}
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+
+ bf counter, src_mrhf_fir_done
+src_mrhf_fir_main_loop_odd:
+
+ {sub counter, counter, 1; ldc step, 0x38}
+
+ //Constant for adding onto stuff. Gets updated later
+
+ {ldw iData0, piData_p[0]; add piData_p, piData_p, 4} //Now 64b aligned
+
+ ldd iCoef1, iCoef0, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[0]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[1]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[2]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[3]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[4]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[5]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ ldd iData0, iData1, piData_p[6]
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+
+ ldd iCoef1, iCoef0, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+
+ add piData_p, piData_p, step
+
+ {ldw iData1, piData_p[0]; add piData_p, piData_p, 4} //0x4 + 0x38 + 0x4 = 0x40)
+ maccs Acc0_h, Acc0_l, iData1, iCoef1
+ //Increment pointers and branch if still running
+
+ ldc step, 0x40
+ {bt counter, src_mrhf_fir_main_loop_odd; add piCoefs_p, piCoefs_p, step}
+
+src_mrhf_fir_done_odd:
+ //pop return value pointer from stack so we can use it to write back
+ {ldw iDataRet_p, sp[6]; ldc counter, 31} //Reuse counter (r3)
+
+ //Write back the return value
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ stw iData0, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ retsp stack_size
+
+.atmp_odd:
+ .size src_mrhf_fir_inner_loop_asm_odd, .atmp_odd-src_mrhf_fir_inner_loop_asm_odd
+ .align 8
+ .cc_bottom src_mrhf_fir_inner_loop_asm_odd.function
+
+ .set src_mrhf_fir_inner_loop_asm_odd.nstackwords, stack_size
+ .globl src_mrhf_fir_inner_loop_asm_odd.nstackwords
+ .set src_mrhf_fir_inner_loop_asm_odd.maxcores, 1
+ .globl src_mrhf_fir_inner_loop_asm_odd.maxcores
+ .set src_mrhf_fir_inner_loop_asm_odd.maxtimers,0
+ .globl src_mrhf_fir_inner_loop_asm_odd.maxtimers
+ .set src_mrhf_fir_inner_loop_asm_odd.maxchanends,0
+ .globl src_mrhf_fir_inner_loop_asm_odd.maxchanends
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.h
new file mode 100644
index 0000000..198d561
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_inner_loop_asm.h
@@ -0,0 +1,10 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_MRHF_FIR_INNER_LOOP_ASM_H_
+#define _SRC_MRHF_FIR_INNER_LOOP_ASM_H_
+
+void src_mrhf_fir_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_fir_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_fir_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count);
+
+#endif // _SRC_MRHF_FIR_INNER_LOOP_ASM_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.S
new file mode 100644
index 0000000..fec8696
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.S
@@ -0,0 +1,265 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_fir_os_inner_loop_asm.function
+ .globl src_mrhf_fir_os_inner_loop_asm
+ .align 8
+ .type src_mrhf_fir_os_inner_loop_asm,@function
+
+src_mrhf_fir_os_inner_loop_asm:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+#define Acc1_l r10
+#define Acc1_h r11
+
+
+
+#define stack_size 10 //In words
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+ std r10, r11, sp[3]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 4
+ {stw iDataRet_p, sp[8]; shr counter, counter, 2}
+
+ //Constant for adding onto stuff. Gets updated later
+ ldc step, 0x40
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+
+ bf counter, src_mrhf_fir_os_done
+src_mrhf_fir_os_main_loop:
+ sub counter, counter, 1
+
+ ldd iData1, iData0, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[0]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ ldd iData1, iData0, piData_p[1]
+ ldd iCoef0, iCoef1, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ ldd iData1, iData0, piData_p[2]
+ ldd iCoef0, iCoef1, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ ldd iData1, iData0, piData_p[3]
+ ldd iCoef0, iCoef1, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[7]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ //Increment coeffs by step
+ {add piCoefs_p, piCoefs_p, step; shr step, step, 1}
+ //Increment data by step/2
+ {add piData_p, piData_p, step; shl step, step, 1}
+
+ //Decrement loop counter
+ bt counter, src_mrhf_fir_os_main_loop
+
+src_mrhf_fir_os_done:
+ //pop return value pointer from stack so we can use it to write back
+ //Resuse counter (r3)
+ {ldw iDataRet_p, sp[8]; ldc counter, 31}
+
+ //Write back the two return values and do sat/ext
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lsats Acc1_h, Acc1_l, r3
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ lextract iData1, Acc1_h, Acc1_l, counter, 32
+ //stw iData0, iDataRet_p[1]
+ //stw iData1, iDataRet_p[0]
+ std iData0, iData1, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ ldd r10, r11, sp[3]
+ retsp stack_size
+
+.atmp:
+ .size src_mrhf_fir_os_inner_loop_asm, .atmp-src_mrhf_fir_os_inner_loop_asm
+ .align 8
+ .cc_bottom src_mrhf_fir_os_inner_loop_asm.function
+
+ .set src_mrhf_fir_os_inner_loop_asm.nstackwords, stack_size
+ .globl src_mrhf_fir_os_inner_loop_asm.nstackwords
+ .set src_mrhf_fir_os_inner_loop_asm.maxcores, 1
+ .globl src_mrhf_fir_os_inner_loop_asm.maxcores
+ .set src_mrhf_fir_os_inner_loop_asm.maxtimers,0
+ .globl src_mrhf_fir_os_inner_loop_asm.maxtimers
+ .set src_mrhf_fir_os_inner_loop_asm.maxchanends,0
+ .globl src_mrhf_fir_os_inner_loop_asm.maxchanends
+
+
+
+
+
+
+
+
+
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_fir_os_inner_loop_asm_odd.function
+ .globl src_mrhf_fir_os_inner_loop_asm_odd
+ .align 8
+ .type src_mrhf_fir_os_inner_loop_asm_odd,@function
+
+src_mrhf_fir_os_inner_loop_asm_odd:
+
+#define piData_p r0
+#define piCoefs_p r1
+#define iDataRet_p r2
+#define step r2
+#define counter r3
+#define iCoef0 r4
+#define iCoef1 r5
+#define iData0 r6
+#define iData1 r7
+#define Acc0_l r8
+#define Acc0_h r9
+#define Acc1_l r10
+#define Acc1_h r11
+
+
+
+#define stack_size 10 //In words
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+ std r10, r11, sp[3]
+
+ //push return value pointers onto stack. Frees up r2
+ //Divide counter by 4
+ {stw iDataRet_p, sp[8] ; shr counter, counter, 2}
+
+ //Initilise MACC regsiters to zero
+ {ldc Acc0_h, 0; ldc Acc0_l, 0}
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+
+ bf counter, src_mrhf_fir_os_done_odd
+src_mrhf_fir_os_main_loop_odd:
+ //Constant for adding onto stuff. Gets updated later
+ {ldc step, 0x18; sub counter, counter, 1}
+
+ {ldw iData0, piData_p[0]; add piData_p, piData_p, 0x4} //Single word data load
+ ldd iCoef0, iCoef1, piCoefs_p[0] //Double word coef load
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+
+ //Now double word aligned for 64b goodness
+
+ ldd iData1, iData0, piData_p[0]
+ ldd iCoef0, iCoef1, piCoefs_p[1]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[2]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ ldd iData1, iData0, piData_p[1]
+ ldd iCoef0, iCoef1, piCoefs_p[3]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[4]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ ldd iData1, iData0, piData_p[2]
+ ldd iCoef0, iCoef1, piCoefs_p[5]
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+ ldd iCoef0, iCoef1, piCoefs_p[6]
+ maccs Acc0_h, Acc0_l, iData1, iCoef0
+ maccs Acc1_h, Acc1_l, iData1, iCoef1
+
+ add piData_p, piData_p, step //Back to word alignment
+
+ //Single word data load
+ {ldw iData0, piData_p[0]; add piData_p, piData_p, 0x4} // Increment pointer (will not be done until after this bundle)
+ ldd iCoef0, iCoef1, piCoefs_p[7] //Double word coef load
+ maccs Acc0_h, Acc0_l, iData0, iCoef0
+ maccs Acc1_h, Acc1_l, iData0, iCoef1
+
+ //Increment pointers and branch if still running
+
+ ldc step, 0x40
+ {add piCoefs_p, piCoefs_p, step; bt counter, src_mrhf_fir_os_main_loop_odd}
+
+
+src_mrhf_fir_os_done_odd:
+ //pop return value pointer from stack so we can use it to write back
+ {ldw iDataRet_p, sp[8]; ldc counter, 31} //Resuse counter (r3)
+
+
+ //Write back the two return values
+ lsats Acc0_h, Acc0_l, r3 //Saturate first
+ lsats Acc1_h, Acc1_l, r3
+ lextract iData0, Acc0_h, Acc0_l, counter, 32 //Extract
+ lextract iData1, Acc1_h, Acc1_l, counter, 32
+ stw iData0, iDataRet_p[1]
+ stw iData1, iDataRet_p[0]
+
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ ldd r10, r11, sp[3]
+ retsp stack_size
+
+.atmp_odd:
+ .size src_mrhf_fir_os_inner_loop_asm_odd, .atmp_odd-src_mrhf_fir_os_inner_loop_asm_odd
+ .align 8
+ .cc_bottom src_mrhf_fir_os_inner_loop_asm_odd.function
+
+ .set src_mrhf_fir_os_inner_loop_asm_odd.nstackwords, stack_size
+ .globl src_mrhf_fir_os_inner_loop_asm_odd.nstackwords
+ .set src_mrhf_fir_os_inner_loop_asm_odd.maxcores, 1
+ .globl src_mrhf_fir_os_inner_loop_asm_odd.maxcores
+ .set src_mrhf_fir_os_inner_loop_asm_odd.maxtimers,0
+ .globl src_mrhf_fir_os_inner_loop_asm_odd.maxtimers
+ .set src_mrhf_fir_os_inner_loop_asm_odd.maxchanends,0
+ .globl src_mrhf_fir_os_inner_loop_asm_odd.maxchanends
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.h
new file mode 100644
index 0000000..b90aac0
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_fir_os_inner_loop_asm.h
@@ -0,0 +1,10 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_
+#define SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_
+
+void src_mrhf_fir_os_inner_loop_asm_odd(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_fir_os_inner_loop_asm(int *piData, int *piCoefs, int iData[], int count);
+void src_mrhf_fir_os_inner_loop_asm_xs3(int *piData, int *piCoefs, int iData[], int count);
+
+#endif // SRC_MRHF_FIR_OS_INNER_LOOP_ASM_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.c b/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.c
new file mode 100644
index 0000000..ad0ccc4
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.c
@@ -0,0 +1,129 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// File: IntArithmetic.c
+//
+// Integer arithmetic implementation file for the ASRC
+//
+// Target: MS Windows
+// Version: 1.0
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+#include
+
+// Integer arithmetic includes
+#include "src_mrhf_int_arithmetic.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+// ==================================================================== //
+// Function: MACC //
+// Description: 32i x 32i -> 64i Multiply-Accumulate //
+// ==================================================================== //
+void MACC(__int64* plAcc, int ix, int iy)
+{
+ *plAcc += (__int64)ix * (__int64)iy;
+}
+
+// ==================================================================== //
+// Function: LMUL //
+// Description: 32i x 32i +32i + 32i -> 64i Multiply (and add) //
+// ==================================================================== //
+void LMUL(__int64* plAcc, int ix, int iy, int ic, int id)
+{
+ *plAcc = (__int64)ix * (__int64)iy;
+ *plAcc += (__int64)ic;
+ *plAcc += (__int64)id;
+}
+
+
+// ==================================================================== //
+// Function: LATS30 //
+// Description: Saturate 64i to 2^62-1, -2^62 //
+// ==================================================================== //
+void LSAT30(__int64 *plx)
+{
+ if(*plx > MAX_VAL64_30)
+ *plx = MAX_VAL64_30;
+ if(*plx < MIN_VAL64_30)
+ *plx = MIN_VAL64_30;
+}
+
+
+// ==================================================================== //
+// Function: EXT30 //
+// Description: Extracts bits [62-31] into 32i //
+// ==================================================================== //
+void EXT30(int *pr, __int64 lx)
+{
+ *pr = (int)(lx>>31);
+}
+
+
+// ==================================================================== //
+// Function: LATS29 //
+// Description: Saturate 64i to 2^61-1, -2^61 //
+// ==================================================================== //
+void LSAT29(__int64 *plx)
+{
+ if(*plx > MAX_VAL64_29)
+ *plx = MAX_VAL64_29;
+ if(*plx < MIN_VAL64_29)
+ *plx = MIN_VAL64_29;
+}
+
+
+// ==================================================================== //
+// Function: EXT29 //
+// Description: Extracts bits [61-30] into 32i //
+// ==================================================================== //
+void EXT29(int *pr, __int64 lx)
+{
+ *pr = (int)(lx>>30);
+}
+
+
+
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.h
new file mode 100644
index 0000000..182eb9c
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_int_arithmetic.h
@@ -0,0 +1,78 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_MRHF_INT_ARITHEMTIC_H_
+#define _SRC_MRHF_INT_ARITHEMTIC_H_
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+#define __int64 long long
+
+ // ===========================================================================
+ //
+ // Variables
+ //
+ // ===========================================================================
+
+
+ // ===========================================================================
+ //
+ // TypeDefs
+ //
+ // ===========================================================================
+ // To avoid C type definitions when including this file from assembler
+ #ifndef INCLUDE_FROM_ASM
+
+
+ // ===========================================================================
+ //
+ // Function prototypes
+ //
+ // ===========================================================================
+
+ // ==================================================================== //
+ // Function: MACC //
+ // Description: 32i x 32i -> 64i Multiply-Accumulate //
+ // ==================================================================== //
+ void MACC(__int64* plAcc, int ix, int iy);
+
+ // ==================================================================== //
+ // Function: LMUL //
+ // Description: 32i x 32i +32i + 32i -> 64i Multiply (and add) //
+ // ==================================================================== //
+ void LMUL(__int64* plAcc, int ix, int iy, int ic, int id);
+
+ // ==================================================================== //
+ // Function: LATS30 //
+ // Description: Saturate 64i to 2^62-1, -2^62 //
+ // ==================================================================== //
+ #define MAX_VAL64_30 (__int64)0x3FFFFFFFFFFFFFFF
+ #define MIN_VAL64_30 (__int64)0xC000000000000000
+ void LSAT30(__int64 *plx);
+
+ // ==================================================================== //
+ // Function: EXT30 //
+ // Description: Extracts bits [62-31] into 32i //
+ // ==================================================================== //
+ void EXT30(int *pr, __int64 lx);
+
+ // ==================================================================== //
+ // Function: LATS29 //
+ // Description: Saturate 64i to 2^61-1, -2^61 //
+ // ==================================================================== //
+ #define MAX_VAL64_29 (__int64)0x1FFFFFFFFFFFFFFF
+ #define MIN_VAL64_29 (__int64)0xE000000000000000
+ void LSAT29(__int64 *plx);
+
+ // ==================================================================== //
+ // Function: EXT29 //
+ // Description: Extracts bits [61-30] into 32i //
+ // ==================================================================== //
+ void EXT29(int *pr, __int64 lx);
+
+ #endif // nINCLUDE_FROM_ASM
+
+#endif // _SRC_MRHF_INT_ARITHEMTIC_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.S b/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.S
new file mode 100644
index 0000000..c4e5522
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.S
@@ -0,0 +1,231 @@
+// Copyright 2016-2023 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+
+#define FILTER_DEFS_ADFIR_PHASE_N_TAPS ((1920 / 128) + 1) // Number of taps per phase
+ .section .dp.data,"awd",@progbits
+ .text
+
+ .cc_top src_mrhf_spline_coeff_gen_inner_loop_asm.function
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm
+ .align 8
+ .type src_mrhf_spline_coeff_gen_inner_loop_asm,@function
+
+src_mrhf_spline_coeff_gen_inner_loop_asm:
+
+#define piPhase r0 //Arg 1
+#define piH r1 //Arg 2
+#define piADCoefs r2 //Arg 3
+#define n_taps r3 //Arg 4
+#define Acc1_l r4
+#define Acc1_h r5
+#define Acc0_l r6
+#define Acc0_h r7
+#define iData0 r8
+#define iData1 r9
+#define tmp r10
+#define piPhase0 r11 //This one remains constant - saves on shuffling
+
+// piPhase1 = piPhase0 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+// piPhase2 = piPhase1 + FILTER_DEFS_ADFIR_PHASE_N_TAPS;
+
+// Following assumes that - FILTER_DEFS_ADFIR_PHASE_N_TAPS = (1920 / 128 ) + 1 = 16
+#if ((FILTER_DEFS_ADFIR_PHASE_N_TAPS) != 16)
+#error "spline coeff asm hard coded to FILTER_DEFS_ADFIR_PHASE_N_TAPS = (1920 / 128 ) + 1 = 16"
+#endif
+
+//In 32b words
+#define stack_size 8
+
+.issue_mode dual
+ //Push registers
+ DUALENTSP_lu6 stack_size
+ std r4, r5, sp[0]
+ std r6, r7, sp[1]
+ std r8, r9, sp[2]
+ std r10, r11, sp[3]
+
+
+ {add piPhase0, piPhase, 0; shl n_taps, n_taps, 2} //offset needs to be * 4 because is int
+ add piPhase, piPhase, n_taps //PiPhase is PiPhase1 now - will swap between PiPhase1/2
+
+src_mrhf_spline_coeff_gen_main_loop:
+ //Loop = 0
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[0]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[0]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[0]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[0]
+
+ //Loop = 2
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[1]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[1]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[1]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[1]
+
+ //Loop = 4
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[2]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[2]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[2]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[2]
+
+ //Loop = 6
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[3]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[3]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[3]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[3]
+
+ //Loop = 8
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[4]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[4]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[4]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[4]
+
+ //Loop = 10
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[5]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[5]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[5]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[5]
+
+ //Loop = 12
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[6]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[6]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[6]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[6]
+
+ //Loop = 14
+ {ldc Acc0_h, 0; ldc Acc0_l, 0} //Initialise MACC registers to zero
+ {ldc Acc1_h, 0; ldc Acc1_l, 0}
+ ldd iData0, iData1, piPhase0[7]
+ ldw tmp, piH[2]
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[7]
+ {ldw tmp, piH[1]; add piPhase, piPhase, n_taps} //piPhase2 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ ldd iData0, iData1, piPhase[7]
+ {ldw tmp, piH[0]; sub piPhase, piPhase, n_taps} //piPhase1 now
+ maccs Acc0_h, Acc0_l, tmp, iData0
+ maccs Acc1_h, Acc1_l, tmp, iData1
+
+ std Acc0_h, Acc1_h, piADCoefs[7]
+src_mrhf_spline_coeff_gen_done:
+ //Pop registers
+ ldd r4, r5, sp[0]
+ ldd r6, r7, sp[1]
+ ldd r8, r9, sp[2]
+ ldd r10, r11, sp[3]
+ retsp stack_size
+
+.atmp:
+ .size src_mrhf_spline_coeff_gen_inner_loop_asm, .atmp-src_mrhf_spline_coeff_gen_inner_loop_asm
+ .align 8
+ .cc_bottom src_mrhf_spline_coeff_gen_inner_loop_asm.function
+
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm.nstackwords, stack_size
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm.nstackwords
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm.maxcores, 1
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm.maxcores
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm.maxtimers,0
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm.maxtimers
+ .set src_mrhf_spline_coeff_gen_inner_loop_asm.maxchanends,0
+ .globl src_mrhf_spline_coeff_gen_inner_loop_asm.maxchanends
diff --git a/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.h b/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.h
new file mode 100644
index 0000000..94b1584
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/src_mrhf_spline_coeff_gen_inner_loop_asm.h
@@ -0,0 +1,9 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_
+#define SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_
+
+void src_mrhf_spline_coeff_gen_inner_loop_asm(int *piPhase0, int *iH, int* piADCoefs, const int n_taps);
+void src_mrhf_spline_coeff_gen_inner_loop_asm_xs3(int *piPhase0, int *iH, int* piADCoefs, const int n_taps);
+
+#endif // SRC_MRHF_SPLINE_COEFF_GEN_INNER_LOOP_ASM_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.c b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.c
new file mode 100644
index 0000000..4f70e23
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.c
@@ -0,0 +1,497 @@
+// Copyright 2016-2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// Top level implementation file for the SSRC
+//
+// Target: MS Windows
+// Version: 1.0
+//
+// ===========================================================================
+// ===========================================================================
+
+
+// ===========================================================================
+//
+// Includes
+//
+// ===========================================================================
+#include
+#include
+#include
+
+// Integer arithmetic include
+#include "src_mrhf_int_arithmetic.h"
+// XMOS built in functions
+#include
+// SSRC include
+#include "src.h"
+
+// ===========================================================================
+//
+// Defines
+//
+// ===========================================================================
+
+
+// State init value
+#define SSRC_STATE_INIT 0
+
+// Random number generator / dithering
+#define SSRC_R_CONS 32767
+#define SSRC_R_BASE 1664525
+#define SSRC_RPDF_BITS_SHIFT 16 // Shift to select bits in pseudo-random number
+#define SSRC_RPDF_MASK 0x0000007F // For dithering at 24bits (in 2.30)
+#define SSRC_DATA24_MASK 0xFFFFFF00 // Mask for 24bits data (once rescaled to 1.31)
+#define SSRC_DITHER_BIAS 0xFFFFFFC0 // TPDF dither bias for compensating masking at 24bits but expressed in 2.30
+
+// Cycle counter
+#define SSRC_FIR_OS2_OVERHEAD_CYCLE_COUNT (15.0)
+#define SSRC_FIR_OS2_TAP_CYCLE_COUNT (1.875)
+#define SSRC_FIR_DS2_OVERHEAD_CYCLE_COUNT (15.0)
+#define SSRC_FIR_DS2_TAP_CYCLE_COUNT (2.125)
+#define SSRC_FIR_SYNC_OVERHEAD_CYCLE_COUNT (15.0)
+#define SSRC_FIR_SYNC_TAP_CYCLE_COUNT (2.125)
+#define SSRC_FIR_PP_OVERHEAD_CYCLE_COUNT (15.0 + SSRC_FIR_SYNC_OVERHEAD_CYCLE_COUNT)
+#define SSRC_FIR_PP_TAP_CYCLE_COUNT (2.125)
+#define SSRC_DITHER_SAMPLE_COUNT (20.0)
+
+
+
+// ===========================================================================
+//
+// Variables
+//
+// ===========================================================================
+
+SSRCFiltersIDs_t sFiltersIDs[SSRC_N_FS][SSRC_N_FS] = // Filter configuration table [Fsin][Fsout]
+{
+ { // Fsin = 44.1kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294}, // Fsout = 48kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_147}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_OS_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_OS_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_147} // Fsout = 192kHz
+ },
+ { // Fsin = 48kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_UP4844_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 48kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_160}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_OS_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_160}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_OS_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0} // Fsout = 192kHz
+ },
+ { // Fsin = 88.2kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_BL8848_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294}, // Fsout = 48kHz
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_147} // Fsout = 192kHz
+ },
+ { // Fsin = 96kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_BL9644_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 48kHz
+ {{FILTER_DEFS_SSRC_FIR_UP4844_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_160}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_UP_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0} // Fsout = 192kHz
+ },
+ { // Fsin = 176.4kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_DS_ID, FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_DS_ID, FILTER_DEFS_SSRC_FIR_BL8848_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294}, // Fsout = 48kHz
+ {{FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_BL17696_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_UPF_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS320_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_294} // Fsout = 192kHz
+ },
+ { // Fsin = 192kHz
+ // F1 F2 F3 Phase step
+ {{FILTER_DEFS_SSRC_FIR_DS_ID, FILTER_DEFS_SSRC_FIR_BL9644_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 44.1kHz
+ {{FILTER_DEFS_SSRC_FIR_DS_ID, FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 48kHz
+ {{FITLER_DEFS_SSRC_FIR_BL19288_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 88.2kHz
+ {{FILTER_DEFS_SSRC_FIR_BL_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0}, // Fsout = 96kHz
+ {{FILTER_DEFS_SSRC_FIR_UP192176_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_HS294_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_320}, // Fsout = 176.4kHz
+ {{FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_SSRC_FIR_NONE_ID, FILTER_DEFS_PPFIR_NONE_ID}, FILTER_DEFS_PPFIR_PHASE_STEP_0} // Fsout = 192kHz
+ }
+};
+
+
+
+// ===========================================================================
+//
+// Local Functions prototypes
+//
+// ===========================================================================
+
+
+SSRCReturnCodes_t SSRC_proc_F1_F2(ssrc_ctrl_t* pssrc_ctrl);
+SSRCReturnCodes_t SSRC_proc_F3(ssrc_ctrl_t* pssrc_ctrl);
+SSRCReturnCodes_t SSRC_proc_dither(ssrc_ctrl_t* pssrc_ctrl);
+
+
+// ===========================================================================
+//
+// Functions implementations
+//
+// ===========================================================================
+
+
+
+// ==================================================================== //
+// Function: SSRC_init //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Inits the SSRC passed as argument //
+// ==================================================================== //
+SSRCReturnCodes_t SSRC_init(ssrc_ctrl_t* pssrc_ctrl)
+{
+ SSRCFiltersIDs_t* psFiltersID;
+ FIRDescriptor_t* psFIRDescriptor;
+ PPFIRDescriptor_t* psPPFIRDescriptor;
+
+
+ // Check if state is allocated
+ if(pssrc_ctrl->psState == 0)
+ return SSRC_ERROR;
+
+ // Check if stack is allocated
+ if(pssrc_ctrl->piStack == 0)
+ return SSRC_ERROR;
+
+ // Check if valid Fsin and Fsout have been provided
+ if( (pssrc_ctrl->eInFs < SSRC_FS_MIN) || (pssrc_ctrl->eInFs > SSRC_FS_MAX))
+ return SSRC_ERROR;
+ if( (pssrc_ctrl->eOutFs < SSRC_FS_MIN) || (pssrc_ctrl->eOutFs > SSRC_FS_MAX))
+ return SSRC_ERROR;
+
+ // Check that number of input samples is allocated and is a multiple of 4
+ if(pssrc_ctrl->uiNInSamples == 0)
+ return SSRC_ERROR;
+ if((pssrc_ctrl->uiNInSamples & 0x3) != 0x0)
+ return SSRC_ERROR;
+
+ // Load filters ID and number of samples
+ psFiltersID = &sFiltersIDs[pssrc_ctrl->eInFs][pssrc_ctrl->eOutFs];
+
+ // Configure filters from filters ID and number of samples
+
+ // Filter F1
+ // ---------
+ psFIRDescriptor = &sSSRCFirDescriptor[psFiltersID->uiFID[SSRC_F1_INDEX]];
+ // Set number of input samples and input samples step
+ pssrc_ctrl->sFIRF1Ctrl.uiNInSamples = pssrc_ctrl->uiNInSamples;
+ pssrc_ctrl->sFIRF1Ctrl.uiInStep = pssrc_ctrl->uiNchannels;
+
+ // Set delay line base pointer
+ if( (psFiltersID->uiFID[SSRC_F1_INDEX] == FILTER_DEFS_SSRC_FIR_DS_ID) || (psFiltersID->uiFID[SSRC_F1_INDEX] == FILTER_DEFS_SSRC_FIR_OS_ID) )
+ pssrc_ctrl->sFIRF1Ctrl.piDelayB = pssrc_ctrl->psState->iDelayFIRShort;
+ else
+ pssrc_ctrl->sFIRF1Ctrl.piDelayB = pssrc_ctrl->psState->iDelayFIRLong;
+
+ // Set output buffer step
+ if(psFiltersID->uiFID[SSRC_F2_INDEX] == FILTER_DEFS_SSRC_FIR_OS_ID)
+ // F2 in use in over-sampling by 2 mode
+ pssrc_ctrl->sFIRF1Ctrl.uiOutStep = 2 * pssrc_ctrl->uiNchannels;
+ else
+ pssrc_ctrl->sFIRF1Ctrl.uiOutStep = pssrc_ctrl->uiNchannels;
+
+ // Call init for FIR F1
+ if(FIR_init_from_desc(&pssrc_ctrl->sFIRF1Ctrl, psFIRDescriptor) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+
+
+ // Filter F2
+ // ---------
+ psFIRDescriptor = &sSSRCFirDescriptor[psFiltersID->uiFID[SSRC_F2_INDEX]];
+
+ // Set number of input samples and input samples step
+ pssrc_ctrl->sFIRF2Ctrl.uiNInSamples = pssrc_ctrl->sFIRF1Ctrl.uiNOutSamples;
+ pssrc_ctrl->sFIRF2Ctrl.uiInStep = pssrc_ctrl->sFIRF1Ctrl.uiOutStep;
+
+ // Set delay line base pointer
+ if( (psFiltersID->uiFID[SSRC_F2_INDEX] == FILTER_DEFS_SSRC_FIR_DS_ID) || (psFiltersID->uiFID[SSRC_F2_INDEX] == FILTER_DEFS_SSRC_FIR_OS_ID) )
+ pssrc_ctrl->sFIRF2Ctrl.piDelayB = pssrc_ctrl->psState->iDelayFIRShort;
+ else
+ pssrc_ctrl->sFIRF2Ctrl.piDelayB = pssrc_ctrl->psState->iDelayFIRLong;
+
+ // Set output buffer step
+ pssrc_ctrl->sFIRF2Ctrl.uiOutStep = pssrc_ctrl->uiNchannels;
+
+ // Call init for FIR F1
+ if(FIR_init_from_desc(&pssrc_ctrl->sFIRF2Ctrl, psFIRDescriptor) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+
+
+ // Filter F3
+ // ---------
+ psPPFIRDescriptor = &sPPFirDescriptor[psFiltersID->uiFID[SSRC_F3_INDEX]];
+
+ // Set number of input samples and input samples step
+ if(psFiltersID->uiFID[SSRC_F2_INDEX] == FILTER_DEFS_SSRC_FIR_NONE_ID)
+ pssrc_ctrl->sPPFIRF3Ctrl.uiNInSamples = pssrc_ctrl->sFIRF1Ctrl.uiNOutSamples;
+ else
+ pssrc_ctrl->sPPFIRF3Ctrl.uiNInSamples = pssrc_ctrl->sFIRF2Ctrl.uiNOutSamples;
+ pssrc_ctrl->sPPFIRF3Ctrl.uiInStep = pssrc_ctrl->sFIRF2Ctrl.uiOutStep;
+
+ // Set delay line base pointer
+ pssrc_ctrl->sPPFIRF3Ctrl.piDelayB = pssrc_ctrl->psState->iDelayPPFIR;
+
+ // Set output buffer step
+ pssrc_ctrl->sPPFIRF3Ctrl.uiOutStep = pssrc_ctrl->uiNchannels;
+
+ // Set phase step
+ pssrc_ctrl->sPPFIRF3Ctrl.uiPhaseStep = psFiltersID->uiPPFIRPhaseStep;
+
+ // Call init for PPFIR F3
+ if(PPFIR_init_from_desc(&pssrc_ctrl->sPPFIRF3Ctrl, psPPFIRDescriptor) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+
+
+ // Setup input/output buffers
+ // --------------------------
+ // We first set them all to stack base (some will be overwritten depending on configuration)
+
+ // F1 input is never from stack, so don't set it
+ pssrc_ctrl->sFIRF2Ctrl.piIn = pssrc_ctrl->piStack;
+ pssrc_ctrl->sPPFIRF3Ctrl.piIn = pssrc_ctrl->piStack;
+
+ pssrc_ctrl->sFIRF1Ctrl.piOut = pssrc_ctrl->piStack;
+ pssrc_ctrl->sFIRF2Ctrl.piOut = pssrc_ctrl->piStack;
+ // F3 output is never to stack, so don't set it
+
+
+ // Finally setup pointer to output buffer that needs to be modified for data output depending on filter configuration
+ // Also set pointer to number of output samples
+ if(psFiltersID->uiFID[SSRC_F3_INDEX] != FILTER_DEFS_PPFIR_NONE_ID)
+ {
+ // F3 is in use so take output from F3 output
+ pssrc_ctrl->ppiOut = &pssrc_ctrl->sPPFIRF3Ctrl.piOut;
+ pssrc_ctrl->puiNOutSamples = &pssrc_ctrl->sPPFIRF3Ctrl.uiNOutSamples;
+ }
+ else
+ {
+ if(psFiltersID->uiFID[SSRC_F2_INDEX] != FILTER_DEFS_SSRC_FIR_NONE_ID)
+ {
+ // F3 not in use but F2 in use, take output from F2 output
+ pssrc_ctrl->ppiOut = &pssrc_ctrl->sFIRF2Ctrl.piOut;
+ pssrc_ctrl->puiNOutSamples = &pssrc_ctrl->sFIRF2Ctrl.uiNOutSamples;
+ }
+ else
+ {
+ // F3 and F2 not in use but F1 in use or not. Set output from F1 output
+ // Note that we also set it to F1 output, even if F1 is not in use (Fsin = Fsout case, this won't cause any problem)
+ pssrc_ctrl->ppiOut = &pssrc_ctrl->sFIRF1Ctrl.piOut;
+
+ if(psFiltersID->uiFID[SSRC_F1_INDEX] != FILTER_DEFS_SSRC_FIR_NONE_ID)
+ // F1 in use so set number of output sample pointer to number of output sample field of F1
+ pssrc_ctrl->puiNOutSamples = &pssrc_ctrl->sFIRF1Ctrl.uiNOutSamples;
+ else
+ // F1 not in use so set number of output sample pointer to number of input sample field
+ pssrc_ctrl->puiNOutSamples = &pssrc_ctrl->uiNInSamples;
+ }
+ }
+
+ // Call sync function
+ if(SSRC_sync(pssrc_ctrl) != SSRC_NO_ERROR)
+ return SSRC_ERROR;
+
+ return SSRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: SSRC_sync //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Syncs the SSRC passed as argument //
+// ==================================================================== //
+SSRCReturnCodes_t SSRC_sync(ssrc_ctrl_t* pssrc_ctrl)
+{
+ // Sync the FIR and PPFIR
+ if(FIR_sync(&pssrc_ctrl->sFIRF1Ctrl) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+ if(FIR_sync(&pssrc_ctrl->sFIRF2Ctrl) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+ if(PPFIR_sync(&pssrc_ctrl->sPPFIRF3Ctrl) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+
+ // Reset random seeds to initial values
+ pssrc_ctrl->psState->uiRndSeed = pssrc_ctrl->uiRndSeedInit;
+
+ return SSRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: SSRC_proc //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Processes the SSRC passed as argument //
+// ==================================================================== //
+#if (XCC_VERSION_MAJOR < 1402) //Beyond 14.2.0 we have proper function pointer support for C
+#pragma stackfunction 64 //Generous stack allocation (probably needs just a handful through F1_F2, ASM etc).
+#endif
+SSRCReturnCodes_t SSRC_proc(ssrc_ctrl_t* pssrc_ctrl)
+{
+ // Setup input / output buffers
+ // ----------------------------
+ pssrc_ctrl->sFIRF1Ctrl.piIn = pssrc_ctrl->piIn;
+ *(pssrc_ctrl->ppiOut) = pssrc_ctrl->piOut;
+
+ // F1 and F2 process
+ // -----------------
+ if( SSRC_proc_F1_F2(pssrc_ctrl) != SSRC_NO_ERROR)
+ return SSRC_ERROR;
+
+ // F3 process
+ // ----------
+ if( SSRC_proc_F3(pssrc_ctrl) != SSRC_NO_ERROR)
+ return SSRC_ERROR;
+
+ // Dither process
+ // --------------
+ if( SSRC_proc_dither(pssrc_ctrl) != SSRC_NO_ERROR)
+ return SSRC_ERROR;
+
+ return SSRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: SSRC_proc_F1_F2 //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Processes F1 and F2 for a channel //
+// ==================================================================== //
+SSRCReturnCodes_t SSRC_proc_F1_F2(ssrc_ctrl_t* pssrc_ctrl)
+{
+ int* piIn = pssrc_ctrl->piIn;
+ int* piOut = pssrc_ctrl->piOut;
+ unsigned int ui;
+
+
+ // Check if F1 is disabled, in which case we just copy input to output as all filters are disabled
+ if(pssrc_ctrl->sFIRF1Ctrl.eEnable == FIR_OFF)
+ {
+ // F1 is not enabled, which means that we are in 1:1 rate, so just copy input to output
+ for(ui = 0; ui < pssrc_ctrl->uiNInSamples * pssrc_ctrl->uiNchannels; ui+= pssrc_ctrl->uiNchannels)
+ piOut[ui] = piIn[ui];
+
+ return SSRC_NO_ERROR;
+ }
+
+ // F1 is enabled, so call F1
+ __attribute__((fptrgroup("MRHF_G1")))
+ FIRReturnCodes_t ret = pssrc_ctrl->sFIRF1Ctrl.pvProc((int *)&pssrc_ctrl->sFIRF1Ctrl);
+ if(ret != FIR_NO_ERROR)
+ return SSRC_ERROR;
+
+
+ // Check if F2 is enabled
+ if(pssrc_ctrl->sFIRF2Ctrl.eEnable == FIR_ON)
+ {
+ // F2 is enabled, so call F2
+ __attribute__((fptrgroup("MRHF_G1")))
+ FIRReturnCodes_t ret = pssrc_ctrl->sFIRF2Ctrl.pvProc((int *)&pssrc_ctrl->sFIRF2Ctrl);
+ if(ret != FIR_NO_ERROR)
+ return SSRC_ERROR;
+ }
+
+ return SSRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: SSRC_proc_F3 //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Processes F3 for a channel //
+// ==================================================================== //
+SSRCReturnCodes_t SSRC_proc_F3(ssrc_ctrl_t* pssrc_ctrl)
+{
+
+ // Check if F3 is enabled
+ if(pssrc_ctrl->sPPFIRF3Ctrl.eEnable == FIR_ON)
+ {
+ // F3 is enabled, so call F3
+ if(PPFIR_proc(&pssrc_ctrl->sPPFIRF3Ctrl) != FIR_NO_ERROR)
+ return SSRC_ERROR;
+ }
+
+ return SSRC_NO_ERROR;
+}
+
+
+// ==================================================================== //
+// Function: SSRC_proc_dither //
+// Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+// Return values: SSRC_NO_ERROR on success //
+// SSRC_ERROR on failure //
+// Description: Processes dither for a channel //
+// ==================================================================== //
+SSRCReturnCodes_t SSRC_proc_dither(ssrc_ctrl_t* pssrc_ctrl)
+{
+ int* piData;
+ unsigned int uiR;
+ int iDither;
+ __int64_t i64Acc;
+ unsigned int ui;
+
+
+ // Apply dither if required
+ if(pssrc_ctrl->uiDitherOnOff == SSRC_DITHER_ON)
+ {
+ // Get data buffer
+ piData = pssrc_ctrl->piOut;
+ // Get random seed
+ uiR = pssrc_ctrl->psState->uiRndSeed;
+
+ // Loop through samples
+ for(ui = 0; ui < *(pssrc_ctrl->puiNOutSamples) * pssrc_ctrl->uiNchannels; ui += pssrc_ctrl->uiNchannels)
+ {
+ // Compute dither sample (TPDF)
+ iDither = SSRC_DITHER_BIAS;
+
+ uiR = (unsigned int)(SSRC_R_BASE * uiR);
+ uiR = (unsigned int)(SSRC_R_CONS + uiR);
+ iDither += ((uiR>>SSRC_RPDF_BITS_SHIFT) & SSRC_RPDF_MASK);
+
+ uiR = (unsigned int)(SSRC_R_BASE * uiR);
+ uiR = (unsigned int)(SSRC_R_CONS + uiR);
+ iDither += ((uiR>>SSRC_RPDF_BITS_SHIFT) & SSRC_RPDF_MASK);
+
+ //TODO - optimise this and remove IntArithmetic
+ // Use MACC instruction to saturate and dither + signal
+ i64Acc = ((__int64_t)iDither <<32); // On XMOS this is not necessary, just load dither in the top word of the ACC register
+ MACC(&i64Acc, piData[ui], 0x7FFFFFFF);
+
+ // Saturate to 31 bits
+ LSAT30(&i64Acc);
+
+ // Extract 32bits result
+ EXT30(&piData[ui], i64Acc);
+
+ // Mask to 24bits
+ piData[ui] &= SSRC_DATA24_MASK;
+
+ }
+
+ // Write random seed back
+ pssrc_ctrl->psState->uiRndSeed = uiR;
+ }
+
+ return SSRC_NO_ERROR;
+}
diff --git a/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.h b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.h
new file mode 100644
index 0000000..5662fef
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.h
@@ -0,0 +1,201 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// ===========================================================================
+// ===========================================================================
+//
+// Top level definition file for the SSRC
+//
+// Target: MS Windows
+// Version: 1.0
+//
+// ===========================================================================
+// ===========================================================================
+
+#ifndef _SRC_MRHF_SSRC_H_
+#define _SRC_MRHF_SSRC_H_
+
+ // ===========================================================================
+ //
+ // Includes
+ //
+ // ===========================================================================
+ #include "src_mrhf_fir.h"
+ #include "src_mrhf_filter_defs.h"
+ #include "src.h"
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+ // General defines
+ // ---------------
+ #define SSRC_STACK_LENGTH_MULT (SSRC_N_CHANNELS * SSRC_N_IN_SAMPLES) // Multiplier for stack length (stack length = this value x the number of input samples to process)
+
+
+ // Parameter values
+ // ----------------
+ #define SSRC_DITHER_OFF 0
+ #define SSRC_DITHER_ON 1
+ #define SSRC_DITHER_ON_OFF_MIN SSRC_DITHER_OFF
+ #define SSRC_DITHER_ON_OFF_MAX SSRC_DITHER_ON
+
+
+
+
+ // ===========================================================================
+ //
+ // Defines
+ //
+ // ===========================================================================
+
+
+ // ===========================================================================
+ //
+ // TypeDefs
+ //
+ // ===========================================================================
+
+ // To avoid C type definitions when including this file from assembler
+ #ifndef INCLUDE_FROM_ASM
+
+ // SSRC Return Codes
+ // -----------------
+ typedef enum _SSRCReturnCodes
+ {
+ SSRC_NO_ERROR = 0,
+ SSRC_ERROR = 1
+ } SSRCReturnCodes_t;
+
+
+ // Sampling rate codes
+ // -------------------
+ typedef enum _SSRCFs
+ {
+ SSRC_FS_44 = 0, // Fs = 44.1kHz code
+ SSRC_FS_48 = 1, // Fs = 48kHz code
+ SSRC_FS_88 = 2, // Fs = 88.2kHz code
+ SSRC_FS_96 = 3, // Fs = 96kHz code
+ SSRC_FS_176 = 4, // Fs = 176.4kHz code
+ SSRC_FS_192 = 5, // Fs = 192kHz code
+ } SSRCFs_t;
+ #define SSRC_N_FS (SSRC_FS_192 + 1)
+ #define SSRC_FS_MIN SSRC_FS_44
+ #define SSRC_FS_MAX SSRC_FS_192
+
+
+ // SSRC Filters IDs structure
+ // --------------------------
+ #define SSRC_F1_INDEX 0
+ #define SSRC_F2_INDEX 1
+ #define SSRC_F3_INDEX 2
+ #define SSRC_N_F (SSRC_F3_INDEX + 1)
+
+ typedef struct _SSRCFiltersIDs
+ {
+ unsigned int uiFID[SSRC_N_F];
+ unsigned int uiPPFIRPhaseStep;
+ } SSRCFiltersIDs_t;
+
+
+ // SSRC State structure
+ // --------------------
+ typedef struct _SSRCState
+ {
+ long long pad_to_64b_alignment;
+ int iDelayFIRLong[2 * FILTER_DEFS_FIR_MAX_TAPS_LONG]; // Doubled length for circular buffer simulation
+ int iDelayFIRShort[2 * FILTER_DEFS_FIR_MAX_TAPS_SHORT]; // Doubled length for circular buffer simulation
+ int iDelayPPFIR[2 * FILTER_DEFS_PPFIR_PHASE_MAX_TAPS]; // Doubled length for circular buffer simulation
+ unsigned int uiRndSeed; // Dither random seeds current values
+
+ } ssrc_state_t;
+
+
+ // SSRC Control structure
+ // ----------------------
+ typedef struct _SSRCCtrl
+ {
+#ifdef __XC__
+ long long pad_to_64b_alignment; //Force compiler to 64b align
+ unsigned int uiNchannels; // Number of channels in this instance
+ int* unsafe piIn; // Input buffer pointer (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNInSamples; // Number of input samples to process in one call to the processing function
+ SSRCFs_t eInFs; // Input sampling rate code
+ int* unsafe piOut; // Output buffer poin ter (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int* unsafe puiNOutSamples; // Pointer to number of output samples produced during last call to the processing function
+ SSRCFs_t eOutFs; // Output sampling rate code
+
+ int* unsafe * unsafe ppiOut; // Pointer to (PP)FIR output data pointer for last filter in the chain
+
+ FIRCtrl_t sFIRF1Ctrl; // F1 FIR controller
+ FIRCtrl_t sFIRF2Ctrl; // F2 FIR controller
+ PPFIRCtrl_t sPPFIRF3Ctrl; // F3 PPFIR controller
+
+ unsigned int uiDitherOnOff; // Dither on/off flag
+ unsigned int uiRndSeedInit; // Dither random seed initial value
+
+ ssrc_state_t* unsafe psState; // Pointer to state structure
+ int* unsafe piStack; // Pointer to stack buffer
+#else
+ long long pad_to_64b_alignment; //Force compiler to 64b align
+ unsigned int uiNchannels; // Number of channels in this instance
+
+ int* piIn; // Input buffer pointer (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int uiNInSamples; // Number of input samples to process in one call to the processing function
+ SSRCFs_t eInFs; // Input sampling rate code
+ int* piOut; // Output buffer poin ter (PCM, 32bits, 2 channels time domain interleaved data)
+ unsigned int* puiNOutSamples; // Pointer to number of output samples produced during last call to the processing function
+ SSRCFs_t eOutFs; // Output sampling rate code
+
+ int* * ppiOut; // Pointer to (PP)FIR output data pointer for last filter in the chain
+
+ FIRCtrl_t sFIRF1Ctrl; // F1 FIR controller
+ FIRCtrl_t sFIRF2Ctrl; // F2 FIR controller
+ PPFIRCtrl_t sPPFIRF3Ctrl; // F3 PPFIR controller
+
+ unsigned int uiDitherOnOff; // Dither on/off flag
+ unsigned int uiRndSeedInit; // Dither random seed initial value
+
+ ssrc_state_t* psState; // Pointer to state structure
+ int* piStack; // Pointer to stack buffer
+#endif
+ } ssrc_ctrl_t;
+
+
+ // ===========================================================================
+ //
+ // Function prototypes
+ //
+ // ===========================================================================
+
+ // ==================================================================== //
+ // Function: SSRC_init //
+ // Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+ // Return values: SSRC_NO_ERROR on success //
+ // SSRC_ERROR on failure //
+ // Description: Inits the SSRC passed as argument //
+ // ==================================================================== //
+ SSRCReturnCodes_t SSRC_init(ssrc_ctrl_t* pssrc_ctrl);
+
+ // ==================================================================== //
+ // Function: SSRC_sync //
+ // Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+ // Return values: SSRC_NO_ERROR on success //
+ // SSRC_ERROR on failure //
+ // Description: Syncs the SSRC passed as argument //
+ // ==================================================================== //
+ SSRCReturnCodes_t SSRC_sync(ssrc_ctrl_t* pssrc_ctrl);
+
+ // ==================================================================== //
+ // Function: SSRC_proc //
+ // Arguments: ssrc_ctrl_t *pssrc_ctrl: Ctrl strct. //
+ // Return values: SSRC_NO_ERROR on success //
+ // SSRC_ERROR on failure //
+ // Description: Processes the SSRC passed as argument //
+ // ==================================================================== //
+ SSRCReturnCodes_t SSRC_proc(ssrc_ctrl_t* pssrc_ctrl);
+
+ #endif // nINCLUDE_FROM_ASM
+
+#endif // _SRC_MRHF_SSRC_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_checks.h b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_checks.h
new file mode 100644
index 0000000..c2c21e8
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_checks.h
@@ -0,0 +1,37 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef _SRC_MRHF_SSRC_CHECKS_H_
+#define _SRC_MRHF_SSRC_CHECKS_H_
+
+#include "src_mrhf_ssrc.h"
+
+//Compile time checks on SRC configuration defines
+#if (SSRC_N_CHANNELS % SSRC_N_INSTANCES != 0)
+#error "Each core must process an integer number of channels. Check SSRC_N_CHANNELS & SSRC_N_INSTANCES."
+#endif
+#if (SSRC_N_CHANNELS < SSRC_N_INSTANCES)
+#error "Each instance (logical core) must process at least one channel. Check SSRC_N_CHANNELS & SSRC_N_INSTANCES."
+#endif
+#if (SSRC_N_INSTANCES < 1)
+#error "Number of instances (logical cores) must be at least 1. Check SSRC_N_INSTANCES."
+#endif
+#if (SSRC_N_CHANNELS < 1)
+#error "Number of audio channels must be at least 1. Check SSRC_N_CHANNELS."
+#endif
+#if (SSRC_N_IN_SAMPLES < 4)
+#error "Number of input audio samples in each block must be at least 4. Check SSRC_N_IN_SAMPLES."
+#endif
+#if ((SSRC_N_IN_SAMPLES & (SSRC_N_IN_SAMPLES - 1)) != 0)
+#error "Number of input audio samples in each block must be a power of two. Check SSRC_N_IN_SAMPLES."
+#endif
+#if (SSRC_N_OUT_IN_RATIO_MAX < 5)
+#warning "SRC buffering configured so that fs out <= 4 * fs in"
+#endif
+#if (SSRC_N_OUT_IN_RATIO_MAX < 3)
+#warning "SRC buffering configured so that fs out <= 2 * fs in"
+#endif
+#if (SSRC_N_OUT_IN_RATIO_MAX < 1)
+#warning "SRC buffering configured so that fs out <= fs in"
+#endif
+
+#endif // _SRC_MRHF_SSRC_CHECKS_H_
diff --git a/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_wrapper.c b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_wrapper.c
new file mode 100644
index 0000000..886f47d
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc_wrapper.c
@@ -0,0 +1,70 @@
+// Copyright 2016-2021 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+// General includes
+#include
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+
+// SSRC includes
+#include "src.h"
+
+static void ssrc_error(int code)
+{
+ debug_printf("SSRC_proc Error code %d\n", code);
+ delay_milliseconds(1); //Allow xscope to display message before quit
+ _Exit(code);
+}
+
+
+void ssrc_init(const fs_code_t sr_in, const fs_code_t sr_out, ssrc_ctrl_t *ssrc_ctrl,
+ const unsigned n_channels_per_instance, const unsigned n_in_samples, const dither_flag_t dither_on_off)
+{
+ SSRCReturnCodes_t ret_code;
+ unsigned ui;
+
+ //Check to see if n_channels_per_instance, n_in_samples are reasonable
+ if ((n_in_samples & 0x1) || (n_in_samples < 4)) ssrc_error(100);
+ if (n_channels_per_instance < 1) ssrc_error(101);
+
+ for(ui = 0; ui < n_channels_per_instance; ui++)
+ {
+ // Set number of channels per instance
+ ssrc_ctrl[ui].uiNchannels = n_channels_per_instance;
+
+ // Set number of samples
+ ssrc_ctrl[ui].uiNInSamples = n_in_samples;
+
+ // Set dither flag and random seeds
+ ssrc_ctrl[ui].uiDitherOnOff = dither_on_off;
+ ssrc_ctrl[ui].uiRndSeedInit = 12345 * ui; //Some randomish numbers. Value not critical
+
+ // Set the sample rate codes
+ ssrc_ctrl[ui].eInFs = (int)sr_in;
+ ssrc_ctrl[ui].eOutFs = (int)sr_out;
+
+ // Init SSRC instances
+ ret_code = SSRC_init(&ssrc_ctrl[ui]) ;
+ if(ret_code != SSRC_NO_ERROR) ssrc_error(ret_code);
+ }
+}
+
+unsigned ssrc_process(int in_buff[], int out_buff[], ssrc_ctrl_t *ssrc_ctrl){
+
+ unsigned ui;
+ unsigned n_samps_out;
+
+ // Get the number of channels per instance from first channel
+ const unsigned n_channels_per_instance = ssrc_ctrl[0].uiNchannels;
+
+ for(ui = 0; ui < n_channels_per_instance; ui++)
+ {
+ ssrc_ctrl[ui].piIn = in_buff + ui;
+ ssrc_ctrl[ui].piOut = out_buff + ui;
+ if(SSRC_proc(&ssrc_ctrl[ui]) != SSRC_NO_ERROR) ssrc_error(0);
+ n_samps_out = (*ssrc_ctrl[ui].puiNOutSamples);
+ }
+ return n_samps_out;
+}
diff --git a/lib_src/lib_src/src/multirate_hifi/use_vpu.h b/lib_src/lib_src/src/multirate_hifi/use_vpu.h
new file mode 100644
index 0000000..de3348d
--- /dev/null
+++ b/lib_src/lib_src/src/multirate_hifi/use_vpu.h
@@ -0,0 +1,13 @@
+// Copyright 2024 XMOS LIMITED.
+// This Software is subject to the terms of the XMOS Public Licence: Version 1.
+#ifndef SRC_USE_VPU
+ #if defined(__XS3A__)
+ #define SRC_USE_VPU 1
+ #else
+ #define SRC_USE_VPU 0
+ #endif
+#else
+ #if(defined(__XS2A__) && (SRC_USE_VPU != 0))
+ #error VPU optimisation in lib_src is only available on XS3 (xcore.ai) architecture
+ #endif
+#endif
diff --git a/lib_src/requirements.txt b/lib_src/requirements.txt
new file mode 100644
index 0000000..4d53f60
--- /dev/null
+++ b/lib_src/requirements.txt
@@ -0,0 +1,6 @@
+# python_version 3.10
+# pip_version 23.*
+
+-e ./python
+
+# Files are specified in setup.py
\ No newline at end of file
diff --git a/lib_src/settings.yml b/lib_src/settings.yml
new file mode 100644
index 0000000..541c33d
--- /dev/null
+++ b/lib_src/settings.yml
@@ -0,0 +1,17 @@
+---
+project: lib_src
+title: SAMPLE RATE CONVERSION
+version: 2.5.0
+
+documentation:
+ exclude_patterns_path: doc/exclude_patterns.inc
+ doxygen_projects:
+ lib_xcore_math:
+ doxyfile_path: doc/Doxyfile.inc
+ pdfs:
+ doc/programming_guide/index:
+ pdf_title: "{{title}} - Programming Guide"
+ pdf_filename: "{{project}}_programming_guide_v{{version}}"
+ doc/python/_build/rst/allPlots:
+ pdf_title: "{{title}} - \\\\ Performance Characterisation for SSRC ASRC DS3 and OS3"
+ pdf_filename: "{{project}}_performance_characterisation_v{{version}}"
diff --git a/lib_uart/.gitignore b/lib_uart/.gitignore
new file mode 100644
index 0000000..ca6e511
--- /dev/null
+++ b/lib_uart/.gitignore
@@ -0,0 +1,17 @@
+**/.build*/*
+**/bin/*
+*.o
+*.xe
+*.vcd
+*.s
+*.xi
+*.i
+*.a
+**/_build/
+**/run_*.log
+**/pdf/*
+**/html/*
+**/.settings/*
+*.pyc
+test_results.csv
+xscope_out.xmt
\ No newline at end of file
diff --git a/lib_uart/CHANGELOG.rst b/lib_uart/CHANGELOG.rst
new file mode 100644
index 0000000..3e14b45
--- /dev/null
+++ b/lib_uart/CHANGELOG.rst
@@ -0,0 +1,75 @@
+UART Library Change Log
+=======================
+
+3.1.0
+-----
+
+ * RESOLVED: Correct the documentation for the write() method of
+ uart_tx_buffered_if
+ * RESOLVED: Added calls to ready_to_transmit() to the uart_tx_buffered
+ component
+ * RESOLVED: Improved the uart_tx_buffered so that it can now drive at full
+ data rate without clock drift. Before it was limited to about 0.5% less than
+ the baud rate
+
+3.0.3
+-----
+
+ * REMOVED: forward references to app notes
+
+3.0.2
+-----
+
+ * CHANGE: Update to source code license and copyright
+
+3.0.1
+-----
+
+ * CHANGE: Update fast rx and tx to match API prototypes & fix port directions
+ * RESOLVED: Fixed order of ports in api calls from example program
+
+3.0.0
+-----
+
+ * CHANGE: Restructued version
+
+ * Changes to dependencies:
+
+ - lib_gpio: Added dependency 1.0.0
+
+ - lib_logging: Added dependency 2.0.0
+
+ - lib_xassert: Added dependency 2.0.0
+
+2.3.2
+-----
+
+ * CHANGE: Increment version for XPD release. Several minor docs bugs fixed.
+
+2.3.1
+-----
+
+ * CHANGE: Tidied up uart_fast and targetted demo at L16 sliceKIT
+
+3.0.0
+-----
+
+ * CHANGE: Major change to generic UART tx/rx components to use new xC features
+ with different api.
+
+2.3.0
+-----
+
+ * ADDED: RS485 component and apps
+
+2.2.0
+-----
+
+ * CHANGE: Updated documents for xSOFTip requirements
+ * ADDED: Metainfo and XPD items
+
+2.1.0
+-----
+
+ * CHANGE: Documentation Updates
+
diff --git a/lib_uart/LICENSE.txt b/lib_uart/LICENSE.txt
new file mode 100644
index 0000000..dcc68d8
--- /dev/null
+++ b/lib_uart/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2014-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 UART library software
diff --git a/lib_uart/README.rst b/lib_uart/README.rst
new file mode 100644
index 0000000..25eb243
--- /dev/null
+++ b/lib_uart/README.rst
@@ -0,0 +1,99 @@
+UART library
+============
+
+Summary
+-------
+
+A software defined, industry-standard, UART (Universal Asynchronous
+Receiver/Transmitter) library
+that allows you to control a UART serial connection via the
+xCORE GPIO ports. This library is controlled
+via C using the XMOS multicore extensions.
+
+Features
+........
+
+.. sidebysidelist::
+
+ * UART receive and transmit
+ * Supports speeds up to 10MBit/s
+ * Half-duplex mode (applicable to RS485)
+ * Efficient multi-uart mode for implementing multiple connections
+
+
+Resource Usage
+..............
+
+.. resusage::
+
+
+ * - configuration: Standard TX
+ - globals:
+ - locals: output_gpio_if i_gpio_tx; interface uart_tx_if i_tx;
+ - fn: uart_tx(i_tx, null,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_tx);
+ - pins: 1
+ - ports: 1
+
+ * - configuration: Standard TX (buffered)
+ - globals:
+ - locals: output_gpio_if i_gpio_tx; interface uart_tx_buffered_if i_tx;
+ - fn: uart_tx_buffered(i_tx, null, 5,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_tx);
+ - pins: 1
+ - ports: 1
+
+ * - configuration: Standard RX
+ - globals:
+ - locals: input_gpio_if i_gpio_rx; interface uart_rx_if i_rx;
+ - fn: uart_rx(i_rx, null, 5,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_rx);
+ - pins: 1
+ - ports: 1
+
+ * - configuration: Fast/streaming TX
+ - globals: out port p_uart_tx = XS1_PORT_1A;
+ - locals: streaming chan c;
+ - fn: uart_tx_streaming(p_uart_tx, c, 100);
+ - pins: 1
+ - ports: 1
+
+ * - configuration: Fast/streaming RX
+ - globals: in port p_uart_tx = XS1_PORT_1A;
+ - locals: streaming chan c;
+ - fn: uart_rx_streaming(p_uart_tx, c, 100);
+ - pins: 1
+ - ports: 1
+
+ * - configuration: Multi-UART TX (8 UARTs)
+ - globals: out buffered port:8 p_uart_tx = XS1_PORT_8B;
+ - locals: interface multi_uart_tx_if i_tx; chan c_tx;
+ - fn: multi_uart_tx(c_tx, i_tx, p_uart_tx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ - pins: 8
+ - ports: 1
+ - cores: 1
+
+ * - configuration: Multi-UART RX (8 UARTs)
+ - globals: in buffered port:32 p_uart_rx = XS1_PORT_8B;
+ - locals: interface multi_uart_rx_if i_rx; streaming chan c_rx;
+ - fn: multi_uart_rx(c_rx, i_rx, p_uart_rx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ - pins: 8
+ - ports: 1
+ - cores: 1
+
+ * - configuration: Half Duplex
+ - globals: port p_uart = XS1_PORT_1A;
+ - locals: interface uart_tx_buffered_if i_tx; uart_rx_if i_rx; uart_control_if i_ctl;
+ - fn: uart_half_duplex(i_tx, i_rx, i_ctl, null, 10, 10, 115200, UART_PARITY_NONE, 8, 1, p_uart);
+ - pins: 1
+ - ports: 1
+ - cores: 1
+
+
+Software version and dependencies
+.................................
+
+.. libdeps::
diff --git a/lib_uart/examples/multi_uart_demo/.cproject b/lib_uart/examples/multi_uart_demo/.cproject
new file mode 100644
index 0000000..12b7015
--- /dev/null
+++ b/lib_uart/examples/multi_uart_demo/.cproject
@@ -0,0 +1,968 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/examples/multi_uart_demo/.project b/lib_uart/examples/multi_uart_demo/.project
new file mode 100644
index 0000000..827b688
--- /dev/null
+++ b/lib_uart/examples/multi_uart_demo/.project
@@ -0,0 +1,90 @@
+
+
+ multi_uart_demo
+
+
+
+
+
+ com.xmos.cdt.core.ProjectInfoSyncBuilder
+
+
+
+
+ com.xmos.cdt.core.LegacyProjectCheckerBuilder
+
+
+
+
+ com.xmos.cdt.core.ModulePathBuilder
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\\\\|\\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_uart/examples/multi_uart_demo/LICENSE.txt b/lib_uart/examples/multi_uart_demo/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/examples/multi_uart_demo/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/examples/multi_uart_demo/Makefile b/lib_uart/examples/multi_uart_demo/Makefile
new file mode 100644
index 0000000..d313ab6
--- /dev/null
+++ b/lib_uart/examples/multi_uart_demo/Makefile
@@ -0,0 +1,31 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+XCC_FLAGS = -g -O3 -save-temps -DMUART_RX_CHAN_COUNT=8 -DMUART_TX_CHAN_COUNT=8
+
+# The USED_MODULES variable lists other module used by the application.
+USED_MODULES = lib_logging lib_uart
+
+#=============================================================================
+# 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
diff --git a/lib_uart/examples/multi_uart_demo/src/main.xc b/lib_uart/examples/multi_uart_demo/src/main.xc
new file mode 100644
index 0000000..f1bfe2b
--- /dev/null
+++ b/lib_uart/examples/multi_uart_demo/src/main.xc
@@ -0,0 +1,65 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+
+// These ports are configures assuming the multi-UART slice is
+// connected to the STAR slot. For other slots the ports will
+// need to be changed.
+in buffered port:32 p_uart_rx = XS1_PORT_8A;
+out buffered port:8 p_uart_tx = XS1_PORT_8B;
+in port p_uart_clk = XS1_PORT_1F;
+
+clock clk_uart = XS1_CLKBLK_4;
+
+void loopback(streaming chanend c_rx, client multi_uart_rx_if i_rx,
+ chanend c_tx, client multi_uart_tx_if i_tx)
+{
+ size_t slot;
+
+ // Configure each task with a chanend
+ i_rx.init(c_rx);
+ i_tx.init(c_tx);
+
+ while (1) {
+ select {
+ case multi_uart_data_ready(c_rx, slot):
+ uint8_t data;
+ if (i_rx.read(slot, data) == UART_RX_VALID_DATA) {
+ if (i_tx.is_slot_free(slot)) {
+ i_tx.write(slot, data);
+ }
+ else {
+ debug_printf("Warning: TX buffer overflow on channel %d\n",
+ slot);
+ }
+ }
+ break;
+ }
+ }
+}
+
+int main(void)
+{
+ interface multi_uart_rx_if i_rx;
+ streaming chan c_rx;
+ chan c_tx;
+ interface multi_uart_tx_if i_tx;
+
+ // Set the rx and tx lines to be clocked off the clk_uart clock block
+ configure_in_port(p_uart_rx, clk_uart);
+ configure_out_port(p_uart_tx, clk_uart, 0);
+
+ // Configure an external clock for the clk_uart clock block
+ configure_clock_src(clk_uart, p_uart_clk);
+ start_clock(clk_uart);
+
+ // Start the rx/tx tasks and the application task
+ par {
+ multi_uart_rx(c_rx, i_rx, p_uart_rx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ multi_uart_tx(c_tx, i_tx, p_uart_tx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ loopback(c_rx, i_rx, c_tx, i_tx);
+ }
+ return 0;
+}
diff --git a/lib_uart/examples/uart_demo/.cproject b/lib_uart/examples/uart_demo/.cproject
new file mode 100644
index 0000000..5735ef8
--- /dev/null
+++ b/lib_uart/examples/uart_demo/.cproject
@@ -0,0 +1,634 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/examples/uart_demo/.project b/lib_uart/examples/uart_demo/.project
new file mode 100644
index 0000000..9d02d0c
--- /dev/null
+++ b/lib_uart/examples/uart_demo/.project
@@ -0,0 +1,95 @@
+
+
+ uart_demo
+
+
+
+
+
+ com.xmos.cdt.core.ModulePathBuilder
+
+
+
+
+ com.xmos.cdt.core.BuildMarkersBuilder
+
+
+
+
+ com.xmos.cdt.core.ProjectCheckerBuilder
+
+
+
+
+ com.xmos.cdt.core.ProjectInfoSyncBuilder
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_uart/examples/uart_demo/.xproject b/lib_uart/examples/uart_demo/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/examples/uart_demo/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/examples/uart_demo/LICENSE.txt b/lib_uart/examples/uart_demo/LICENSE.txt
new file mode 100644
index 0000000..8b30cb4
--- /dev/null
+++ b/lib_uart/examples/uart_demo/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2014-2017, 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 UART library software
diff --git a/lib_uart/examples/uart_demo/Makefile b/lib_uart/examples/uart_demo/Makefile
new file mode 100644
index 0000000..74bab7a
--- /dev/null
+++ b/lib_uart/examples/uart_demo/Makefile
@@ -0,0 +1,32 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+XCC_FLAGS = -O2 -g -save-temps
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart
+
+#=============================================================================
+# 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
diff --git a/lib_uart/examples/uart_demo/README.rst b/lib_uart/examples/uart_demo/README.rst
new file mode 100644
index 0000000..be1d0e7
--- /dev/null
+++ b/lib_uart/examples/uart_demo/README.rst
@@ -0,0 +1,11 @@
+Generic Uart Loopback Example
+=============================
+
+:scope: Example
+:description: Application to demonstrate module_uart_rx and module_uart_tx running looped back on a single Slicekti core board.
+:keywords: UART, demo
+:boards: XA-SKC-L2
+
+This application instantiates both the module_uart_rx and module_uart_tx components looped back to one another to demonstrate basic usage. It will be necessary to setup two connections on the 0.1" testpoints on the Slicekti core board prior to running the demo.
+
+
diff --git a/lib_uart/examples/uart_demo/src/main.xc b/lib_uart/examples/uart_demo/src/main.xc
new file mode 100644
index 0000000..a156dd6
--- /dev/null
+++ b/lib_uart/examples/uart_demo/src/main.xc
@@ -0,0 +1,56 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+#include
+
+// Port declarations
+port p_uart_rx = on tile[0] : XS1_PORT_1A;
+port p_uart_tx = on tile[0] : XS1_PORT_1B;
+
+#define BAUD_RATE 115200
+#define RX_BUFFER_SIZE 64
+
+/* This function performs the main "application" that outputs and reads
+ some bytes over UART */
+void app(client uart_tx_if uart_tx, client uart_rx_if uart_rx)
+{
+ uint8_t byte;
+ printstrln("Test started");
+ byte = 0;
+ for (size_t i = 0; i < 20; i++) {
+ printstr("Echo 10 bytes... ");
+ for(size_t j = 0; j < 10; j++) {
+ uart_tx.write(byte);
+ byte = byte + 1;
+ }
+ for(size_t j = 0; j < 10; j++) {
+ printhex(uart_rx.wait_for_data_and_read());
+ }
+ }
+ printstrln(". Done.");
+}
+
+void test() { while (1);}
+
+/* "main" function that sets up two uarts and the application */
+int main() {
+ interface uart_rx_if i_rx;
+ interface uart_tx_if i_tx;
+ input_gpio_if i_gpio_rx;
+ output_gpio_if i_gpio_tx[1];
+ par {
+ on tile[0]: test();
+ on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
+ on tile[0]: uart_tx(i_tx, null,
+ BAUD_RATE, UART_PARITY_NONE, 8, 1,
+ i_gpio_tx[0]);
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_uart_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, RX_BUFFER_SIZE,
+ BAUD_RATE, UART_PARITY_NONE, 8, 1,
+ i_gpio_rx);
+ on tile[0]: app(i_tx, i_rx);
+ }
+ return 0;
+}
diff --git a/lib_uart/examples/uart_streaming_demo/LICENSE.txt b/lib_uart/examples/uart_streaming_demo/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/examples/uart_streaming_demo/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/examples/uart_streaming_demo/Makefile b/lib_uart/examples/uart_streaming_demo/Makefile
new file mode 100644
index 0000000..74bab7a
--- /dev/null
+++ b/lib_uart/examples/uart_streaming_demo/Makefile
@@ -0,0 +1,32 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+XCC_FLAGS = -O2 -g -save-temps
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart
+
+#=============================================================================
+# 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
diff --git a/lib_uart/examples/uart_streaming_demo/src/main.xc b/lib_uart/examples/uart_streaming_demo/src/main.xc
new file mode 100644
index 0000000..941d3e6
--- /dev/null
+++ b/lib_uart/examples/uart_streaming_demo/src/main.xc
@@ -0,0 +1,46 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+#include
+
+// Port declarations
+in port p_uart_rx = on tile[0] : XS1_PORT_1A;
+out port p_uart_tx = on tile[0] : XS1_PORT_1B;
+
+/* This function performs the main "application" that outputs and reads
+ some bytes over UART */
+void app(streaming chanend c_tx, streaming chanend c_rx)
+{
+ uint8_t byte;
+ printstrln("Test started");
+ byte = 0;
+ for (size_t i = 0; i < 20; i++) {
+ printstr("Echo 10 bytes... ");
+ for(size_t j = 0; j < 10; j++) {
+ uart_tx_streaming_write_byte(c_tx, byte);
+ byte = byte + 1;
+ }
+ for(size_t j = 0; j < 10; j++) {
+ uart_rx_streaming_read_byte(c_rx, byte);
+ printhex(byte);
+ }
+ }
+ printstrln(". Done.");
+}
+
+
+#define TICKS_PER_BIT 20
+
+/* "main" function that sets up two uarts and the application */
+int main() {
+ streaming chan c_rx;
+ streaming chan c_tx;
+ par {
+ on tile[0]: uart_tx_streaming(p_uart_tx, c_tx, TICKS_PER_BIT);
+ on tile[0]: uart_rx_streaming(p_uart_rx, c_rx, TICKS_PER_BIT);
+ on tile[0]: app(c_tx, c_rx);
+ }
+ return 0;
+}
diff --git a/lib_uart/lib_uart/.cproject b/lib_uart/lib_uart/.cproject
new file mode 100644
index 0000000..5ed09bc
--- /dev/null
+++ b/lib_uart/lib_uart/.cproject
@@ -0,0 +1,1040 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+ -f .makefile
+ all
+ true
+ true
+ true
+
+
+ xmake
+ -f .makefile
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/lib_uart/.makefile b/lib_uart/lib_uart/.makefile
new file mode 100644
index 0000000..87b347b
--- /dev/null
+++ b/lib_uart/lib_uart/.makefile
@@ -0,0 +1,8 @@
+all:
+ @echo "** Module only - only builds as part of application **"
+
+
+clean:
+ @echo "** Module only - only builds as part of application **"
+
+
diff --git a/lib_uart/lib_uart/.project b/lib_uart/lib_uart/.project
new file mode 100644
index 0000000..6ba76c8
--- /dev/null
+++ b/lib_uart/lib_uart/.project
@@ -0,0 +1,100 @@
+
+
+ lib_uart
+
+
+
+
+
+ com.xmos.cdt.core.LegacyProjectCheckerBuilder
+
+
+
+
+ com.xmos.cdt.core.ModulePathBuilder
+
+
+
+
+ com.xmos.cdt.core.ProjectCheckerBuilder
+
+
+
+
+ com.xmos.cdt.core.BuildMarkersBuilder
+
+
+
+
+ com.xmos.cdt.core.ProjectInfoSyncBuilder
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?children?=?name?=entry\\\\\\\|\\\|\|?name?=outputEntries\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ -f .makefile
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
diff --git a/lib_uart/lib_uart/LICENSE.txt b/lib_uart/lib_uart/LICENSE.txt
new file mode 100644
index 0000000..dcc68d8
--- /dev/null
+++ b/lib_uart/lib_uart/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2014-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 UART library software
diff --git a/lib_uart/lib_uart/api/multi_uart_impl.h b/lib_uart/lib_uart/api/multi_uart_impl.h
new file mode 100644
index 0000000..b86f14b
--- /dev/null
+++ b/lib_uart/lib_uart/api/multi_uart_impl.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#ifndef __MULTI_UART_IMPL_H__
+#define __MULTI_UART_IMPL_H__
+
+[[distributable]]
+void multi_uart_rx_buffer(server interface multi_uart_rx_if i,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits);
+
+void multi_uart_rx_pins(streaming chanend c,
+ in buffered port:32 p,
+ unsigned num_uarts);
+
+[[distributable]]
+void multi_uart_tx_buffer(server interface multi_uart_tx_if i_tx,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits);
+
+void multi_uart_tx_pins(chanend c, out buffered port:8 p, size_t clock_rate);
+
+#define multi_uart_rx(c, i, p, n, clock_rate, baud, parity, bits, stop_bits) \
+ {par { \
+ [[distribute]] multi_uart_rx_buffer(i, clock_rate, baud, parity, bits, stop_bits); \
+ multi_uart_rx_pins(c, p, n); \
+ } \
+ }
+
+#define multi_uart_tx(c, i, p, n, clock_rate, baud, parity, bits, stop_bits) \
+ {par { \
+ [[distribute]] multi_uart_tx_buffer(i, clock_rate, baud, parity, bits, stop_bits); \
+ multi_uart_tx_pins(c, p, clock_rate); \
+ } \
+ }
+
+#pragma select handler
+inline void multi_uart_data_ready(streaming chanend c_rx, size_t &index) {
+ char x;
+ c_rx :> x;
+ index = x;
+}
+
+#endif // __MULTI_UART_IMPL_H__
diff --git a/lib_uart/lib_uart/api/uart.h b/lib_uart/lib_uart/api/uart.h
new file mode 100644
index 0000000..195976d
--- /dev/null
+++ b/lib_uart/lib_uart/api/uart.h
@@ -0,0 +1,597 @@
+// Copyright (c) 2014-2018, XMOS Ltd, All rights reserved
+
+#ifndef _uart_h_
+#define _uart_h_
+#include
+#include
+#include
+#include
+
+#ifdef __XC__
+
+/** Type representing the parity of a UART */
+typedef enum uart_parity_t {
+ UART_PARITY_EVEN = 0, ///< Even parity.
+ UART_PARITY_ODD = 1, ///< Odd parity.
+ UART_PARITY_NONE ///< No parity.
+} uart_parity_t;
+
+/** UART configuration interface.
+ *
+ * This interface enables dynamic reconfiguration of a UART. It is used by
+ * several UART components to provide a method of configuration.
+ */
+typedef interface uart_config_if {
+ /** Set the baud rate of a UART.
+ */
+ void set_baud_rate(unsigned baud_rate);
+
+ /** Set the parity of a UART.
+ */
+ void set_parity(enum uart_parity_t parity);
+
+ /** Set number of stop bits used by a UART.
+ */
+ void set_stop_bits(unsigned stop_bits);
+
+ /** Set number of bits per byte used by a UART (must be in the range [1-8])
+ */
+ void set_bits_per_byte(unsigned bits_per_byte);
+} uart_config_if;
+
+
+/*---------------------- Receiver API ---------------------------*/
+
+/** UART RX interface.
+ *
+ * This interface provides clients access to buffer uart receive
+ * functionality.
+ */
+typedef interface uart_rx_if {
+ /** Get a byte from the receive buffer.
+ *
+ * This function should be called after receiving a data_ready()
+ * notification. If these is no data in the buffer (for example, this
+ * function is called before receiving a notification) then the return
+ * value is undefined.
+ */
+ [[clears_notification]] uint8_t read(void);
+
+ /** Notification that data is in the receive buffer.
+ *
+ * This notification function can be selected on by the client and
+ * will event when the is data in the receive buffer. After this
+ * notification the client should call the read() function.
+ */
+ [[notification]] slave void data_ready(void);
+
+ /** Returns whether there is data in the buffer.
+ */
+ int has_data();
+} uart_rx_if;
+
+extends client interface uart_rx_if : {
+
+ /** Get a byte from the receive buffer.
+ *
+ * This function will wait until there is data in the receive buffer
+ * of the uart and then fetch that data. On getting the data, it
+ * will clear the notification flag on the interface.
+ */
+ inline uint8_t wait_for_data_and_read(client uart_rx_if i) {
+ if (!i.has_data()) {
+ select {
+ case i.data_ready():
+ break;
+ }
+ }
+ return i.read();
+ }
+}
+
+/** UART RX.
+ *
+ * This function runs a uart receiver.
+ * Bytes received by the this task are buffered.
+ * When the buffer is full further incoming bytes of data will be dropped.
+ * The function never returns and will run indefinitely.
+ *
+ * \param i_data the interface connection allowing clients to
+ * receive data
+ * \param i_config the interface connection allowing clients to
+ * reconfigure the UART
+ * \param buffer_size the size of the buffer
+ * \param baud the initial baud rate
+ * \param parity the initial parity setting
+ * \param bits_per_byte the initial number of bits per byte (must be
+ * in the range [1-8])
+ * \param stop_bits the initial number of stop bits
+ * \param p_rxd the gpio interface to input data on
+ */
+[[combinable]]
+void uart_rx(server interface uart_rx_if i_data,
+ server interface uart_config_if ?i_config,
+ const static unsigned buffer_size,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client input_gpio_if p_rxd);
+
+/** Fast/Streaming UART RX.
+ *
+ * This function implements a fast UART. The UART configuration is
+ * fixed to a single start bit, 8 bits per byte, and a single stop bit.
+ * On a 62.5 MIPS thread this function should be able to keep up with a 10
+ * MBit UART sustained (provided that the streaming channel can keep up
+ * with it too).
+ *
+ * This function does not return.
+ *
+ * \param p input port, 1 bit port on which data comes in.
+ *
+ * \param c output streaming channel to connect to the application.
+ *
+ * \param ticks_per_bit number of clock ticks between bits.
+ * This number depends on the clock that is
+ * attached to port p. If it is the
+ * 100 Mhz reference clock then this value
+ * should be at least 10.
+ */
+void uart_rx_streaming(in port p, streaming chanend c, int ticks_per_bit);
+
+/** Receive a byte from a streaming UART receiver.
+ *
+ * This function receives a byte from the fast/streaming UART component. It is
+ * "select handler" so can be used within a select e.g.
+ *
+ \verbatim
+ uint8_t byte;
+ size_t index;
+ select {
+ case uart_rx_streaming_receive_byte(c, byte):
+ // use sample and index here...
+ ...
+ break;
+ ...
+ \endverbatim
+ *
+ * The case in this select will fire when the UART component has data ready.
+ *
+ * \param c chanend connected to the streaming UART receiver component
+ * \param data This reference parameter gets set with the incoming
+ * data
+ */
+#pragma select handler
+void uart_rx_streaming_read_byte(streaming chanend c, uint8_t &data);
+
+/*---------------------- Transmitter API ---------------------------*/
+
+/** UART transmit interface.
+ *
+ * This interface provides functions for transmitting data on an
+ * unbuffered UART.
+ */
+typedef interface uart_tx_if {
+
+ /** Write a byte to a UART.
+ *
+ * This function writes a byte of data to a UART. It will output
+ * immediately and block until the data is output.
+ *
+ * \param data The data to write.
+ */
+ void write(uint8_t data);
+} uart_tx_if;
+
+
+/** UART transmitter.
+ *
+ * This function implements an unbuffered UART transmitter.
+ *
+ * \param i_data interface enabling client to send data
+ * \param i_config interface enabling client to configure the UART
+ * \param baud the initial baud rate
+ * \param parity the initial parity setting
+ * \param bits_per_byte the initial number of bits per byte (must be in
+ * the range [1-8])
+ * \param stop_bits the initial number of stop bits
+ * \param p_txd the gpio interface to output data on
+
+ */
+[[distributable]]
+void uart_tx(server interface uart_tx_if i_data,
+ server interface uart_config_if ?i_config,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client output_gpio_if p_txd);
+
+/** UART transmit interface (buffered).
+ *
+ * This interface contains functions to write to a buffered UART and
+ * manage the buffering.
+ *
+ */
+typedef interface uart_tx_buffered_if {
+
+ /** Write a byte to a UART.
+ *
+ * This function writes a byte of data to a UART. It will place the
+ * data in the output buffer queue to write and then return. If the
+ * buffer is full then the data is discarded.
+ *
+ * \param data The data to write.
+ *
+ * \returns Zero if the write was successful. If the buffer was
+ * full then the function will return 1 and the data is
+ * discarded.
+ */
+ [[clears_notification]]
+ int write(uint8_t data);
+
+ /** Ready to transmit notification.
+ *
+ * This notification will occur when the UART is ready to transmit (either
+ * intially or after a write() call when there is space in the buffer).
+ */
+ [[notification]]
+ slave void ready_to_transmit(void);
+
+ /** Get avaiable buffer size.
+ *
+ * This function returns the number of bytes remaining in the buffer that
+ * can be filled by write() calls.
+ */
+ size_t get_available_buffer_size(void);
+} uart_tx_buffered_if;
+
+/** UART transmitter (buffered).
+ *
+ * This function implements a UART transmitter. Data sent to the task will
+ * be placed in a buffer and sent at the rate of the UART.
+ *
+ * \param i_data interface enabling client to send data
+ * \param i_config interface enabling client to configure the UART
+ * \param buffer_size the size of the transmit buffer in bytes
+ * \param baud the initial baud rate
+ * \param parity the initial parity setting
+ * \param bits_per_byte the initial number of bits per byte (must be in
+ * the range [1-8])
+ * \param stop_bits the initial number of stop bits
+ * \param p_txd the gpio interface to output data on
+ */
+[[combinable]]
+void uart_tx_buffered(server interface uart_tx_buffered_if i_data,
+ server interface uart_config_if ?i_config,
+ const static unsigned buffer_size,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client output_gpio_if p_txd);
+
+/** Fast/Streaming UART TX.
+ *
+ * This function implements a fast UART transmitter.
+ * It needs an unbuffered 1-bit
+ * port, a streaming channel end, and a number of port-clocks to wait
+ * between bits. It receives a start bit, 8 bits, and a stop bit, and
+ * transmits the 8 bits over the streaming channel end as a single token.
+ * On a 62.5 MIPS thread this function should be able to keep up with a 10
+ * MBit UART sustained (provided that the streaming channel can keep up
+ * with it too).
+ *
+ * This function does not return.
+ *
+ * \param p input port, 1 bit port on which data comes in.
+ *
+ * \param c output streaming channel to connect to the application.
+ *
+ * \param ticks_per_bit number of clock ticks between bits.
+ * This number depends on the clock that is
+ * attached to port p. If it is the
+ * 100 Mhz reference clock then this value
+ * should be at least 10.
+ */
+void uart_tx_streaming(out port p, streaming chanend c, int ticks_per_bit);
+
+/** Write a byte to a streaming UART transmitter.
+ *
+ * This function writes a
+ * \param c chanend connected to the streaming UART Tx component
+ * \param data The data to send.
+ */
+void uart_tx_streaming_write_byte(streaming chanend c, uint8_t data);
+
+
+/*---------------------- Half Duplex API ---------------------------*/
+
+/** Type representing the mode (direction) of a uart. */
+typedef enum uart_half_duplex_mode_t {
+ UART_RX_MODE, ///< Uart is in receive mode.
+ UART_TX_MODE ///< Uart is in transmit mode.
+} uart_half_duplex_mode_t;
+
+/** Interface to control the mode of a half-duplex UART */
+typedef interface uart_control_if {
+ /** Set the mode of the UART.
+ *
+ * This function can be used to control whether the UART is in send or
+ * receive mode.
+ */
+ void set_mode(uart_half_duplex_mode_t mode);
+} uart_control_if;
+
+/** Half duplex UART.
+ *
+ * This function implements a UART that can either transmit or receive on
+ * the same wire. The application explicitly control whether the component
+ * is in transmit or receive mode.
+ *
+ * \param i_tx interface for transmitting data
+ * \param i_rx interface for receiving data
+ * \param i_control interface for controlling the direction of the UART
+ * \param i_config interface for configuring the UART
+ * \param tx_buf_length the size of the transmit buffer (in bytes)
+ * \param rx_buf_length the size of the receive buffer (in bytes)
+ * \param baud baud rate
+ * \param parity the parity of the UART
+ * \param bits_per_byte bits per byte (must be in the range [1-8])
+ * \param stop_bits The number of stop bits
+ * \param p_uart the 1-bit port to send/recieve the UART signals.
+ */
+void uart_half_duplex(server interface uart_tx_buffered_if i_tx,
+ server interface uart_rx_if i_rx,
+ server interface uart_control_if i_control,
+ server interface uart_config_if ?i_config,
+ const static unsigned tx_buf_length,
+ const static unsigned rx_buf_length,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ port p_uart);
+
+/*---------------------- Multi-UART API ---------------------------*/
+
+typedef enum multi_uart_read_result_t {
+ UART_RX_VALID_DATA, ///< Data received is valid.
+ UART_RX_INVALID_DATA ///< Data received is not valid.
+} multi_uart_read_result_t;
+
+/** Multi-UART receive interface */
+interface multi_uart_rx_if {
+
+ /** Initialize the multi-UART RX component.
+ *
+ * \param c The chanend connected to the multi-UART RX task
+ */
+ void init(streaming chanend c);
+
+ /** Read a byte for the next UART with ready data.
+ *
+ * This function will read out a byte from the next UART with data available.
+ * If several UARTS have data available then the data is read out in a
+ * round-robin fashion.
+ *
+ * \param index This index of the UART to read from
+ * \param data The data byte read
+ * \returns An enum type that indicates if the data is valid
+ */
+ enum multi_uart_read_result_t read(size_t index, uint8_t &data);
+
+ /** Pause the multi-UART RX component for reconfiguration.
+ *
+ * This call will stop the mulit-UART component so that the UARTs can be
+ * reconfigured.
+ */
+ void pause(void);
+
+ /** Restart the multi-UART RX component after reconfiguration.
+ *
+ * This call will restart the multi-UART component.
+ */
+ void restart(void);
+
+ /** Set the baud rate of a UART.
+ *
+ * This call will set the baud rate of one of the UARTs.
+ * The rate must be a divisor of the clock rate of the underlying
+ * clock used for the component.
+ *
+ * \param index The index of the UART to configure
+ * \param baud_rate The required baud rate
+ */
+ void set_baud_rate(size_t index, unsigned baud_rate);
+
+ /** Set parity of a UART.
+ *
+ * This call will set the parity of one of the UARTs.
+ * The rate must be a divisor of the clock rate of the underlying
+ * clock used for the component.
+ *
+ * \param index The index of the UART to configure.
+ * \param parity The required parity
+ */
+ void set_parity(size_t index, enum uart_parity_t parity);
+
+ /** Set the number of stop bits of a UART.
+ *
+ * This call will set the number of stop bits of one of the UARTs.
+ *
+ * \param index The index of the UART
+ * \param stop_bits The number of stop bits
+ */
+ void set_stop_bits(size_t index, unsigned stop_bits);
+
+ /** Set the number of bit per byte of a UART.
+ *
+ * This call will set the number of stop bits of one of the UARTs.
+ *
+ * \param index The index of the UART
+ * \param bits_per_byte The number of bits per byte (must be in the
+ * range [1-8])
+ */
+ void set_bits_per_byte(size_t index, unsigned bits_per_byte);
+} [[sametile]];
+
+typedef interface multi_uart_rx_if multi_uart_rx_if;
+
+#pragma select handler
+inline void multi_uart_data_ready(streaming chanend c_rx, size_t &index);
+
+/** Multi-UART receiver.
+ *
+ * This function implements multiple UART receivers on a multi-bit port. The
+ * UARTS all have the same baud rate.
+ * The parity, bits per byte and number of stop bits
+ * is the same for all UARTs and cannot be changed dynamically.
+ *
+ * \param c a chanend used internally for high speed communication
+ * \param i the interface for getting data from the task
+ * \param p the multibit port
+ * \param clk a clock block for the component to use. This needs
+ * to be set to run of the reference clock (the default
+ * state for clock blocks)
+ * \param num_uarts the number of uarts to run (must be less than or
+ * equal to the width of \p p)
+ * \param clock_rate_hz the clock rate in Hz
+ * \param baud baud rate
+ * \param parity the parity of the UART
+ * \param bits_per_byte bits per byte (must be in the range [1-8])
+ * \param stop_bits number of stop bits
+ */
+void multi_uart_rx(streaming chanend c,
+ server interface multi_uart_rx_if i,
+ in buffered port:32 p, clock clk,
+ size_t num_uarts,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits);
+
+/** Multi-UART transmit interface */
+interface multi_uart_tx_if {
+
+ /** Initialize the multi-UART TX component.
+ *
+ * \param c The chanend connected to the multi-UART TX task
+ */
+ void init(chanend c);
+
+ /** Check whether transmit slot is free.
+ *
+ * This function checks whether the application can write data to
+ * a specific UART.
+ *
+ * \param index The index of the UART to check
+ * \returns non-zero if the slot is free (i.e. data can be sent)
+ */
+ int is_slot_free(size_t index);
+
+ /** Write to a UART.
+ *
+ * This function writes a byte of data to a UART. This byte will be buffered
+ * to send. If the transmit buffer for
+ * that UART is not available then the data is ignored (use
+ * is_tx_slot_free() to determine availability).
+ *
+ * \param index The index of the UART to write to
+ * \param data The data to write
+ */
+ void write(size_t index, uint8_t data);
+
+ /** Pause the multi-UART RX component for reconfiguration.
+ *
+ * This call will stop the mulit-UART component so that the UARTs can be
+ * reconfigured.
+ */
+ void pause(void);
+
+ /** Restart the multi-UART RX component after reconfiguration.
+ *
+ * This call will restart the multi-UART component.
+ */
+ void restart(void);
+
+ /** Set the baud rate of a UART.
+ *
+ * This call will set the baud rate of one of the UARTs.
+ * The rate must be a divisor of the clock rate of the underlying
+ * clock used for the component.
+ *
+ * \param index The index of the UART to configure.
+ * \param baud_rate The required baud rate
+ */
+ void set_baud_rate(size_t index, unsigned baud_rate);
+
+ /** Set parity of a UART.
+ *
+ * This call will set the parity of one of the UARTs.
+ * The rate must be a divisor of the clock rate of the underlying
+ * clock used for the component.
+ *
+ * \param index The index of the UART to configure.
+ * \param parity The required parity
+ */
+ void set_parity(size_t index, enum uart_parity_t parity);
+
+ /** Set the number of stop bits of a UART.
+ *
+ * This call will set the number of stop bits of one of the UARTs.
+ *
+ * \param index The index of the UART
+ * \param stop_bits The number of stop bits
+ */
+ void set_stop_bits(size_t index, unsigned stop_bits);
+
+ /** Set the number of bit per byte of a UART.
+ *
+ * This call will set the number of stop bits of one of the UARTs.
+ *
+ * \param index The index of the UART
+ * \param bits_per_byte The number of bits per byte (must be in the
+ * range [1-8])
+ */
+ void set_bits_per_byte(size_t index, unsigned bits_per_byte);
+} [[sametile]];
+
+typedef interface multi_uart_tx_if multi_uart_tx_if;
+
+/** Multi-UART transmitter.
+ *
+ * This function implements multiple UART transmiiters on a multi-bit port. The
+ * UARTS all have the same baud rate.
+ * The parity, bits per byte and number of stop bits
+ * is the same for all UARTs and cannot be changed dynamically.
+ *
+ * \param c a chanend used internally for high speed communication
+ * \param i the interface for sending data to the task
+ * \param p the multibit port
+ * \param num_uarts the number of uarts to run (must be less than or
+ * equal to the width of \p p)
+ * \param clock_rate_hz the clock rate in Hz
+ * \param baud baud rate
+ * \param parity the parity of the UART
+ * \param bits_per_byte bits per byte (must be in the range [1-8])
+ * \param stop_bits number of stop bits
+ */
+void multi_uart_tx(chanend c,
+ server interface multi_uart_tx_if i,
+ out port p,
+ size_t num_uarts,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits);
+
+
+#include "multi_uart_impl.h"
+
+#endif // __XC__
+
+#endif /* _uart_h_ */
diff --git a/lib_uart/lib_uart/api/uart_half_duplex.h b/lib_uart/lib_uart/api/uart_half_duplex.h
new file mode 100644
index 0000000..dedb24f
--- /dev/null
+++ b/lib_uart/lib_uart/api/uart_half_duplex.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#ifndef __uart_half_duplex_h__
+#define __uart_half_duplex_h__
+
+enum uart_tx_state {
+ WAITING_FOR_DATA,
+ OUTPUTTING_DATA_BIT,
+ OUTPUTTING_PARITY_BIT,
+ OUTPUTTING_STOP_BIT,
+ TX_INACTIVE
+};
+enum uart_rx_state {
+ WAITING_FOR_INPUT,
+ WAITING_FOR_HIGH,
+ TESTING_START_BIT,
+ INPUTTING_DATA_BIT,
+ INPUTTING_PARITY_BIT,
+ INPUTTING_STOP_BIT,
+ RX_INACTIVE
+};
+
+#endif // __uart_half_duplex_h__
diff --git a/lib_uart/lib_uart/doc/rst/images/Makefile b/lib_uart/lib_uart/doc/rst/images/Makefile
new file mode 100644
index 0000000..4b45cfb
--- /dev/null
+++ b/lib_uart/lib_uart/doc/rst/images/Makefile
@@ -0,0 +1,22 @@
+ODGS = $(wildcard *.odg)
+PDFS = $(ODGS:.odg=.pdf)
+
+all: $(PDFS)
+ @echo PDFs created
+
+_uncropped:
+ mkdir _uncropped
+
+_uncropped/%.pdf: %.odg | _uncropped
+ soffice -env:UserInstallation=file:///home/$(USER)/.libreoffice-alt --headless --convert-to pdf $< --outdir _uncropped
+
+%.pdf: _uncropped/%.pdf
+ pdfcrop $< $@
+
+wavedrom:
+ WaveDromEditor source data_sequence.js png data_sequence.png
+
+clean:
+ -rm $(PDFS)
+ -rm _uncropped/*.pdf
+ -rmdir _uncropped
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_fast.odg b/lib_uart/lib_uart/doc/rst/images/connect_fast.odg
new file mode 100644
index 0000000..c52814b
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_fast.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_fast.pdf b/lib_uart/lib_uart/doc/rst/images/connect_fast.pdf
new file mode 100644
index 0000000..88e9e10
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_fast.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.odg b/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.odg
new file mode 100644
index 0000000..a192629
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.pdf b/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.pdf
new file mode 100644
index 0000000..044dfc5
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_half_duplex.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_multi.odg b/lib_uart/lib_uart/doc/rst/images/connect_multi.odg
new file mode 100644
index 0000000..7671f95
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_multi.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_multi.pdf b/lib_uart/lib_uart/doc/rst/images/connect_multi.pdf
new file mode 100644
index 0000000..69f9e58
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_multi.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_rx.odg b/lib_uart/lib_uart/doc/rst/images/connect_rx.odg
new file mode 100644
index 0000000..41541d2
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_rx.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_rx.pdf b/lib_uart/lib_uart/doc/rst/images/connect_rx.pdf
new file mode 100644
index 0000000..c5db789
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_rx.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_standard.odg b/lib_uart/lib_uart/doc/rst/images/connect_standard.odg
new file mode 100644
index 0000000..7cde484
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_standard.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_standard.pdf b/lib_uart/lib_uart/doc/rst/images/connect_standard.pdf
new file mode 100644
index 0000000..be31d94
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_standard.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_tx.odg b/lib_uart/lib_uart/doc/rst/images/connect_tx.odg
new file mode 100644
index 0000000..6654865
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_tx.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/connect_tx.pdf b/lib_uart/lib_uart/doc/rst/images/connect_tx.pdf
new file mode 100644
index 0000000..fc9ca11
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/connect_tx.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/data_sequence.js b/lib_uart/lib_uart/doc/rst/images/data_sequence.js
new file mode 100644
index 0000000..63c0c9c
--- /dev/null
+++ b/lib_uart/lib_uart/doc/rst/images/data_sequence.js
@@ -0,0 +1,9 @@
+{
+ config: { hscale: 1.5 },
+ signal: [
+ {name: 'UART', wave: 'x10=========1x',data:['b0','b1','b2','b3','b4','b5','b6','b7','parity']},
+ {node: '..abcdefghijkl'}
+ ],
+ edge:['b<->a tBIT','b<->c tBIT','c<->d tBIT','d<->e tBIT','e<->f tBIT','f<->g tBIT','g<->h tBIT','h<->i tBIT','i<->j tBIT','j<->k tBIT','k<->l tBIT']
+}
+
diff --git a/lib_uart/lib_uart/doc/rst/images/data_sequence.png b/lib_uart/lib_uart/doc/rst/images/data_sequence.png
new file mode 100644
index 0000000..efa1e42
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/data_sequence.png differ
diff --git a/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.odg b/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.odg
new file mode 100644
index 0000000..be4a5e9
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.pdf b/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.pdf
new file mode 100644
index 0000000..76c1772
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/fast_uart_task_diag.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.odg b/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.odg
new file mode 100644
index 0000000..1b5e3cb
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.pdf b/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.pdf
new file mode 100644
index 0000000..f5eceba
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/half_duplex_task_diag.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.odg b/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.odg
new file mode 100644
index 0000000..6da389f
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.pdf b/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.pdf
new file mode 100644
index 0000000..2eaec80
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/multi_uart_task_diag.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.odg b/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.odg
new file mode 100644
index 0000000..772a64e
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.pdf b/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.pdf
new file mode 100644
index 0000000..d80e464
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/uart_rx_task_diag.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/images/uart_task_diag.odg b/lib_uart/lib_uart/doc/rst/images/uart_task_diag.odg
new file mode 100644
index 0000000..670704c
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/uart_task_diag.odg differ
diff --git a/lib_uart/lib_uart/doc/rst/images/uart_task_diag.pdf b/lib_uart/lib_uart/doc/rst/images/uart_task_diag.pdf
new file mode 100644
index 0000000..1e159e7
Binary files /dev/null and b/lib_uart/lib_uart/doc/rst/images/uart_task_diag.pdf differ
diff --git a/lib_uart/lib_uart/doc/rst/lib_uart.rst b/lib_uart/lib_uart/doc/rst/lib_uart.rst
new file mode 100644
index 0000000..6305fc0
--- /dev/null
+++ b/lib_uart/lib_uart/doc/rst/lib_uart.rst
@@ -0,0 +1,578 @@
+.. include:: ../../../README.rst
+
+External signal description
+---------------------------
+
+The UART signals used by the library are high in their idle state. The
+transmission of a character start with a *start bit* when the line
+transitions from high to low. Then the data bits of the character are
+then transmitted followed by an optional parity bit and a number of
+stop bits (where the line is driven high). This sequence is shown in
+:ref:`uart_waveform`. The data is driven least significant bit first.
+
+.. _uart_waveform:
+
+.. figure:: images/data_sequence.png
+ :width: 100%
+
+ UART data sequence
+
+The start bit, data bits, parity bit and stop bits are all the same
+length (``tBIT`` in :ref:`uart_waveform`). This length is give by the BAUD
+rate which is the number of bits per second.
+
+Connecting to the xCORE device
+..............................
+
+If you are using the general UART Rx/Tx components then the UART line
+can be connected to a bit of any port. The other bits of the port can
+be shared using the GPIO library. Please refer to the GPIO library
+user guide for restrictions on sharing bits of a port (for example,
+all bits of a port need to be in the same direction - so UART rx and
+UART tx cannot be put on the same port).
+
+.. figure:: images/connect_standard.*
+
+ UART Rx and Tx connections
+
+The half duplex UART needs to be connected to a 1-bit port.
+
+.. figure:: images/connect_half_duplex.*
+
+ UART half duplex connection
+
+|newpage|
+
+The fast/streaming UART also needs to be connect to a 1-bit port for
+TX or RX.
+
+.. figure:: images/connect_fast.*
+
+ Fast/Streaming UART connections
+
+The multi-UARTs need to be connected to 8-bit ports. If fewer than 8
+UARTs are required then an 8-bit port must still be used with some of
+the pins of the port not connected.
+
+.. figure:: images/connect_multi.*
+
+ Multi UART connections
+
+For multi-UART receive, an incoming clock is required to acheive
+standard baud rates. The clock should be a multiple of the maximum
+BAUD rate required e.g. a 1843200Khz oscillator is a multiple of
+115200 baud (and lower rates also). The maximum allowable incoming
+signal is 1843200Khz.
+
+For multi-UART transmit, an incoming clock can also be used. The same
+clock signal can be shared between receive and transmit (i.e. only a
+single 1-bit port need be used).
+
+Usage
+-----
+
+The are four ways to use the UART library detailed in the table below.
+
+.. list-table::
+ :header-rows: 1
+
+ * - UART type
+ - Description
+ * - Standard
+ - Standard UARTs provide a flexible, fully configurable UART for
+ speeds up to 115200 baud. The UART connects to ports via the GPIO
+ library so can be used with single bits of
+ multi-bit ports. Transmit can be buffered or unbuffered. The UART
+ components runs on a logical core but are combinable so can be
+ run with other tasks on the same core (though the timing may be affected).
+ * - Fast/streaming
+ - The fast/streaming UART components provide a fixed configuration
+ fast UART that streams data in and out via a streaming channel.
+ * - Half-duplex
+ - The half-duplex component performs receive and transmit on the
+ same data line. The application controls the direction of the
+ UART at runtime. It is particularly useful for RS485 connections (link?)
+ * - Multi-UART
+ - The multi-UART components efficiently run several UARTS on the
+ same core using a multibit port.
+
+All the UARTs use the XMOS multicore extensions to C (xC) to perform
+their operations, see the :ref:`XMOS Programming
+Guide` for more details.
+
+|newpage|
+
+Standard UART usage
+...................
+
+UART components are instantiated as parallel tasks that run in a
+``par`` statement. The application
+can connect via an interface connection using the ``uart_rx_if`` (for
+the UART Rx component) or the ``uart_tx_if`` (for the UART Tx
+component). Both components also have an optional configuration
+interface that lets the application change the speed and properties of
+the UART at run time.
+
+.. figure:: images/uart_task_diag.*
+
+ UART task diagram
+
+For example, the following code instantiates a UART rx and UART tx
+component and connects to them::
+
+ // Port declarations
+ port p_uart_rx = on tile[0] : XS1_PORT_1A;
+ port p_uart_tx = on tile[0] : XS1_PORT_1B;
+
+ #define RX_BUFFER_SIZE 20
+
+ int main() {
+ interface uart_rx_if i_rx;
+ interface uart_tx_if i_tx;
+ input_gpio_if i_gpio_rx[1];
+ output_gpio_if i_gpio_tx[1];
+ par {
+ on tile[0]: output_gpio(i_gpio_tx, 1, p_uart_tx, null);
+ on tile[0]: uart_tx(i_tx, null,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_tx[0]);
+ on tile[0].core[0] : input_gpio_with_events(i_gpio_rx, 1, p_uart_rx, null);
+ on tile[0].core[0] : uart_rx(i_rx, null, RX_BUFFER_SIZE,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_rx[0]);
+ on tile[0]: app(i_tx, i_rx);
+ }
+ return 0;
+ }
+
+The ``output_gpio`` task and ``input_gpio_with_events`` tasks are part
+of the GPIO library for flexible use of multi-bit ports. See the GPIO
+library user guide for details.
+
+|newpage|
+
+The application can use the client end of the interface connection to
+perform UART operations e.g.::
+
+ void my_application(client uart_tx_if uart_tx,
+ client uart_rx_if uart_rx) {
+ // Write a byte to the UART
+ uart_tx.write(0xff);
+
+ // Wait for a byte to
+ select {
+ case uart_rx.data_ready():
+ uint8_t data = uart_rx.read();
+ printf("Data received %d\n", data);
+ ...
+ break;
+ }
+ }
+
+UART configuration
+~~~~~~~~~~~~~~~~~~
+
+The ``uart_config_if`` connection can be optionally connected to
+either the UART Rx or Tx task e.g.::
+
+ ...
+ interface uart_tx_if i_tx;
+ interface uart_cfg_if i_tx_cfg;
+ input_gpio_if i_gpio_rx[1];
+ par {
+ ...
+ on tile[0]: uart_tx(i_tx, i_tx_cfg,
+ 115200, UART_PARITY_NONE, 8, 1,
+ i_gpio_tx[0]);
+ on tile[0]: app(i_tx, i_rx_cfg);
+ ...
+
+The application can use this interface to dynamically reconfigure the
+UART e.g.::
+
+ void app(client uart_tx_if uart_tx,
+ client uart_config_if uart_tx_cfg) {
+ // Configure the UART to 9600 BAUD
+ uart_tx_cfg.set_baud_rate(9600);
+ // Write to the UART
+ uart_tx.write(0xff);
+ ...
+
+If runtime configuration is not required then ``null`` can be passed
+into the task instead of an interface connection.
+
+Transmit buffering
+~~~~~~~~~~~~~~~~~~
+
+There are two types of standard UART tx task: buffered and
+un-buffered.
+
+The buffered UART will buffer characters written to the
+UART. It requires a separate logical core to feed characters from the
+buffer to the UART pin. This frees the application to perform other
+processing. The buffered UART will inform the application that data has been
+transmitted and that there is more space in the buffer by calling the
+:c:func:`ready_to_transmit` notification.
+
+The unbuffered UART does not take its own logical core but calls to
+``write`` will block until the character has been sent.
+
+Fast/Streaming UART usage
+.........................
+
+The fast/streaming UART components are
+instantiated as parallel tasks that run in a
+``par`` statement. The can connect via a streaming channel.
+
+.. figure:: images/fast_uart_task_diag.*
+
+ Fast/streaming UART task diagram
+
+For example, the following code instantiates a strreaming UART rx and UART tx
+component and connects to them::
+
+ // Port declarations
+ in port p_uart_rx = on tile[0] : XS1_PORT_1A;
+ out port p_uart_tx = on tile[0] : XS1_PORT_1B;
+
+ #define TICKS_PER_BIT 20
+
+ int main() {
+ streaming chan c_rx;
+ streaming chan c_tx;
+ par {
+ on tile[0]: uart_tx_streaming(p_uart_tx, c_tx, TICKS_PER_BIT);
+ on tile[0]: uart_rx_streaming(p_uart_rx, c_rx, TICKS_PER_BIT);
+ on tile[0]: app(c_tx, c_rx);
+ }
+ return 0;
+ }
+
+The streaming channel has a limited amount of buffering
+(~8 characters) but in general the application must deal with incoming
+data as soon as it arrives.
+
+The application can interact with the component using the
+fast/streaming UART functions (see :ref:`fast_uart_api`) e.g.::
+
+ void app(streaming chanend c_tx, streaming chanend c_rx)
+ {
+ uart_tx_streaming_write_byte(c_tx, 0xff);
+ uint8_t byte;
+ uart_rx_streaming_read_byte(c_rx, byte);
+ printf("Received: %d\n", byte);
+ ...
+
+|newpage|
+
+Half-duplex UART usage
+......................
+
+The half-duplex components are instantiated as parallel tasks that run in a
+``par`` statement. The application
+connects via three interface connections: the ``uart_rx_if`` (for
+receiving data), the ``uart_tx_if`` (for transmitting data) and the
+``uart_control_if`` (for controlling the current direction of the UART).
+The component also has an optional configuration
+interface that lets the application change the speed and properties of
+the UART at run time.
+
+.. figure:: images/half_duplex_task_diag.*
+
+ Half-duplex UART task diagram
+
+For example, the following code instantiates a half-duplex UART
+component and connects to it::
+
+ #define TX_BUFFER_SIZE 16
+ #define RX_BUFFER_SIZE 16
+
+ port p_uart = on tile[0] : XS1_PORT_1A;
+
+ int main() {
+ interface uart_rx_if i_rx;
+ interface uart_control_if i_control;
+ interface uart_tx_buffered_if i_tx;
+
+ par {
+ on tile[0] : uart_half_duplex(i_tx, i_rx, i_control, null,
+ TX_BUFFER_SIZE, RX_BUFFER_SIZE,
+ 115200, UART_PARITY_NONE, 8, 1, p_uart);
+
+ on tile[0] : app(i_rx, i_tx, i_control);
+ }
+
+The application can use the interfaces in the same manner as a
+standard UART. The control interface can be used to change direction e.g.::
+
+ void app(client uart_rx_if i_uart_rx,
+ client uart_tx_buffered_if i_uart_tx,
+ client uart_control_if i_control) {
+ uint8_t byte;
+ i_control.set_mode(UART_RX_MODE);
+ byte = i_uart_rx.read();
+ i_control.set_mode(UART_TX_MODE);
+ i_uart_tx.write(byte);
+ ...
+
+|newpage|
+
+Multi-UART usage
+................
+
+Multi-UART components are instantiated as parallel tasks that run in a
+``par`` statement. The application
+can connect via a combination of a channel and
+an interface connection using the ``multi_uart_rx_if``
+(for the UART Rx component) or the ``multi_uart_tx_if`` (for the UART Tx
+component). These interfaces handle data for all the UARTS and runtime
+configuration.
+
+.. figure:: images/multi_uart_task_diag.*
+
+ Multi-UART task diagram
+
+For example, the following code instantiates a multi-UART RX and multi-UART TX
+component and connects to them::
+
+ in buffered port:32 p_uart_rx = XS1_PORT_8A;
+ out buffered port:8 p_uart_tx = XS1_PORT_8B;
+ in port p_uart_clk = XS1_PORT_1F;
+
+ clock clk_uart = XS1_CLKBLK_4;
+
+ int main(void)
+ {
+ interface multi_uart_rx_if i_rx;
+ streaming chan c_rx;
+ chan c_tx;
+ interface multi_uart_tx_if i_tx;
+
+ // Set the rx and tx lines to be clocked off the clk_uart clock block
+ configure_in_port(p_uart_rx, clk_uart);
+ configure_out_port(p_uart_tx, clk_uart, 0);
+
+ // Configure an external clock for the clk_uart clock block
+ configure_clock_src(clk_uart, p_uart_clk);
+ start_clock(clk_uart);
+
+ // Start the rx/tx tasks and the application task
+ par {
+ multi_uart_rx(c_rx, i_rx, p_uart_rx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ multi_uart_tx(c_tx, i_tx, p_uart_tx, 8, 1843200, 115200, UART_PARITY_NONE, 8, 1);
+ app(c_rx, i_rx, c_tx, i_tx);
+ }
+ }
+
+|newpage|
+The application communicates with all the UARTs via the single
+multi-UART interfaces e.g.::
+
+ void loopback(streaming chanend c_rx, client multi_uart_rx_if i_rx,
+ chanend c_tx, client multi_uart_tx_if i_tx)
+ {
+ size_t uart_num;
+
+ // Configure each task with a chanend
+ i_rx.init(c_rx);
+ i_tx.init(c_tx);
+
+ while (1) {
+ select {
+ case multi_uart_data_ready(c_rx, uart_num):
+ uint8_t data;
+ if (i_rx.read(uart_num, data) == UART_RX_VALID_DATA) {
+ if (i_tx.is_slot_free(uart_num)) {
+ i_tx.write(uart_num, data);
+ }
+ else {
+ debug_printf("Warning: TX buffer overflow on channel %d\n",
+ uart_num);
+ }
+ }
+ break;
+ }
+ }
+ }
+
+Note that the ``init`` function on the interface must be called once
+before any use of the interface.
+
+Configuring clocks for multi-UARTs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ports used for the multi-UART components need to have their clocks
+configured. For example, the following code configures the multi-UART
+RX port to run of a clock that is sourced by an incoming port::
+
+ // Set the rx line to be clocked off the clk_uart clock block
+ configure_in_port(p_uart_rx, clk_uart);
+
+ // Configure an external clock for the clk_uart clock block
+ configure_clock_src(clk_uart, p_uart_clk);
+ start_clock(clk_uart);
+
+For more information on configuring ports, please refer to the
+:ref:`XMOS Programming Guide` for more details.
+
+The multi-UART components take an argument which is the speed of the
+underlying clock. This way the component can attain the correct BAUD
+rate.
+
+The multi-UART RX component must be clocked of a rate which is a
+multiple of the BAUD rates required.
+
+If a port is not explicitly configured, then it will be clocked of the
+reference 100Mhz clock of the xCORE. The TX component can also work
+with this clock rate.
+
+|newpage|
+
+Runtime configuration of the Multi-UARTs
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The re-configuration of a one of the UARTS in the multi-UART is done
+via the main ``multi_uart_tx_if`` or ``multi_uart_rx_if``. In both
+cases, the user must call the ``pause`` function of the interface,
+then a reconfiguration function and then the ``restart`` function
+e.g.::
+
+ void app(streaming chanend c_rx, client multi_uart_rx_if i_rx)
+ ...
+ i_rx.pause();
+ // Set UART number 2 to baud rate 9600
+ i_rx.set_baud_rate(2, 9600);
+ i_rx.restart();
+ ....
+
+Standard UART API
+-----------------
+
+
+UART configuration interface
+............................
+
+.. doxygeninterface:: uart_config_if
+
+|newpage|
+
+.. doxygenenum:: uart_parity_t
+
+|newpage|
+
+UART receiver component
+.......................
+
+.. doxygenfunction:: uart_rx
+
+|newpage|
+
+UART receive interface
+......................
+
+.. doxygeninterface:: uart_rx_if
+
+|newpage|
+
+UART transmitter components
+...........................
+
+.. doxygenfunction:: uart_tx
+
+|newpage|
+
+.. doxygenfunction:: uart_tx_buffered
+
+|newpage|
+
+UART transmit interface
+.......................
+
+.. doxygeninterface:: uart_tx_if
+
+|newpage|
+
+UART transmit interface (buffered)
+..................................
+
+.. doxygeninterface:: uart_tx_buffered_if
+
+|newpage|
+
+.. _fast_uart_api:
+
+Fast/Streaming API
+-----------------------
+
+Streaming receiver
+..................
+
+.. doxygenfunction:: uart_rx_streaming
+.. doxygenfunction:: uart_rx_streaming_read_byte
+
+Streaming transmitter
+.....................
+
+.. doxygenfunction:: uart_tx_streaming
+.. doxygenfunction:: uart_tx_streaming_write_byte
+
+Half-Duplex API
+---------------
+
+Half-duplex component
+.....................
+
+.. doxygenfunction:: uart_half_duplex
+
+|newpage|
+
+Half-duplex control interface
+.............................
+
+.. doxygenenum:: uart_half_duplex_mode_t
+
+.. doxygeninterface:: uart_control_if
+
+
+Multi-UART API
+--------------
+
+Multi-UART receiver
+...................
+
+.. doxygenfunction:: multi_uart_rx
+
+|newpage|
+
+Multi-UART receive interface
+............................
+
+.. doxygenenum:: multi_uart_read_result_t
+
+.. doxygeninterface:: multi_uart_rx_if
+
+|newpage|
+
+Multi-UART transmitter
+......................
+
+.. doxygenfunction:: multi_uart_tx
+
+|newpage|
+
+Multi-UART transmit interface
+.............................
+
+.. doxygeninterface:: multi_uart_tx_if
+
+|newpage|
+
+|appendix|
+
+Known Issues
+------------
+
+No known issues.
+
+.. include:: ../../../CHANGELOG.rst
+
diff --git a/lib_uart/lib_uart/doc/rst/xdoc.conf b/lib_uart/lib_uart/doc/rst/xdoc.conf
new file mode 100644
index 0000000..2cef5f5
--- /dev/null
+++ b/lib_uart/lib_uart/doc/rst/xdoc.conf
@@ -0,0 +1,2 @@
+XMOSNEWSTYLE = 1
+DOXYGEN_DIRS=../../api
\ No newline at end of file
diff --git a/lib_uart/lib_uart/lib_build_info.cmake b/lib_uart/lib_uart/lib_build_info.cmake
new file mode 100644
index 0000000..a0c5a5e
--- /dev/null
+++ b/lib_uart/lib_uart/lib_build_info.cmake
@@ -0,0 +1,6 @@
+set(LIB_NAME lib_uart)
+set(LIB_VERSION 3.1.0)
+set(LIB_INCLUDES api)
+set(LIB_COMPILER_FLAGS -Os)
+
+XMOS_REGISTER_MODULE()
diff --git a/lib_uart/lib_uart/module_build_info b/lib_uart/lib_uart/module_build_info
new file mode 100644
index 0000000..0d46af9
--- /dev/null
+++ b/lib_uart/lib_uart/module_build_info
@@ -0,0 +1,18 @@
+# You can set flags specifically for your module by using the MODULE_XCC_FLAGS
+# variable. So the following
+#
+# MODULE_XCC_FLAGS = $(XCC_FLAGS) -O3
+#
+# specifies that everything in the modules should have the application
+# build flags with -O3 appended (so the files will build at
+# optimization level -O3).
+#
+# You can also set MODULE_XCC_C_FLAGS, MODULE_XCC_XC_FLAGS etc..
+
+MODULE_XCC_XC_FLAGS = $(XCC_XC_FLAGS) -O3
+
+VERSION = 3.1.0
+
+DEPENDENT_MODULES = lib_xassert(>=3.0.0) lib_gpio(>=1.1.0) lib_logging(>=2.1.0)
+
+OPTIONAL_HEADERS += uart_rx_conf.h
diff --git a/lib_uart/lib_uart/src/multi_uart_rx.xc b/lib_uart/lib_uart/src/multi_uart_rx.xc
new file mode 100644
index 0000000..22798d8
--- /dev/null
+++ b/lib_uart/lib_uart/src/multi_uart_rx.xc
@@ -0,0 +1,296 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+
+#ifndef MUART_RX_CHAN_COUNT
+#define MUART_RX_CHAN_COUNT (8)
+#endif
+
+#define MULTI_UART_GO 0xFE
+
+/**
+ * Structure to hold configuration information and data for the UART channel RX side -
+ * this should only be interacted with via the API and not accessed directly.
+ */
+typedef struct multi_uart_rx_info_t
+{
+ int bits_per_byte; /**< length of the UART character */
+ int uart_word_len; /**< number of bits in UART word e.g. Start bit + 8 bit data + parity + 2 stop bits is a 12 bit UART word */
+ int clocks_per_bit; /**< define baud rate in relation to max baud rate */
+ int invert_output; /**< define if output is inverted (set to 1) */
+ int use_sample; /**< sample in bit stream to use */
+
+ int num_stop_bits;
+ uart_parity_t parity;
+} multi_uart_rx_info_t;
+
+
+extern inline void multi_uart_data_ready(streaming chanend c_rx, size_t &index);
+
+static inline int parity32(unsigned x, enum uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised
+ // to 0 / 1 respectively. The values of the uart_parity_t have been
+ // chosen so the parity can be used to initialise the checksum
+ // directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+
+static
+enum multi_uart_read_result_t
+multi_uart_rx_validate_word(size_t index,
+ unsigned &data,
+ multi_uart_rx_info_t &info)
+{
+
+ switch (info.num_stop_bits) {
+ case 1:
+ if ((data & 0x1) != 0x1)
+ return UART_RX_INVALID_DATA;
+ data >>= 1;
+ break;
+ case 2:
+ if ((data & 0x3) != 0x3)
+ return UART_RX_INVALID_DATA;
+ data >>= 2;
+ break;
+ }
+
+ switch (info.parity)
+ {
+ case UART_PARITY_ODD:
+ case UART_PARITY_EVEN:
+ unsigned parity = data & 1;
+ data >>= 1;
+ data = (bitrev(data) >> (32 - info.bits_per_byte));
+ if (parity != parity32(data, info.parity))
+ return UART_RX_INVALID_DATA;
+ break;
+ case UART_PARITY_NONE:
+ data = (bitrev(data) >> (32 - info.bits_per_byte));
+ break;
+ }
+
+ return UART_RX_VALID_DATA;
+}
+
+static void calc_word_len(multi_uart_rx_info_t &info)
+{
+ info.uart_word_len = info.bits_per_byte + info.num_stop_bits;
+ if (info.parity != UART_PARITY_NONE)
+ info.uart_word_len += 1;
+}
+
+static unsafe void initialize_slot_info(unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ multi_uart_rx_info_t * unsafe rx_slot_info)
+{
+ for (int i = 0; i < MUART_RX_CHAN_COUNT; i++) {
+ rx_slot_info[i].clocks_per_bit = clock_rate_hz / baud;
+ rx_slot_info[i].use_sample = rx_slot_info[i].clocks_per_bit / 2;
+ rx_slot_info[i].parity = parity;
+ rx_slot_info[i].num_stop_bits = stop_bits;
+ rx_slot_info[i].bits_per_byte = bits_per_byte;
+ calc_word_len(rx_slot_info[i]);
+ }
+}
+
+
+[[distributable]]
+void multi_uart_rx_buffer(server interface multi_uart_rx_if i,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits)
+{
+ unsigned * unsafe rx_slots;
+ multi_uart_rx_info_t * unsafe rx_slot_info;
+ unsafe streaming chanend c;
+ while (1) {
+ select {
+ case i.init(streaming chanend c0):
+ unsafe {
+ c = c0;
+ c :> rx_slots;
+ c :> rx_slot_info;
+ initialize_slot_info(clock_rate_hz,
+ baud, parity,
+ bits_per_byte,
+ stop_bits,
+ rx_slot_info);
+ c <: 0;
+ }
+ break;
+ case i.read(size_t index, uint8_t &data) -> enum multi_uart_read_result_t res:
+ unsafe {
+ unsigned x = rx_slots[index];
+ res = multi_uart_rx_validate_word(index, x, rx_slot_info[index]);
+ data = x;
+ }
+ break;
+ case i.pause():
+ unsafe {
+ c <: 0;
+ }
+ break;
+ case i.restart():
+ unsafe {
+ c <: 0;
+ }
+ break;
+ case i.set_baud_rate(size_t index, unsigned baud_rate):
+ unsafe {
+ rx_slot_info[index].clocks_per_bit = clock_rate_hz / baud_rate;
+ rx_slot_info[index].use_sample = rx_slot_info[index].clocks_per_bit/2;
+ }
+ break;
+ case i.set_parity(size_t index, enum uart_parity_t parity):
+ unsafe {
+ rx_slot_info[index].parity = parity;
+ calc_word_len(rx_slot_info[index]);
+ }
+ break;
+ case i.set_stop_bits(size_t index, unsigned stop_bits):
+ unsafe {
+ rx_slot_info[index].num_stop_bits = stop_bits;
+ calc_word_len(rx_slot_info[index]);
+ }
+ break;
+ case i.set_bits_per_byte(size_t index, unsigned bpb):
+ unsafe {
+ rx_slot_info[index].bits_per_byte = bpb;
+ calc_word_len(rx_slot_info[index]);
+ }
+ break;
+ }
+ }
+}
+
+typedef enum e_uart_rx_chan_state
+{
+ idle = 0x0,
+ store_idle,
+ data_bits = 0x1,
+} e_uart_rx_chan_state;
+
+extern "C" {
+ void uart_rx_loop_8(in buffered port:32 pUart, e_uart_rx_chan_state state[],
+ int tick_count[], int bit_count[], int uart_word[],
+ streaming chanend cUART, unsigned rx_char_slots[],
+ unsigned fourBitConfig[],
+ multi_uart_rx_info_t rx_slot_info[],
+ unsigned startBitLookup[]);
+}
+
+void multi_uart_rx_pins(streaming chanend c,
+ in buffered port:32 p,
+ unsigned num_uarts)
+{
+ e_uart_rx_chan_state state[MUART_RX_CHAN_COUNT];
+
+ int tickcount[MUART_RX_CHAN_COUNT];
+ int bit_count[MUART_RX_CHAN_COUNT];
+ int uart_word[MUART_RX_CHAN_COUNT];
+
+ unsigned fourBitLookup0[16];
+ unsigned fourBitLookup1[16];
+ unsigned fourBitConfig[MUART_RX_CHAN_COUNT];
+
+ unsigned startBitLookupEnabled[16];
+ unsigned startBitLookupDisabled[16];
+ unsigned startBitConfig[MUART_RX_CHAN_COUNT];
+
+ multi_uart_rx_info_t rx_slot_info[MUART_RX_CHAN_COUNT];
+
+ unsigned rx_slots[MUART_RX_CHAN_COUNT];
+
+ /*
+ * Four bit look up table that takes the CRC32 with poly 0xf of the masked off 32 bit word
+ * from an 8 bit port and translates it into the 4 desired bits - huzzah!
+ * bit 4-7 indicates whether there could be a start bit and how many are swallowed
+ */
+ fourBitLookup0[15] = 0x00;
+ fourBitLookup0[7] = 0x31;
+ fourBitLookup0[13] = 0x02;
+ fourBitLookup0[5] = 0x23;
+ fourBitLookup0[0] = 0x04;
+ fourBitLookup0[8] = 0x05;
+ fourBitLookup0[2] = 0x06;
+ fourBitLookup0[10] = 0x17;
+ fourBitLookup0[11] = 0x08;
+ fourBitLookup0[3] = 0x09;
+ fourBitLookup0[9] = 0x0a;
+ fourBitLookup0[1] = 0x0b;
+ fourBitLookup0[4] = 0x0c;
+ fourBitLookup0[12] = 0x0d;
+ fourBitLookup0[6] = 0x0e;
+ fourBitLookup0[14] = 0x0f;
+
+ fourBitLookup1[15] = 0x00;
+ fourBitLookup1[7] = 0x01;
+ fourBitLookup1[13] = 0x02;
+ fourBitLookup1[5] = 0x03;
+ fourBitLookup1[0] = 0x04;
+ fourBitLookup1[8] = 0x05;
+ fourBitLookup1[2] = 0x06;
+ fourBitLookup1[10] = 0x07;
+ fourBitLookup1[11] = 0x18;
+ fourBitLookup1[3] = 0x09;
+ fourBitLookup1[9] = 0x0a;
+ fourBitLookup1[1] = 0x0b;
+ fourBitLookup1[4] = 0x2c;
+ fourBitLookup1[12] = 0x0d;
+ fourBitLookup1[6] = 0x3e;
+ fourBitLookup1[14] = 0x0f;
+
+ for (int i = 0; i < 16; i++)
+ {
+ startBitLookupEnabled[i] = 0xffffffff;
+ startBitLookupDisabled[i] = 0xffffffff;
+ }
+
+ startBitLookupEnabled[0b0000] = 4;
+ startBitLookupEnabled[0b0001] = 3;
+ startBitLookupEnabled[0b0011] = 2;
+ startBitLookupEnabled[0b0111] = 1;
+
+ unsafe {
+ c <: (void * unsafe) rx_slots;
+ c <: (void * unsafe) rx_slot_info;
+ }
+ while (1) {
+ c :> int;
+ /* initialisation loop */
+ for (int i = 0; i < MUART_RX_CHAN_COUNT; i++) {
+ state[i] = idle;
+ uart_word[i] = 0;
+ bit_count[i] = 0;
+ tickcount[i] = rx_slot_info[i].use_sample;
+ unsafe {
+ if (i < num_uarts) {
+ startBitConfig[i] =
+ (unsigned) (unsigned * unsafe) startBitLookupEnabled;
+ } else {
+ startBitConfig[i] =
+ (unsigned) (unsigned * unsafe) startBitLookupDisabled;
+ }
+
+ fourBitConfig[i] = (unsigned) (unsigned * unsafe) fourBitLookup0;
+ }
+ }
+
+ /* run ASM function - will exit on reconfiguration request over the channel */
+ uart_rx_loop_8(p, state, tickcount, bit_count, uart_word,
+ c, rx_slots, fourBitConfig, rx_slot_info, startBitConfig);
+ }
+}
diff --git a/lib_uart/lib_uart/src/multi_uart_tx.xc b/lib_uart/lib_uart/src/multi_uart_tx.xc
new file mode 100644
index 0000000..5fe1176
--- /dev/null
+++ b/lib_uart/lib_uart/src/multi_uart_tx.xc
@@ -0,0 +1,296 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+#include
+
+#define MUART_TX_MAX_BAUD (115200)
+
+#ifndef MUART_TX_CHAN_COUNT
+#define MUART_TX_CHAN_COUNT (8)
+#endif
+
+#ifndef MUART_TX_BUF_SIZE
+#define MUART_TX_BUF_SIZE (16)
+#endif
+
+/**
+ * Structure to hold configuration information and data for the
+ * UART TX channels.
+ */
+typedef struct multi_uart_tx_info_t {
+ /** Configuration constants */
+ unsigned bits_per_byte; /**< length of the UART char */
+ unsigned uart_word_len; /**< number of bits in UART word e.g. Start bit + 8 bit data + parity + 2 stop bits is 12 bit UART word */
+ unsigned clocks_per_bit; /**< define baud rate in relation to max baud rate */
+
+ /** Mode definition */
+ unsigned num_stop_bits;
+ uart_parity_t parity;
+
+ /** Buffering variables */
+ size_t wr_ptr; /**< Write pointer */
+ size_t rd_ptr; /**< Read pointer */
+ uint32_t buf[MUART_TX_BUF_SIZE]; /**< Buffer array */
+
+} multi_uart_tx_info_t;
+
+
+static inline int parity32(unsigned x, enum uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised
+ // to 0 / 1 respectively. The values of the art_tx_parity have been
+ // chosen so the parity can be used to initialise the checksum
+ // directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+unsigned int uart_tx_assemble_word(multi_uart_tx_info_t &info,
+ unsigned int uart_char )
+{
+ unsigned int full_word = 0;
+ int pos = 0;
+ /* format data into the word (msb -> lsb) STOP|PARITY|DATA|START */
+
+ pos += 1;
+
+ /* uart word - mask, reverse char and put into full word */
+ unsigned mask = (1 << info.bits_per_byte) - 1;
+ uart_char = uart_char & mask;
+ full_word |= uart_char << pos;
+ pos += info.bits_per_byte;
+
+ /* parity */
+ if (info.parity != UART_PARITY_NONE)
+ {
+ int parity = parity32(uart_char, info.parity);
+ full_word |= (parity << pos);
+ pos += 1;
+ }
+
+ unsigned stop_bits = (1 << info.num_stop_bits) - 1;
+
+ full_word |= stop_bits << pos;
+ pos += info.num_stop_bits;
+
+ /* do calc XOR'd output */
+ full_word = ((full_word << 1) | 0x1) ^ full_word;
+
+ return full_word;
+}
+
+
+[[distributable]]
+void multi_uart_tx_buffer(server interface multi_uart_tx_if i_tx,
+ unsigned clock_rate_hz,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits)
+{
+ multi_uart_tx_info_t tx_slot_info[MUART_TX_CHAN_COUNT];
+ unsafe chanend c;
+
+ if (clock_rate_hz >= MUART_TX_MAX_BAUD) {
+ // Update to the effective tick rate of the transmitter
+ clock_rate_hz = MUART_TX_MAX_BAUD;
+ }
+
+ /* MUART_TX_BUF_SIZE must be a power of 2 */
+ assert((MUART_TX_BUF_SIZE >> clz(bitrev(MUART_TX_BUF_SIZE))) == 1);
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ unsigned initial_clocks_per_bit = clock_rate_hz / baud;
+
+ for (size_t i = 0; i < MUART_TX_CHAN_COUNT; i++) {
+ tx_slot_info[i].clocks_per_bit = initial_clocks_per_bit;
+ tx_slot_info[i].num_stop_bits = stop_bits;
+ tx_slot_info[i].parity = parity;
+ tx_slot_info[i].bits_per_byte = bits_per_byte;
+ tx_slot_info[i].uart_word_len = 1 + bits_per_byte + stop_bits;
+ if (tx_slot_info[i].parity != UART_PARITY_NONE) {
+ tx_slot_info[i].uart_word_len += 1;
+ }
+ tx_slot_info[i].rd_ptr = 0;
+ tx_slot_info[i].wr_ptr = 0;
+ }
+
+ while (1) {
+ select {
+ case i_tx.init(chanend c0):
+ unsafe {
+ c = (unsafe chanend) c0;
+ c <: (multi_uart_tx_info_t * unsafe) tx_slot_info;
+ }
+ break;
+ case i_tx.is_slot_free(size_t index) -> int result:
+ unsigned w = (tx_slot_info[index].wr_ptr + 1) % MUART_TX_BUF_SIZE;
+ result = (w != tx_slot_info[index].rd_ptr);
+ break;
+ case i_tx.write(size_t index, uint8_t byte):
+ unsigned w = (tx_slot_info[index].wr_ptr + 1) % MUART_TX_BUF_SIZE;
+ if (w == tx_slot_info[index].rd_ptr)
+ break;
+ unsigned uart_word = uart_tx_assemble_word(tx_slot_info[index], byte);
+ tx_slot_info[index].buf[tx_slot_info[index].wr_ptr] = uart_word;
+ tx_slot_info[index].wr_ptr = w;
+ break;
+ case i_tx.pause():
+ unsafe {
+ c <: 0;
+ }
+ break;
+ case i_tx.restart():
+ unsafe {
+ c <: 0;
+ }
+ break;
+ case i_tx.set_baud_rate(size_t index, unsigned baud_rate):
+ unsafe {
+ tx_slot_info[index].clocks_per_bit = clock_rate_hz / baud_rate;
+ }
+ break;
+ case i_tx.set_parity(size_t index, enum uart_parity_t parity):
+ unsafe {
+ tx_slot_info[index].parity = parity;
+ }
+ break;
+ case i_tx.set_stop_bits(size_t index, unsigned stop_bits):
+ unsafe {
+ tx_slot_info[index].num_stop_bits = stop_bits;
+ }
+ break;
+ case i_tx.set_bits_per_byte(size_t index, unsigned bits_per_byte):
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+ unsafe {
+ tx_slot_info[index].bits_per_byte = bits_per_byte;
+ }
+ break;
+ }
+ }
+}
+
+#pragma unsafe arrays
+void multi_uart_tx_pins(chanend c,
+ out buffered port:8 p,
+ unsigned clock_rate_hz)
+{
+ unsigned port_val;
+ unsigned ts;
+ const unsigned idle_val = 0xFFFFFFFF;
+
+ unsigned current_word[MUART_TX_CHAN_COUNT];
+ unsigned current_word_pos[MUART_TX_CHAN_COUNT];
+ unsigned tick_count[MUART_TX_CHAN_COUNT];
+ unsigned clocks_per_bit[MUART_TX_CHAN_COUNT];
+
+ volatile multi_uart_tx_info_t * unsafe tx_slot_info;
+ unsigned ts_inc = 1;
+
+ if (clock_rate_hz >= MUART_TX_MAX_BAUD) {
+ // Update to the effective tick rate of the transmitter
+ ts_inc = clock_rate_hz / MUART_TX_MAX_BAUD;
+ }
+ else {
+ ts_inc = 1;
+ }
+
+
+ /* wait until release (post config) */
+ unsafe {
+ c :> tx_slot_info;
+ }
+
+ /* initialise data structures */
+ for (int i = 0; i < MUART_TX_CHAN_COUNT; i++)
+ {
+ current_word[i] = 0;
+ current_word_pos[i] = 0; // disable channel
+ tick_count[i] = 0;
+ unsafe {
+ clocks_per_bit[i] = tx_slot_info[i].clocks_per_bit;
+ }
+ }
+
+ port_val = idle_val;
+ /* initialise port */
+ p <: port_val @ ts;
+ // Wait for 20 port ticks for the while(1) to be set up. TODO: This could be
+ // optimised and the number of ticks could be calculated from the BAUD rate.
+ ts += 20 + ts_inc;
+
+ while (1)
+ {
+ /* process the next bit on the ports */
+#pragma xta endpoint "tx_bit_ep0"
+ p @ ts <: port_val;
+ ts += ts_inc;
+ /* calculate next port_val */
+#pragma loop unroll
+ for (int i = 0; i < MUART_TX_CHAN_COUNT; i++)
+ {
+#pragma xta label "update_loop"
+ tick_count[i]--;
+ /* active and counter tells us we need to send a bit */
+ if (tick_count[i] == 0 && current_word_pos[i])
+ {
+ port_val ^= (current_word[i] & 1) << i;
+ current_word[i] >>= 1;
+ current_word_pos[i] -= 1;
+ tick_count[i] = clocks_per_bit[i];
+ }
+
+ unsafe {
+ if ((current_word_pos[i] == 0) &&
+ (tx_slot_info[i].rd_ptr != tx_slot_info[i].wr_ptr)) // rd == wr => empty
+ {
+ int rd_ptr = tx_slot_info[i].rd_ptr;
+ current_word[i] = tx_slot_info[i].buf[rd_ptr];
+ rd_ptr = (rd_ptr + 1) % MUART_TX_BUF_SIZE;
+ tx_slot_info[i].rd_ptr = rd_ptr;
+
+ current_word_pos[i] = tx_slot_info[i].uart_word_len;
+ tick_count[i] = clocks_per_bit[i];
+ }
+ }
+ }
+
+ /* check for request to pause for reconfigure */
+ unsafe {
+ select
+ {
+#pragma xta endpoint "tx_bit_ep1"
+ case c :> int _: // anything here will pause the TX thread
+
+ /* set port to IDLE */
+ port_val = idle_val;
+ p <: port_val @ ts;
+
+ /* allow otherside to hold us while we wait */
+ c :> int _;
+
+ /* initialise data structures */
+ for (int i = 0; i < MUART_TX_CHAN_COUNT; i++)
+ {
+ current_word[i] = 0;
+ current_word_pos[i] = 0; // disable channel
+ tick_count[i] = 0;
+ tx_slot_info[i].wr_ptr = 0;
+ tx_slot_info[i].rd_ptr = 0;
+ clocks_per_bit[i] = tx_slot_info[i].clocks_per_bit;
+ }
+
+ /* initialise port */
+ p <: port_val @ ts;
+ ts += 20;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
diff --git a/lib_uart/lib_uart/src/uart.xscope b/lib_uart/lib_uart/src/uart.xscope
new file mode 100644
index 0000000..a835449
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart.xscope
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/lib_uart/src/uart_fast_rx.xc b/lib_uart/lib_uart/src/uart_fast_rx.xc
new file mode 100644
index 0000000..5f79184
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_fast_rx.xc
@@ -0,0 +1,39 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+
+void uart_rx_fast_init(in port p, const clock clkblk){
+ //set port into clocked mode
+ configure_in_port_no_ready(p, clkblk);
+ //clear the receive buffer
+ clearbuf(p);
+}
+
+void uart_rx_streaming_read_byte(streaming chanend c, uint8_t &byte)
+{
+ c :> byte;
+}
+
+void uart_rx_streaming(in port pIn, streaming chanend cOut, int clocks) {
+ int dt2 = (clocks * 3)>>1; //one and a half bit times
+ int dt = clocks;
+ int t;
+ unsigned int data = 0;
+ while (1) {
+ pIn when pinseq(0) :> int _ @ t; //wait until falling edge of start bit
+ t += dt2;
+#pragma loop unroll(8)
+ for(int i = 0; i < 8; i++) {
+ pIn @ t :> >> data; //sample value when port timer = t
+ //inlcudes post right shift
+ t += dt;
+ }
+ data >>= 24; //shift into MSB
+ cOut <: (unsigned char) data; //send to client
+ pIn @ t :> int _;
+ data = 0;
+ }
+}
+
diff --git a/lib_uart/lib_uart/src/uart_fast_tx.xc b/lib_uart/lib_uart/src/uart_fast_tx.xc
new file mode 100644
index 0000000..0e037e0
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_fast_tx.xc
@@ -0,0 +1,32 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+
+void uart_tx_fast_init(out port p, const clock clkblk){
+ //set to clocked port, with initial value 1 (idle for UART)
+ configure_out_port_no_ready(p, clkblk, 1);
+}
+
+void uart_tx_streaming_write_byte(streaming chanend c, uint8_t byte)
+{
+ c <: byte;
+}
+
+void uart_tx_streaming(out port p, streaming chanend c, int clocks) {
+ int t;
+ unsigned char b;
+ while (1) {
+ c :> b;
+ p <: 0 @ t; //send start bit and timestamp (grab port timer value)
+ t += clocks;
+#pragma loop unroll(8)
+ for(int i = 0; i < 8; i++) {
+ p @ t <: >> b; //timed output with post right shift
+ t += clocks;
+ }
+ p @ t <: 1; //send stop bit
+ t += clocks;
+ p @ t <: 1; //wait until end of stop bit
+ }
+}
diff --git a/lib_uart/lib_uart/src/uart_half_duplex.xc b/lib_uart/lib_uart/src/uart_half_duplex.xc
new file mode 100644
index 0000000..6c03e7c
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_half_duplex.xc
@@ -0,0 +1,434 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+// UART API Header
+#include "uart.h"
+#include "uart_half_duplex.h"
+
+#include
+#include
+#include
+
+#include "xassert.h"
+
+static inline int parity32(unsigned x, uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised to 0 / 1
+ // respectively. The values of the art_tx_parity have been chosen so the
+ // parity can be used to initialise the checksum directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+static inline int buffer_full(size_t rdptr, size_t wrptr, int buf_length)
+{
+ wrptr++;
+ if (wrptr == buf_length)
+ wrptr = 0;
+ return (wrptr == rdptr);
+}
+
+static inline void init_transmit(uint8_t buffer[buf_length],
+ unsigned buf_length,
+ unsigned &rdptr, unsigned &wrptr,
+ out port p, enum uart_tx_state &state,
+ unsigned &bit_count, int &t, int bit_time,
+ unsigned &byte)
+{
+ timer tmr;
+ if (state != WAITING_FOR_DATA || rdptr == wrptr)
+ return;
+ byte = buffer[rdptr];
+
+ // Trace the outgoing data
+ //xscope_char(UART_TX_VALUE, byte);
+
+ rdptr++;
+ if (rdptr == buf_length)
+ rdptr = 0;
+ state = OUTPUTTING_DATA_BIT;
+
+ bit_count = 0;
+
+ // Output start bit
+ tmr :> t;
+ t+=bit_time;
+ tmr when timerafter(t) :> void;
+
+ p <: 0;
+ t += bit_time;
+}
+
+
+static inline int add_to_buffer(uint8_t buffer[n], unsigned n,
+ unsigned &rdptr, unsigned &wrptr,
+ uint8_t data)
+{
+ int new_wrptr = wrptr + 1;
+
+ if (new_wrptr >= n)
+ new_wrptr = 0;
+
+ if (new_wrptr == rdptr) {
+ // buffer full
+ return 0;
+ }
+
+ // Output tracing information of the values entering the buffer
+ // xscope_char(UART_RX_VALUE, data);
+
+ buffer[wrptr] = data;
+ wrptr = new_wrptr;
+ return 1;
+}
+
+static inline void wait_when_pins_eq(port pin, int value)
+{
+ assert(value == 1 || value == 0);
+ char current;
+ do {
+ pin :> current;
+ } while (current != value);
+}
+
+
+void uart_half_duplex(server interface uart_tx_buffered_if i_tx,
+ server interface uart_rx_if i_rx,
+ server interface uart_control_if i_control,
+ server interface uart_config_if ?i_config,
+ const static unsigned tx_buf_length,
+ const static unsigned rx_buf_length,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ port p_uart)
+{
+ enum uart_tx_state tx_state = WAITING_FOR_DATA;
+ enum uart_rx_state rx_state = RX_INACTIVE;
+ uart_half_duplex_mode_t mode = UART_TX_MODE;
+ // Initialise the server.
+ uint8_t rx_buffer[rx_buf_length], tx_buffer[tx_buf_length];
+ int bit_time = XS1_TIMER_HZ / baud;
+
+ // State machine intitial state.
+ p_uart <: 1; // Idle high
+
+ // Locals
+ int switch_mode = 0;
+ unsigned byte, data = 0, data_bit_count = 0;
+ timer tmr;
+ int t;
+
+ size_t tx_rdptr = 0, tx_wrptr = 0;
+ size_t rx_rdptr = 0, rx_wrptr = 0;
+ unsigned bit_count = 0, stop_bit_count;
+
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ // State machine
+ while(1)
+ {
+ switch(mode)
+ {
+ // tx mode
+ case UART_TX_MODE:
+ {
+ select
+ {
+ // If we're not in the waiting state, go through state
+ // machine once per bit time
+ case (tx_state != WAITING_FOR_DATA && tx_state != TX_INACTIVE) => tmr when timerafter(t) :> void:
+ {
+ switch(tx_state)
+ {
+ case OUTPUTTING_DATA_BIT:
+ {
+ p_uart <: (byte >> bit_count) & 0x1;
+ bit_count++;
+ t += bit_time;
+ if (bit_count == bits_per_byte)
+ {
+ bit_count = 0;
+ if (parity != UART_PARITY_NONE)
+ {
+ tx_state = OUTPUTTING_PARITY_BIT;
+ }
+ else
+ {
+ stop_bit_count = stop_bits;
+ tx_state = OUTPUTTING_STOP_BIT;
+ }
+ }
+ break;
+ }
+
+ case OUTPUTTING_PARITY_BIT:
+ {
+ int val = parity32(byte, parity);
+ p_uart <: val;
+ t += bit_time;
+ stop_bit_count = stop_bits;
+ tx_state = OUTPUTTING_STOP_BIT;
+ break;
+ }
+
+ case OUTPUTTING_STOP_BIT:
+ {
+ p_uart <: 1;
+ t += bit_time;
+ stop_bit_count--;
+
+ if (stop_bit_count == 0) {
+ tx_state = WAITING_FOR_DATA;
+
+ // If a mode switch has been requested...
+ if(switch_mode == 1)
+ {
+ mode = UART_RX_MODE;
+ tx_state = TX_INACTIVE;
+ rx_state = WAITING_FOR_INPUT;
+ switch_mode = 0;
+ p_uart :> int _;
+ break;
+ }
+ else
+ {
+ init_transmit(tx_buffer, tx_buf_length,
+ tx_rdptr, tx_wrptr, p_uart, tx_state,
+ bit_count, t, bit_time, byte);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ case i_tx.write(uint8_t data) -> int buffer_was_full:
+ {
+ if (buffer_full(tx_rdptr, tx_wrptr, tx_buf_length))
+ {
+ buffer_was_full = 1;
+ return;
+ }
+ buffer_was_full = 0;
+ tx_buffer[tx_wrptr] = data;
+ tx_wrptr++;
+ if (tx_wrptr == tx_buf_length)
+ tx_wrptr = 0;
+
+ init_transmit(tx_buffer, tx_buf_length, tx_rdptr,
+ tx_wrptr, p_uart, tx_state, bit_count, t,
+ bit_time, byte);
+ break;
+ }
+
+ case i_tx.get_available_buffer_size(void) -> size_t available:
+ {
+ int size = tx_rdptr - tx_wrptr;
+ if (size <= 0)
+ size += tx_buf_length - 1;
+ available = size;
+ break;
+ }
+
+ case i_control.set_mode(uart_half_duplex_mode_t n_mode):
+ {
+ // If this is actually a mode change...
+ if(mode != n_mode)
+ {
+ // If we're not in an idle state, set a flag for the
+ // mode the be change after outputting the current
+ // byte
+ if(tx_state != WAITING_FOR_DATA)
+ {
+ switch_mode = 1;
+ }
+ else // Otherwise, just change mode
+ {
+ mode = UART_RX_MODE;
+ tx_state = TX_INACTIVE;
+ rx_state = WAITING_FOR_INPUT;
+ p_uart :> int _;
+ switch_mode = 0;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ // rx mode
+ case UART_RX_MODE:
+ {
+ select
+ {
+ case (rx_state == WAITING_FOR_HIGH || rx_state == WAITING_FOR_INPUT) => p_uart when pinseq(0) :> void:
+ {
+ tmr :> t;
+ switch (rx_state) {
+ case WAITING_FOR_HIGH:
+ {
+ p_uart when pinseq(0) :> void;
+ rx_state = WAITING_FOR_INPUT;
+ break;
+ }
+ case WAITING_FOR_INPUT:
+ {
+ t += bit_time/2;
+ rx_state = TESTING_START_BIT;
+ break;
+ }
+ }
+ break;
+ }
+
+ case (rx_state != WAITING_FOR_INPUT && rx_state != RX_INACTIVE) => tmr when timerafter(t) :> void:
+ {
+ switch (rx_state) {
+ case TESTING_START_BIT:
+ {
+ // We should now be half way through the start
+ // bit. Test it is not a glitch
+ int level_test;
+ p_uart :> level_test;
+ if (level_test == 0)
+ {
+ data_bit_count = 0;
+ t += bit_time;
+ data = 0;
+ rx_state = INPUTTING_DATA_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ break;
+ }
+
+ case INPUTTING_DATA_BIT:
+ {
+ int bit;
+ p_uart :> bit;
+ data = data << 1 | bit;
+ data_bit_count++;
+ t += bit_time;
+ if (data_bit_count == bits_per_byte) {
+ data = bitrev(data) >> (CHAR_BIT * sizeof(unsigned) - bits_per_byte);
+ if (parity != UART_PARITY_NONE)
+ {
+ rx_state = INPUTTING_PARITY_BIT;
+ }
+ else
+ {
+ if (add_to_buffer(rx_buffer, rx_buf_length, rx_rdptr, rx_wrptr, data))
+ i_rx.data_ready();
+ if (stop_bits != 0)
+ {
+ stop_bit_count = stop_bits;
+ rx_state = INPUTTING_STOP_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ }
+ }
+ break;
+ }
+
+ case INPUTTING_PARITY_BIT:
+ {
+ int bit;
+ p_uart :> bit;
+ if (bit == parity32(data, parity))
+ {
+ if (add_to_buffer(rx_buffer, rx_buf_length, rx_rdptr, rx_wrptr, data))
+ i_rx.data_ready();
+ if (stop_bits != 0)
+ {
+ stop_bit_count = stop_bits;
+ rx_state = INPUTTING_STOP_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ }
+ else
+ {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ t += bit_time;
+ break;
+ }
+
+ case INPUTTING_STOP_BIT:
+ {
+ int level_test;
+ p_uart :> level_test;
+ if (level_test == 0) {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ stop_bit_count--;
+ t += bit_time;
+ if (stop_bit_count == 0) {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ case i_rx.read() -> uint8_t data:
+ {
+ if (rx_rdptr == rx_wrptr)
+ break;
+ data = rx_buffer[rx_rdptr];
+ rx_rdptr++;
+ if (rx_rdptr == rx_buf_length)
+ rx_rdptr = 0;
+ if (rx_rdptr != rx_wrptr)
+ i_rx.data_ready();
+ break;
+ }
+
+ case i_rx.has_data() -> int res:
+ {
+ res = (rx_rdptr != rx_wrptr);
+ break;
+ }
+
+ case i_control.set_mode(uart_half_duplex_mode_t n_mode):
+ {
+ // If this is actually a mode change...
+ if(mode != n_mode)
+ {
+ // If we're not in an idle state, set a flag for the
+ // mode the be change after outputting the current
+ // byte
+ if(rx_state != WAITING_FOR_DATA)
+ {
+ switch_mode = 1;
+ }
+ else // Otherwise, just change mode
+ {
+ mode = UART_TX_MODE;
+ rx_state = RX_INACTIVE;
+ tx_state = WAITING_FOR_INPUT;
+ switch_mode = 0;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/lib_uart/lib_uart/src/uart_half_duplex.xc~ b/lib_uart/lib_uart/src/uart_half_duplex.xc~
new file mode 100644
index 0000000..94c70d5
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_half_duplex.xc~
@@ -0,0 +1,434 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+// UART API Header
+#include "uart.h"
+#include "uart_half_duplex.h"
+
+#include
+#include
+#include
+
+#include "xassert.h"
+
+static inline int parity32(unsigned x, uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised to 0 / 1
+ // respectively. The values of the art_tx_parity have been chosen so the
+ // parity can be used to initialise the checksum directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+static inline int buffer_full(size_t rdptr, size_t wrptr, int buf_length)
+{
+ wrptr++;
+ if (wrptr == buf_length)
+ wrptr = 0;
+ return (wrptr == rdptr);
+}
+
+static inline void init_transmit(uint8_t buffer[buf_length],
+ unsigned buf_length,
+ unsigned &rdptr, unsigned &wrptr,
+ out port p, enum uart_tx_state &state,
+ unsigned &bit_count, int &t, int bit_time,
+ unsigned &byte)
+{
+ timer tmr;
+ if (state != WAITING_FOR_DATA || rdptr == wrptr)
+ return;
+ byte = buffer[rdptr];
+
+ // Trace the outgoing data
+ xscope_char(UART_TX_VALUE, byte);
+
+ rdptr++;
+ if (rdptr == buf_length)
+ rdptr = 0;
+ state = OUTPUTTING_DATA_BIT;
+
+ bit_count = 0;
+
+ // Output start bit
+ tmr :> t;
+ t+=bit_time;
+ tmr when timerafter(t) :> void;
+
+ p <: 0;
+ t += bit_time;
+}
+
+
+static inline int add_to_buffer(uint8_t buffer[n], unsigned n,
+ unsigned &rdptr, unsigned &wrptr,
+ uint8_t data)
+{
+ int new_wrptr = wrptr + 1;
+
+ if (new_wrptr >= n)
+ new_wrptr = 0;
+
+ if (new_wrptr == rdptr) {
+ // buffer full
+ return 0;
+ }
+
+ // Output tracing information of the values entering the buffer
+ // xscope_char(UART_RX_VALUE, data);
+
+ buffer[wrptr] = data;
+ wrptr = new_wrptr;
+ return 1;
+}
+
+static inline void wait_when_pins_eq(port pin, int value)
+{
+ assert(value == 1 || value == 0);
+ char current;
+ do {
+ pin :> current;
+ } while (current != value);
+}
+
+
+void uart_half_duplex(server interface uart_tx_buffered_if i_tx,
+ server interface uart_rx_if i_rx,
+ server interface uart_control_if i_control,
+ server interface uart_config_if ?i_config,
+ const static unsigned tx_buf_length,
+ const static unsigned rx_buf_length,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ port p_uart)
+{
+ enum uart_tx_state tx_state = WAITING_FOR_DATA;
+ enum uart_rx_state rx_state = RX_INACTIVE;
+ uart_half_duplex_mode_t mode = UART_TX_MODE;
+ // Initialise the server.
+ uint8_t rx_buffer[rx_buf_length], tx_buffer[tx_buf_length];
+ int bit_time = XS1_TIMER_HZ / baud;
+
+ // State machine intitial state.
+ p_uart <: 1; // Idle high
+
+ // Locals
+ int switch_mode = 0;
+ unsigned byte, data = 0, data_bit_count = 0;
+ timer tmr;
+ int t;
+
+ size_t tx_rdptr = 0, tx_wrptr = 0;
+ size_t rx_rdptr = 0, rx_wrptr = 0;
+ unsigned bit_count = 0, stop_bit_count;
+
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ // State machine
+ while(1)
+ {
+ switch(mode)
+ {
+ // tx mode
+ case UART_TX_MODE:
+ {
+ select
+ {
+ // If we're not in the waiting state, go through state
+ // machine once per bit time
+ case (tx_state != WAITING_FOR_DATA && tx_state != TX_INACTIVE) => tmr when timerafter(t) :> void:
+ {
+ switch(tx_state)
+ {
+ case OUTPUTTING_DATA_BIT:
+ {
+ p_uart <: (byte >> bit_count) & 0x1;
+ bit_count++;
+ t += bit_time;
+ if (bit_count == bits_per_byte)
+ {
+ bit_count = 0;
+ if (parity != UART_PARITY_NONE)
+ {
+ tx_state = OUTPUTTING_PARITY_BIT;
+ }
+ else
+ {
+ stop_bit_count = stop_bits;
+ tx_state = OUTPUTTING_STOP_BIT;
+ }
+ }
+ break;
+ }
+
+ case OUTPUTTING_PARITY_BIT:
+ {
+ int val = parity32(byte, parity);
+ p_uart <: val;
+ t += bit_time;
+ stop_bit_count = stop_bits;
+ tx_state = OUTPUTTING_STOP_BIT;
+ break;
+ }
+
+ case OUTPUTTING_STOP_BIT:
+ {
+ p_uart <: 1;
+ t += bit_time;
+ stop_bit_count--;
+
+ if (stop_bit_count == 0) {
+ tx_state = WAITING_FOR_DATA;
+
+ // If a mode switch has been requested...
+ if(switch_mode == 1)
+ {
+ mode = UART_RX_MODE;
+ tx_state = TX_INACTIVE;
+ rx_state = WAITING_FOR_INPUT;
+ switch_mode = 0;
+ p_uart :> int _;
+ break;
+ }
+ else
+ {
+ init_transmit(tx_buffer, tx_buf_length,
+ tx_rdptr, tx_wrptr, p_uart, tx_state,
+ bit_count, t, bit_time, byte);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ case i_tx.write(uint8_t data) -> int buffer_was_full:
+ {
+ if (buffer_full(tx_rdptr, tx_wrptr, tx_buf_length))
+ {
+ buffer_was_full = 1;
+ return;
+ }
+ buffer_was_full = 0;
+ tx_buffer[tx_wrptr] = data;
+ tx_wrptr++;
+ if (tx_wrptr == tx_buf_length)
+ tx_wrptr = 0;
+
+ init_transmit(tx_buffer, tx_buf_length, tx_rdptr,
+ tx_wrptr, p_uart, tx_state, bit_count, t,
+ bit_time, byte);
+ break;
+ }
+
+ case i_tx.get_available_buffer_size(void) -> size_t available:
+ {
+ int size = tx_rdptr - tx_wrptr;
+ if (size <= 0)
+ size += tx_buf_length - 1;
+ available = size;
+ break;
+ }
+
+ case i_control.set_mode(uart_half_duplex_mode_t n_mode):
+ {
+ // If this is actually a mode change...
+ if(mode != n_mode)
+ {
+ // If we're not in an idle state, set a flag for the
+ // mode the be change after outputting the current
+ // byte
+ if(tx_state != WAITING_FOR_DATA)
+ {
+ switch_mode = 1;
+ }
+ else // Otherwise, just change mode
+ {
+ mode = UART_RX_MODE;
+ tx_state = TX_INACTIVE;
+ rx_state = WAITING_FOR_INPUT;
+ p_uart :> int _;
+ switch_mode = 0;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ // rx mode
+ case UART_RX_MODE:
+ {
+ select
+ {
+ case (rx_state == WAITING_FOR_HIGH || rx_state == WAITING_FOR_INPUT) => p_uart when pinseq(0) :> void:
+ {
+ tmr :> t;
+ switch (rx_state) {
+ case WAITING_FOR_HIGH:
+ {
+ p_uart when pinseq(0) :> void;
+ rx_state = WAITING_FOR_INPUT;
+ break;
+ }
+ case WAITING_FOR_INPUT:
+ {
+ t += bit_time/2;
+ rx_state = TESTING_START_BIT;
+ break;
+ }
+ }
+ break;
+ }
+
+ case (rx_state != WAITING_FOR_INPUT && rx_state != RX_INACTIVE) => tmr when timerafter(t) :> void:
+ {
+ switch (rx_state) {
+ case TESTING_START_BIT:
+ {
+ // We should now be half way through the start
+ // bit. Test it is not a glitch
+ int level_test;
+ p_uart :> level_test;
+ if (level_test == 0)
+ {
+ data_bit_count = 0;
+ t += bit_time;
+ data = 0;
+ rx_state = INPUTTING_DATA_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ break;
+ }
+
+ case INPUTTING_DATA_BIT:
+ {
+ int bit;
+ p_uart :> bit;
+ data = data << 1 | bit;
+ data_bit_count++;
+ t += bit_time;
+ if (data_bit_count == bits_per_byte) {
+ data = bitrev(data) >> (CHAR_BIT * sizeof(unsigned) - bits_per_byte);
+ if (parity != UART_PARITY_NONE)
+ {
+ rx_state = INPUTTING_PARITY_BIT;
+ }
+ else
+ {
+ if (add_to_buffer(rx_buffer, rx_buf_length, rx_rdptr, rx_wrptr, data))
+ i_rx.data_ready();
+ if (stop_bits != 0)
+ {
+ stop_bit_count = stop_bits;
+ rx_state = INPUTTING_STOP_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ }
+ }
+ break;
+ }
+
+ case INPUTTING_PARITY_BIT:
+ {
+ int bit;
+ p_uart :> bit;
+ if (bit == parity32(data, parity))
+ {
+ if (add_to_buffer(rx_buffer, rx_buf_length, rx_rdptr, rx_wrptr, data))
+ i_rx.data_ready();
+ if (stop_bits != 0)
+ {
+ stop_bit_count = stop_bits;
+ rx_state = INPUTTING_STOP_BIT;
+ }
+ else
+ {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ }
+ else
+ {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ t += bit_time;
+ break;
+ }
+
+ case INPUTTING_STOP_BIT:
+ {
+ int level_test;
+ p_uart :> level_test;
+ if (level_test == 0) {
+ rx_state = WAITING_FOR_HIGH;
+ }
+ stop_bit_count--;
+ t += bit_time;
+ if (stop_bit_count == 0) {
+ rx_state = WAITING_FOR_INPUT;
+ }
+ break;
+ }
+ }
+ break;
+ }
+
+ case i_rx.read() -> uint8_t data:
+ {
+ if (rx_rdptr == rx_wrptr)
+ break;
+ data = rx_buffer[rx_rdptr];
+ rx_rdptr++;
+ if (rx_rdptr == rx_buf_length)
+ rx_rdptr = 0;
+ if (rx_rdptr != rx_wrptr)
+ i_rx.data_ready();
+ break;
+ }
+
+ case i_rx.has_data() -> int res:
+ {
+ res = (rx_rdptr != rx_wrptr);
+ break;
+ }
+
+ case i_control.set_mode(uart_half_duplex_mode_t n_mode):
+ {
+ // If this is actually a mode change...
+ if(mode != n_mode)
+ {
+ // If we're not in an idle state, set a flag for the
+ // mode the be change after outputting the current
+ // byte
+ if(rx_state != WAITING_FOR_DATA)
+ {
+ switch_mode = 1;
+ }
+ else // Otherwise, just change mode
+ {
+ mode = UART_TX_MODE;
+ rx_state = RX_INACTIVE;
+ tx_state = WAITING_FOR_INPUT;
+ switch_mode = 0;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/lib_uart/lib_uart/src/uart_rx.xc b/lib_uart/lib_uart/src/uart_rx.xc
new file mode 100644
index 0000000..13328ad
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_rx.xc
@@ -0,0 +1,222 @@
+// Copyright (c) 2014-2018, XMOS Ltd, All rights reserved
+
+#include "uart.h"
+#include "xassert.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifndef UART_RX_DISABLE_DYNAMIC_CONFIG
+#define UART_RX_DISABLE_DYNAMIC_CONFIG 0
+#endif
+
+enum uart_rx_state {
+ WAITING_FOR_INPUT,
+ WAITING_FOR_HIGH,
+ TESTING_START_BIT,
+ INPUTTING_DATA_BIT,
+ INPUTTING_PARITY_BIT,
+ INPUTTING_STOP_BIT,
+};
+
+static inline int parity32(unsigned x, enum uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised
+ // to 0 / 1 respectively. The values of the uart_parity_t have been
+ // chosen so the parity can be used to initialise the checksum
+ // directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+static inline int add_to_buffer(uint8_t buffer[n], unsigned n,
+ size_t &rdptr, size_t &wrptr,
+ uint8_t data)
+{
+ int new_wrptr = wrptr + 1;
+
+ if (new_wrptr >= n)
+ new_wrptr = 0;
+
+ if (new_wrptr == rdptr) {
+ // buffer full
+ return 0;
+ }
+
+ // Output tracing information of the values entering the buffer
+ // xscope_char(UART_RX_VALUE, data);
+
+ buffer[wrptr] = data;
+ wrptr = new_wrptr;
+ return 1;
+}
+
+[[combinable]]
+void uart_rx(server interface uart_rx_if c,
+ server interface uart_config_if ?config,
+ const static unsigned n,
+ unsigned baud,
+ enum uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client input_gpio_if p_rxd)
+{
+ uint8_t buffer[n];
+ unsigned data_bit_count;
+ timer tmr;
+ enum uart_rx_state state = WAITING_FOR_HIGH;
+ int t;
+ unsigned bit_time = (XS1_TIMER_HZ / baud);
+ int stop_bit_count;
+ unsigned data;
+ size_t rdptr = 0, wrptr = 0;
+ p_rxd.event_when_pins_eq(1);
+
+ assert(!UART_RX_DISABLE_DYNAMIC_CONFIG || isnull(config));
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ while (1) {
+ select {
+ // The following cases implement the uart state machine
+ case p_rxd.event():
+ tmr :> t;
+ (void) p_rxd.input();
+ switch (state) {
+ case WAITING_FOR_HIGH:
+ p_rxd.event_when_pins_eq(0);
+ state = WAITING_FOR_INPUT;
+ break;
+ case WAITING_FOR_INPUT:
+ t += bit_time/2;
+ state = TESTING_START_BIT;
+ break;
+ }
+ break;
+ case (state != WAITING_FOR_INPUT && state != WAITING_FOR_HIGH) =>
+ tmr when timerafter(t) :> void:
+ switch (state) {
+ case TESTING_START_BIT:
+ // We should now be half way through the start bit
+ // Test it is not a glitch
+ int level_test = p_rxd.input();
+ if (level_test == 0) {
+ data_bit_count = 0;
+ t += bit_time;
+ data = 0;
+ state = INPUTTING_DATA_BIT;
+ }
+ else {
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ }
+ break;
+ case INPUTTING_DATA_BIT:
+ int bit = p_rxd.input();
+ data = data << 1 | bit;
+ data_bit_count++;
+ t += bit_time;
+ if (data_bit_count == bits_per_byte) {
+ data = bitrev(data) >> (CHAR_BIT * sizeof(unsigned) - bits_per_byte);
+ if (parity != UART_PARITY_NONE) {
+ state = INPUTTING_PARITY_BIT;
+ } else {
+ if (add_to_buffer(buffer, n, rdptr, wrptr, data))
+ c.data_ready();
+ if (stop_bits != 0) {
+ stop_bit_count = stop_bits;
+ state = INPUTTING_STOP_BIT;
+ }
+ else {
+ state = WAITING_FOR_INPUT;
+ p_rxd.event_when_pins_eq(0);
+ }
+ }
+ }
+ break;
+ case INPUTTING_PARITY_BIT:
+ int bit = p_rxd.input();
+ if (bit == parity32(data, parity)) {
+ if (add_to_buffer(buffer, n, rdptr, wrptr, data))
+ c.data_ready();
+ if (stop_bits != 0) {
+ stop_bit_count = stop_bits;
+ state = INPUTTING_STOP_BIT;
+ }
+ else {
+ p_rxd.event_when_pins_eq(0);
+ state = WAITING_FOR_INPUT;
+ }
+ }
+ else {
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ }
+ t += bit_time;
+ break;
+ case INPUTTING_STOP_BIT:
+ int level_test = p_rxd.input();
+ if (level_test == 0) {
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ } else {
+ stop_bit_count--;
+ t += bit_time;
+ if (stop_bit_count == 0) {
+ p_rxd.event_when_pins_eq(0);
+ state = WAITING_FOR_INPUT;
+ }
+ }
+ break;
+ }
+ break;
+
+ case c.read() -> uint8_t data:
+ if (rdptr == wrptr)
+ break;
+ data = buffer[rdptr];
+ rdptr++;
+ if (rdptr == n)
+ rdptr = 0;
+ if (rdptr != wrptr)
+ c.data_ready();
+ break;
+ case c.has_data() -> int res:
+ res = (rdptr != wrptr);
+ break;
+#if !UART_RX_DISABLE_DYNAMIC_CONFIG
+ // Handle client interaction with the component
+ case !isnull(config) => config.set_baud_rate(unsigned baud_rate):
+ bit_time = XS1_TIMER_HZ / baud_rate;
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ break;
+ case !isnull(config) => config.set_parity(enum uart_parity_t new_parity):
+ parity = new_parity;
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ break;
+ case !isnull(config) => config.set_stop_bits(unsigned new_stop_bits):
+ stop_bits = new_stop_bits;
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ break;
+ case !isnull(config) => config.set_bits_per_byte(unsigned bpb):
+ assert((bpb > 0) && (bpb <= 8) && "Invalid number of bits per byte");
+ bits_per_byte = bpb;
+ p_rxd.event_when_pins_eq(1);
+ state = WAITING_FOR_HIGH;
+ break;
+#endif
+ }
+ }
+}
+
+extends client interface uart_rx_if : {
+ extern inline uint8_t wait_for_data_and_read(client uart_rx_if i);
+}
diff --git a/lib_uart/lib_uart/src/uart_tx.xc b/lib_uart/lib_uart/src/uart_tx.xc
new file mode 100644
index 0000000..e696924
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_tx.xc
@@ -0,0 +1,89 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+
+#include "uart.h"
+#include
+#include
+#include
+#include
+#include "xassert.h"
+
+#ifndef UART_TX_DISABLE_DYNAMIC_CONFIG
+#define UART_TX_DISABLE_DYNAMIC_CONFIG 0
+#endif
+
+static inline int parity32(unsigned x, enum uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised
+ // to 0 / 1 respectively. The values of the art_tx_parity have been
+ // chosen so the parity can be used to initialise the checksum
+ // directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+[[distributable]]
+void uart_tx(server interface uart_tx_if i,
+ server interface uart_config_if ?config,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client output_gpio_if p_txd)
+{
+ int bit_time = XS1_TIMER_HZ / baud;
+ timer tmr;
+
+ assert(!UART_TX_DISABLE_DYNAMIC_CONFIG || isnull(config));
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ p_txd.output(1);
+ while (1) {
+ select {
+ case i.write(uint8_t data):
+ // Trace the outgoing data
+ //xscope_char(UART_TX_VALUE, data);
+ int t;
+ // Output start bit
+ p_txd.output(0);
+ tmr :> t;
+ t += bit_time;
+ unsigned byte = data;
+ // Output data bits
+ for (int j = 0; j < bits_per_byte; j++) {
+ tmr when timerafter(t) :> void;
+ p_txd.output(byte & 1);
+ byte >>= 1;
+ t += bit_time;
+ }
+ // Output parity
+ if (parity != UART_PARITY_NONE) {
+ tmr when timerafter(t) :> void;
+ p_txd.output(parity32(data, parity));
+ t += bit_time;
+ }
+ // Output stop bits
+ tmr when timerafter(t) :> void;
+ p_txd.output(1);
+ t += bit_time * stop_bits;
+ tmr when timerafter(t) :> void;
+ break;
+#if !UART_TX_DISABLE_DYNAMIC_CONFIG
+ case !isnull(config) => config.set_baud_rate(unsigned baud_rate):
+ bit_time = XS1_TIMER_HZ / baud_rate;
+ break;
+ case !isnull(config) => config.set_parity(enum uart_parity_t new_parity):
+ parity = new_parity;
+ break;
+ case !isnull(config) => config.set_stop_bits(unsigned new_stop_bits):
+ stop_bits = new_stop_bits;
+ break;
+ case !isnull(config) => config.set_bits_per_byte(unsigned bpb):
+ assert((bpb > 0) && (bpb <= 8) && "Invalid number of bits per byte");
+ bits_per_byte = bpb;
+ break;
+#endif
+ }
+ }
+}
diff --git a/lib_uart/lib_uart/src/uart_tx_buffered.xc b/lib_uart/lib_uart/src/uart_tx_buffered.xc
new file mode 100644
index 0000000..b178e7b
--- /dev/null
+++ b/lib_uart/lib_uart/src/uart_tx_buffered.xc
@@ -0,0 +1,216 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+
+#include "uart.h"
+#include
+#include
+#include
+#include
+#include
+#include "xassert.h"
+#include "debug_print.h"
+
+#ifndef UART_TX_DISABLE_DYNAMIC_CONFIG
+#define UART_TX_DISABLE_DYNAMIC_CONFIG 0
+#endif
+
+enum uart_tx_state {
+ WAITING_FOR_DATA,
+ OUTPUTTING_START_BIT,
+ OUTPUTTING_DATA_BIT,
+ OUTPUTTING_PARITY_BIT,
+ OUTPUTTING_STOP_BIT,
+ STOP_BIT_SENT,
+};
+
+
+static inline int parity32(unsigned x, uart_parity_t parity)
+{
+ // To compute even / odd parity the checksum should be initialised
+ // to 0 / 1 respectively. The values of the uart_parity_t have been
+ // chosen so the parity can be used to initialise the checksum
+ // directly.
+ assert(UART_PARITY_EVEN == 0);
+ assert(UART_PARITY_ODD == 1);
+ crc32(x, parity, 1);
+ return (x & 1);
+}
+
+static inline int buffer_full(int rdptr, int wrptr, int buf_length)
+{
+ wrptr++;
+ if (wrptr == buf_length)
+ wrptr = 0;
+ return (wrptr == rdptr);
+}
+
+static inline void init_transmit(size_t &rdptr, size_t &wrptr,
+ enum uart_tx_state &state, int &t,
+ int &clock_sync_required)
+{
+ if ((state != WAITING_FOR_DATA && state != STOP_BIT_SENT) || rdptr == wrptr){
+ // Already busy transmitting a bit
+ return;
+ }
+
+ if (state == WAITING_FOR_DATA) {
+ // Starting to transmit from the idle - ensure the time is valid so that
+ // the select case will trigger
+ timer tmr;
+ tmr :> t;
+
+ // Indicate to the OUTPUTTING_START_BIT state that the time needs to be
+ // re-synchronised
+ clock_sync_required = 1;
+ }
+
+ state = OUTPUTTING_START_BIT;
+}
+
+[[combinable]]
+void uart_tx_buffered(server interface uart_tx_buffered_if i,
+ server interface uart_config_if ?config,
+ const static unsigned buf_length,
+ unsigned baud,
+ uart_parity_t parity,
+ unsigned bits_per_byte,
+ unsigned stop_bits,
+ client output_gpio_if p_txd)
+{
+ uint8_t buffer[buf_length];
+ int bit_time = XS1_TIMER_HZ / baud;
+ enum uart_tx_state state = WAITING_FOR_DATA;
+ uint8_t byte;
+ timer tmr;
+ size_t rdptr = 0, wrptr = 0;
+ unsigned bit_count, stop_bit_count;
+ int clock_sync_required = 0;
+ int parity_val;
+
+ assert(!UART_TX_DISABLE_DYNAMIC_CONFIG || isnull(config));
+ assert((bits_per_byte > 0) && (bits_per_byte <= 8) && "Invalid number of bits per byte");
+
+ int t;
+ p_txd.output(1);
+
+ // Inform the client that there is space
+ i.ready_to_transmit();
+
+ while (1) {
+ select {
+ case (state != WAITING_FOR_DATA) => tmr when timerafter(t) :> void:
+ switch (state) {
+ case OUTPUTTING_START_BIT:
+ p_txd.output(0);
+
+ if (clock_sync_required) {
+ // Re-align clock with the start of frame
+ tmr :> t;
+ clock_sync_required = 0;
+ }
+ t += bit_time;
+ state = OUTPUTTING_DATA_BIT;
+
+ byte = buffer[rdptr];
+ rdptr++;
+ if (rdptr == buf_length) {
+ rdptr = 0;
+ }
+
+ // Trace the outgoing data
+ //xscope_char(UART_TX_VALUE, byte);
+
+ bit_count = 0;
+
+ // Inform the client that there is space
+ i.ready_to_transmit();
+
+ break;
+ case OUTPUTTING_DATA_BIT:
+ p_txd.output((byte >> bit_count));
+ t += bit_time;
+ bit_count++;
+ if (bit_count == bits_per_byte) {
+ if (parity != UART_PARITY_NONE) {
+ state = OUTPUTTING_PARITY_BIT;
+ parity_val = parity32(byte, parity);
+ } else if (stop_bits) {
+ stop_bit_count = stop_bits;
+ state = OUTPUTTING_STOP_BIT;
+ } else {
+ state = STOP_BIT_SENT;
+ }
+ }
+ break;
+ case OUTPUTTING_PARITY_BIT:
+ p_txd.output(parity_val);
+ t += bit_time;
+ if (stop_bits) {
+ stop_bit_count = stop_bits;
+ state = OUTPUTTING_STOP_BIT;
+ } else {
+ state = STOP_BIT_SENT;
+ }
+ break;
+ case OUTPUTTING_STOP_BIT:
+ p_txd.output(1);
+ t += bit_time;
+ stop_bit_count--;
+ if (stop_bit_count == 0) {
+ state = STOP_BIT_SENT;
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ }
+ break;
+ case STOP_BIT_SENT:
+ state = WAITING_FOR_DATA;
+ break;
+ }
+ break;
+ // Handle client interaction with the component
+ case i.write(uint8_t data) -> int buffer_was_full:
+ if (buffer_full(rdptr, wrptr, buf_length)) {
+ buffer_was_full = 1;
+ return;
+ }
+ buffer_was_full = 0;
+ buffer[wrptr] = data;
+ wrptr++;
+ if (wrptr == buf_length) {
+ wrptr = 0;
+ }
+
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ break;
+
+ case i.get_available_buffer_size(void) -> size_t available:
+ int size = rdptr - wrptr;
+ if (size <= 0)
+ size += buf_length - 1;
+ available = size;
+ break;
+
+#if !UART_TX_DISABLE_DYNAMIC_CONFIG
+ case !isnull(config) => config.set_baud_rate(unsigned baud_rate):
+ bit_time = XS1_TIMER_HZ / baud_rate;
+ state = WAITING_FOR_DATA;
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ break;
+ case !isnull(config) => config.set_parity(uart_parity_t new_parity):
+ parity = new_parity;
+ state = WAITING_FOR_DATA;
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ break;
+ case !isnull(config) => config.set_stop_bits(unsigned new_stop_bits):
+ stop_bits = new_stop_bits;
+ state = WAITING_FOR_DATA;
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ break;
+ case !isnull(config) => config.set_bits_per_byte(unsigned bpb):
+ assert((bpb > 0) && (bpb <= 8) && "Invalid number of bits per byte");
+ bits_per_byte = bpb;
+ state = WAITING_FOR_DATA;
+ init_transmit(rdptr, wrptr, state, t, clock_sync_required);
+ break;
+#endif
+ }
+ }
+}
diff --git a/lib_uart/tests/__init__.py b/lib_uart/tests/__init__.py
new file mode 100644
index 0000000..4cee009
--- /dev/null
+++ b/lib_uart/tests/__init__.py
@@ -0,0 +1 @@
+# Here for importy things.
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test/.cproject b/lib_uart/tests/app_uart_test/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test/.project b/lib_uart/tests/app_uart_test/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test/.xproject b/lib_uart/tests/app_uart_test/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test/LICENSE.txt b/lib_uart/tests/app_uart_test/LICENSE.txt
new file mode 100644
index 0000000..8b30cb4
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2014-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test/Makefile b/lib_uart/tests/app_uart_test/Makefile
new file mode 100644
index 0000000..655c8d0
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/Makefile
@@ -0,0 +1,38 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt" --plugin LoopbackPort.dll '-port tile[0] XS1_PORT_1A 1 0 -port tile[1] XS1_PORT_1B 1 0'
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test/README.rst b/lib_uart/tests/app_uart_test/README.rst
new file mode 100644
index 0000000..c6f7cb3
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/README.rst
@@ -0,0 +1,12 @@
+UART rx/tx regression test
+==========================
+
+:scope: Example
+:description: Regression test for uart rx/tx components
+:keywords: uart, testing
+
+This application provides a simple regression test harness for the
+uart rx/tx components. It tests the components in various
+configurations based on a simulator looping back the pins between the
+two components.
+
diff --git a/lib_uart/tests/app_uart_test/config.xscope b/lib_uart/tests/app_uart_test/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test/src/debug_conf.h b/lib_uart/tests/app_uart_test/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test/src/uart_test.xc b/lib_uart/tests/app_uart_test/src/uart_test.xc
new file mode 100644
index 0000000..5c96f6b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test/src/uart_test.xc
@@ -0,0 +1,225 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+static void check_no_rx_data(client uart_rx_if i_uart_rx,
+ unsigned timeout,
+ int &result)
+{
+ timer t;
+ unsigned time;
+ t :> time;
+ select {
+ case t when timerafter(time + timeout) :> void:
+ return;
+ case i_uart_rx.data_ready():
+ printhexln(i_uart_rx.read());
+ result = 0;
+ return;
+ }
+ __builtin_unreachable();
+}
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ client uart_rx_if i_uart_rx,
+ client uart_config_if i_rx_config,
+ unsigned baud_rate)
+{
+ unsigned char byte;
+ timer t;
+ unsigned time;
+
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+
+ // Configure RX, TX
+ i_rx_config.set_baud_rate(baud_rate);
+ i_tx_config.set_baud_rate(baud_rate);
+
+ int result = 1;
+ debug_printf("Performing basic loopback test.\n");
+ i_uart_tx.write(0x0);
+
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x0);
+
+ i_uart_tx.write(0x2c);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x2c);
+
+ i_uart_tx.write(0x0A);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x0A);
+
+ i_uart_tx.write(0x04);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x04);
+
+ debug_printf("TEST RESULT:basic_loopback:%s\n", result ? "PASS" : "FAIL");
+
+ if (CHECK_EVENTS) {
+ debug_printf("Check we can event on incoming data.\n");
+ result = 1;
+ t :> time;
+ i_uart_tx.write(173);
+ select {
+ case t when timerafter(time + BITTIME(baud_rate) * 20) :> void:
+ // Shouldn't get here.
+ debug_printf("timeout (data not ready)");
+ result = 0;
+ break;
+ case i_uart_rx.data_ready():
+ byte = i_uart_rx.read();
+ result &= (byte == 173);
+ break;
+ }
+ debug_printf("TEST RESULT:rx_notification:%s\n", result ? "PASS" : "FAIL");
+ }
+
+ if (CHECK_BUFFERING) {
+ result = 1;
+ unsigned char data[] = { 0b10111111, 0x55, 0x2c, 0x09};
+ debug_printf("Testing buffering of %d bytes.\n", ARRAY_SIZE(data));
+ for (unsigned i = 0; i < ARRAY_SIZE(data); i++) {
+ i_uart_tx.write(data[i]);
+ }
+ t :> time;
+ t when timerafter(time + BITTIME(baud_rate) * 11 * 4) :> void;
+ for (unsigned i = 0; i < ARRAY_SIZE(data); i++) {
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == data[i]);
+ }
+ debug_printf("TEST RESULT:rx_buffer:%s\n", result ? "PASS" : "FAIL");
+ }
+
+ if (CHECK_RUNTIME_PARAMETER_CHANGE) {
+ // Reconfigure
+ debug_printf("Reconfiguring UART.\n");
+ result = 1;
+ i_rx_config.set_baud_rate(baud_rate/2);
+ i_rx_config.set_stop_bits(10);
+ i_rx_config.set_bits_per_byte(7);
+ i_tx_config.set_baud_rate(baud_rate/2);
+ i_tx_config.set_stop_bits(10);
+ i_tx_config.set_bits_per_byte(7);
+
+ i_uart_tx.write(0x12);
+ i_uart_tx.write(0x5a);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x12);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x5a);
+
+ debug_printf("TEST RESULT:reconfiguration:%s\n", result ? "PASS" : "FAIL");
+
+ debug_printf("Reconfiguring parity to odd.\n");
+ result = 1;
+ // Check parity
+ i_rx_config.set_bits_per_byte(8);
+ i_tx_config.set_bits_per_byte(8);
+ i_rx_config.set_parity(UART_PARITY_ODD);
+ i_tx_config.set_parity(UART_PARITY_ODD);
+ i_uart_tx.write(0x12);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x12);
+ i_uart_tx.write(0xa4);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0xa4);
+
+ debug_printf("TEST RESULT:reconfigure_parity_odd:%s\n", result ? "PASS" : "FAIL");
+
+ debug_printf("Reconfiguring parity to even.\n");
+ result = 1;
+ // Check parity
+ i_rx_config.set_parity(UART_PARITY_EVEN);
+ i_tx_config.set_parity(UART_PARITY_EVEN);
+ i_uart_tx.write(0x12);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0x12);
+ i_uart_tx.write(0xa4);
+ byte = i_uart_rx.wait_for_data_and_read();
+ result &= (byte == 0xa4);
+
+ debug_printf("TEST RESULT:reconfigure_parity_even:%s\n", result ? "PASS" : "FAIL");
+
+ debug_printf("Reconfiguring back ..\n");
+ i_rx_config.set_baud_rate(baud_rate);
+ i_rx_config.set_stop_bits(1);
+ i_rx_config.set_bits_per_byte(8);
+ i_rx_config.set_parity(UART_PARITY_NONE);
+ i_tx_config.set_baud_rate(baud_rate);
+ i_tx_config.set_stop_bits(1);
+ i_tx_config.set_bits_per_byte(8);
+ i_tx_config.set_parity(UART_PARITY_NONE);
+ }
+
+
+ if (CHECK_PARITY_ERRORS) {
+ debug_printf("Checking that invalid parity information is discarded.\n");
+ result = 1;
+ i_rx_config.set_parity(UART_PARITY_ODD);
+ i_tx_config.set_parity(UART_PARITY_EVEN);
+ delay_ticks(1000);
+ i_uart_tx.write(0x55);
+ check_no_rx_data(i_uart_rx, BITTIME(baud_rate) * 200, result);
+
+ i_rx_config.set_parity(UART_PARITY_EVEN);
+ i_tx_config.set_parity(UART_PARITY_ODD);
+ delay_ticks(1000);
+ i_uart_tx.write(0x55);
+ check_no_rx_data(i_uart_rx, BITTIME(baud_rate) * 200, result);
+ debug_printf("TEST RESULT:parity_errors:%s\n", result ? "PASS" : "FAIL");
+
+ }
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[1] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_rx_if i_rx;
+ uart_tx_if i_tx;
+ uart_config_if i_rx_config, i_tx_config;
+ input_gpio_if i_gpio_rx;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[1] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[1] : uart_tx(i_tx, i_tx_config,
+ 115200, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, i_rx_config, BUFFER_SIZE,
+ 115200, UART_PARITY_NONE, 8, 1, i_gpio_rx);
+ on tile[0] : {
+ #if SMOKE_TEST
+ unsigned rates[] = {115200};
+ #else
+ unsigned rates[] = {2400, 9600, 19200};
+ #endif
+ for (int i = 0; i < ARRAY_SIZE(rates); i++) {
+ uart_test(i_tx, i_tx_config, i_rx, i_rx_config, rates[i]);
+ }
+ _Exit(0);
+ }
+ par (int i=0;i<6;i++)
+ on tile[0]: while(1);
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_bpb/.cproject b/lib_uart/tests/app_uart_test_bpb/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_bpb/.project b/lib_uart/tests/app_uart_test_bpb/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_bpb/.xproject b/lib_uart/tests/app_uart_test_bpb/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_bpb/LICENSE.txt b/lib_uart/tests/app_uart_test_bpb/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_bpb/Makefile b/lib_uart/tests/app_uart_test_bpb/Makefile
new file mode 100644
index 0000000..1ff7f1a
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/Makefile
@@ -0,0 +1,43 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+bits_per_byte ?= 8
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity) -DBPB=$(bits_per_byte)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity) -DBPB=$(bits_per_byte)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_bpb/README.rst b/lib_uart/tests/app_uart_test_bpb/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_bpb/config.xscope b/lib_uart/tests/app_uart_test_bpb/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_bpb/src/debug_conf.h b/lib_uart/tests/app_uart_test_bpb/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_bpb/src/uart_test.xc b/lib_uart/tests/app_uart_test_bpb/src/uart_test.xc
new file mode 100644
index 0000000..584a742
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_bpb/src/uart_test.xc
@@ -0,0 +1,51 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing tx test.\n");
+ i_uart_tx.write(0x19);
+ i_uart_tx.write(0x12);
+ i_uart_tx.write(0x1A);
+ i_uart_tx.write(0x0F);
+ _Exit(0);
+
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_tx_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx(i_tx, i_tx_config, BAUD, PARITY, BPB, 1, i_gpio_tx[0]);
+ on tile[0] : {
+ uart_test(i_tx, i_tx_config, BAUD);
+ }
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_fast_tx/.cproject b/lib_uart/tests/app_uart_test_fast_tx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_fast_tx/.project b/lib_uart/tests/app_uart_test_fast_tx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_fast_tx/.xproject b/lib_uart/tests/app_uart_test_fast_tx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_fast_tx/LICENSE.txt b/lib_uart/tests/app_uart_test_fast_tx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_fast_tx/Makefile b/lib_uart/tests/app_uart_test_fast_tx/Makefile
new file mode 100644
index 0000000..5eebc19
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_fast_tx/README.rst b/lib_uart/tests/app_uart_test_fast_tx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_fast_tx/config.xscope b/lib_uart/tests/app_uart_test_fast_tx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_fast_tx/src/debug_conf.h b/lib_uart/tests/app_uart_test_fast_tx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_fast_tx/src/uart_test.xc b/lib_uart/tests/app_uart_test_fast_tx/src/uart_test.xc
new file mode 100644
index 0000000..f4d442c
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_fast_tx/src/uart_test.xc
@@ -0,0 +1,38 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (XS1_TIMER_HZ / (x))
+
+static void uart_test(streaming chanend stream, unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n", baud_rate);
+ debug_printf("Performing tx test.\n");
+
+ for(int i = 0; i < 256; i++)
+ uart_tx_streaming_write_byte(stream, i);
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+out port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ streaming chan stream;
+ par {
+ on tile[0] : uart_tx_streaming(p_tx, stream, BITTIME(BAUD));
+ on tile[0] : {
+ uart_test(stream, BAUD);
+ }
+ }
+ return 0;
+ }
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex/.cproject b/lib_uart/tests/app_uart_test_half_duplex/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex/.project b/lib_uart/tests/app_uart_test_half_duplex/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex/.xproject b/lib_uart/tests/app_uart_test_half_duplex/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex/LICENSE.txt b/lib_uart/tests/app_uart_test_half_duplex/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_half_duplex/Makefile b/lib_uart/tests/app_uart_test_half_duplex/Makefile
new file mode 100644
index 0000000..90a6e05
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS) -g
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_half_duplex/README.rst b/lib_uart/tests/app_uart_test_half_duplex/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex/config.xscope b/lib_uart/tests/app_uart_test_half_duplex/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex/src/debug_conf.h b/lib_uart/tests/app_uart_test_half_duplex/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_half_duplex/src/uart_test.xc b/lib_uart/tests/app_uart_test_half_duplex/src/uart_test.xc
new file mode 100644
index 0000000..60ddb53
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex/src/uart_test.xc
@@ -0,0 +1,45 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BUFFER_SIZE 64
+port p_uart = on tile[0] : XS1_PORT_1A;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ client uart_tx_buffered_if i_uart_tx,
+ client uart_control_if i_control,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n", baud_rate);
+ debug_printf("Performing combined test.\n");
+
+ if (i_uart_tx.write(0x7f) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0x00) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0x2f) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0xff) != 0) printstrln("Write failed.");
+
+ timer tmr;
+ int t;
+ tmr :> t;
+ tmr when timerafter(t+(1000000/baud_rate)*10000+50000) :> void;
+ _Exit(0);
+}
+
+int main() {
+ interface uart_rx_if i_rx;
+ interface uart_control_if i_control;
+ interface uart_tx_buffered_if i_tx;
+
+ par {
+ on tile[0] : uart_half_duplex(i_tx, i_rx, i_control, NULL, BUFFER_SIZE, BUFFER_SIZE, BAUD, PARITY, 8, 1, p_uart);
+ on tile[0] : uart_test(i_rx, i_tx, i_control, BAUD);
+ }
+
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/.cproject b/lib_uart/tests/app_uart_test_half_duplex_combined/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/.project b/lib_uart/tests/app_uart_test_half_duplex_combined/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/.xproject b/lib_uart/tests/app_uart_test_half_duplex_combined/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/LICENSE.txt b/lib_uart/tests/app_uart_test_half_duplex_combined/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/Makefile b/lib_uart/tests/app_uart_test_half_duplex_combined/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/README.rst b/lib_uart/tests/app_uart_test_half_duplex_combined/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/config.xscope b/lib_uart/tests/app_uart_test_half_duplex_combined/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/src/debug_conf.h b/lib_uart/tests/app_uart_test_half_duplex_combined/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_half_duplex_combined/src/uart_test.xc b/lib_uart/tests/app_uart_test_half_duplex_combined/src/uart_test.xc
new file mode 100644
index 0000000..3633a26
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_combined/src/uart_test.xc
@@ -0,0 +1,55 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BUFFER_SIZE 64
+port p_uart = on tile[0] : XS1_PORT_1A;
+port sim_notif = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ client uart_tx_buffered_if i_uart_tx,
+ client uart_control_if i_control,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n", baud_rate);
+ debug_printf("Performing combined test.\n");
+
+ if (i_uart_tx.write(0x7f) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0x00) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0x2f) != 0) printstrln("Write failed.");
+ if (i_uart_tx.write(0xff) != 0) printstrln("Write failed.");
+
+ timer tmr;
+ int t;
+ tmr :> t;
+ tmr when timerafter(t+((XS1_TIMER_HZ/baud_rate)*20*4)) :> void;
+ i_control.set_mode(UART_RX_MODE);
+ sim_notif <: 1;
+
+
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ _Exit(0);
+}
+
+int main() {
+ interface uart_rx_if i_rx;
+ interface uart_control_if i_control;
+ interface uart_tx_buffered_if i_tx;
+
+ par {
+ on tile[0] : uart_half_duplex(i_tx, i_rx, i_control, NULL, BUFFER_SIZE, BUFFER_SIZE, BAUD, PARITY, 8, 1, p_uart);
+ on tile[0] : uart_test(i_rx, i_tx, i_control, BAUD);
+ }
+
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/.cproject b/lib_uart/tests/app_uart_test_half_duplex_rx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/.project b/lib_uart/tests/app_uart_test_half_duplex_rx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/.xproject b/lib_uart/tests/app_uart_test_half_duplex_rx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/LICENSE.txt b/lib_uart/tests/app_uart_test_half_duplex_rx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/Makefile b/lib_uart/tests/app_uart_test_half_duplex_rx/Makefile
new file mode 100644
index 0000000..cf74216
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS) -g
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/README.rst b/lib_uart/tests/app_uart_test_half_duplex_rx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/config.xscope b/lib_uart/tests/app_uart_test_half_duplex_rx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/src/debug_conf.h b/lib_uart/tests/app_uart_test_half_duplex_rx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_half_duplex_rx/src/uart_test.xc b/lib_uart/tests/app_uart_test_half_duplex_rx/src/uart_test.xc
new file mode 100644
index 0000000..51329de
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_half_duplex_rx/src/uart_test.xc
@@ -0,0 +1,51 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BUFFER_SIZE 64
+port p_uart = on tile[0] : XS1_PORT_1A;
+port sim_notif = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ client uart_tx_buffered_if i_uart_tx,
+ client uart_control_if i_control,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n", baud_rate);
+ debug_printf("Performing combined test.\n");
+
+ i_control.set_mode(UART_RX_MODE);
+ timer tmr;
+ int t;
+ tmr :> t;
+ tmr when timerafter(t+50000) :> void;
+ sim_notif <: 1;
+
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ tmr :> t;
+ tmr when timerafter(t+50000) :> void;
+ _Exit(0);
+}
+
+int main() {
+ interface uart_rx_if i_rx;
+ interface uart_control_if i_control;
+ interface uart_tx_buffered_if i_tx;
+
+ par {
+ on tile[0] : uart_half_duplex(i_tx, i_rx, i_control, NULL, BUFFER_SIZE, BUFFER_SIZE, 115200, UART_PARITY_NONE, 8, 1, p_uart);
+ on tile[0] : uart_test(i_rx, i_tx, i_control, 115200);
+ }
+
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_intermittent/.cproject b/lib_uart/tests/app_uart_test_intermittent/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_intermittent/.project b/lib_uart/tests/app_uart_test_intermittent/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_intermittent/.xproject b/lib_uart/tests/app_uart_test_intermittent/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_intermittent/LICENSE.txt b/lib_uart/tests/app_uart_test_intermittent/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_intermittent/Makefile b/lib_uart/tests/app_uart_test_intermittent/Makefile
new file mode 100644
index 0000000..5eebc19
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_intermittent/README.rst b/lib_uart/tests/app_uart_test_intermittent/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_intermittent/config.xscope b/lib_uart/tests/app_uart_test_intermittent/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_intermittent/src/debug_conf.h b/lib_uart/tests/app_uart_test_intermittent/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_intermittent/src/uart_test.xc b/lib_uart/tests/app_uart_test_intermittent/src/uart_test.xc
new file mode 100644
index 0000000..de8b896
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_intermittent/src/uart_test.xc
@@ -0,0 +1,55 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+unsigned int seed = 1028472;
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing tx test.\n");
+
+ timer tmr;
+ int t;
+
+ for(int i = 0; i < 64; i++)
+ {
+ // Store the current time in t
+ tmr :> t;
+
+ // Delay until t+some_random
+ crc32(seed, -1, 0xEB31D82E);
+ seed /= 100000;
+ tmr when timerafter(t+seed) :> void;
+ i_uart_tx.write(i);
+ }
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_tx_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx(i_tx, i_tx_config, BAUD, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
+ on tile[0] : {
+ uart_test(i_tx, i_tx_config, BAUD);
+ }
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_loopback/.cproject b/lib_uart/tests/app_uart_test_loopback/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_loopback/.project b/lib_uart/tests/app_uart_test_loopback/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_loopback/.xproject b/lib_uart/tests/app_uart_test_loopback/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_loopback/LICENSE.txt b/lib_uart/tests/app_uart_test_loopback/LICENSE.txt
new file mode 100644
index 0000000..7b55bba
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2016-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_loopback/Makefile b/lib_uart/tests/app_uart_test_loopback/Makefile
new file mode 100644
index 0000000..bd1919c
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/Makefile
@@ -0,0 +1,37 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -O2 -g
+
+XCC_FLAGS_14400 = $(COMMON_FLAGS) -DBAUD=14400
+XCC_FLAGS_28800 = $(COMMON_FLAGS) -DBAUD=28800
+XCC_FLAGS_57600 = $(COMMON_FLAGS) -DBAUD=57600
+XCC_FLAGS_115200 = $(COMMON_FLAGS) -DBAUD=115200
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_loopback/README.rst b/lib_uart/tests/app_uart_test_loopback/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_loopback/config.xscope b/lib_uart/tests/app_uart_test_loopback/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_loopback/src/debug_conf.h b/lib_uart/tests/app_uart_test_loopback/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_loopback/src/uart_test.xc b/lib_uart/tests/app_uart_test_loopback/src/uart_test.xc
new file mode 100644
index 0000000..28144a8
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_loopback/src/uart_test.xc
@@ -0,0 +1,42 @@
+// Copyright (c) 2015-2017, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "xassert.h"
+#include "uart.h"
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_rx_ready = on tile[0] : XS1_PORT_1B;
+port p_tx = on tile[0] : XS1_PORT_1C;
+
+#define BUFFER_SIZE 64
+int main() {
+ interface uart_tx_buffered_if i_tx;
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ output_gpio_if i_gpio_tx[1];
+ par {
+ on tile[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, UART_PARITY_NONE, 8, 1, i_gpio_rx);
+ on tile[0] : uart_tx_buffered(i_tx, null, BUFFER_SIZE, BAUD,
+ UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
+
+ on tile[0]: {
+ printf("TEST CONFIG:{'baud rate':%d}\n", BAUD);
+ printf("Performing rx test.\n");
+ p_rx_ready <: 1;
+
+ for (int i = 0; i < 4; i++) {
+ unsigned char ch = i_rx.wait_for_data_and_read();
+ i_tx.write(ch);
+ }
+ // Wait for the byte to be sent (data + start + stop)
+ delay_ticks(2*10*100000000/BAUD);
+ _Exit(0);
+ }
+ }
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_multi_rx/.cproject b/lib_uart/tests/app_uart_test_multi_rx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_multi_rx/.project b/lib_uart/tests/app_uart_test_multi_rx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_multi_rx/.xproject b/lib_uart/tests/app_uart_test_multi_rx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_multi_rx/LICENSE.txt b/lib_uart/tests/app_uart_test_multi_rx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_multi_rx/Makefile b/lib_uart/tests/app_uart_test_multi_rx/Makefile
new file mode 100644
index 0000000..0c9bab2
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/Makefile
@@ -0,0 +1,41 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_multi_rx/README.rst b/lib_uart/tests/app_uart_test_multi_rx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_multi_rx/config.xscope b/lib_uart/tests/app_uart_test_multi_rx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_multi_rx/src/debug_conf.h b/lib_uart/tests/app_uart_test_multi_rx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_multi_rx/src/uart_test.xc b/lib_uart/tests/app_uart_test_multi_rx/src/uart_test.xc
new file mode 100644
index 0000000..56cd161
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_rx/src/uart_test.xc
@@ -0,0 +1,66 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+
+#include "debug_print.h"
+
+// Ports for TRIANGLE slice & startKIT slice
+in buffered port:32 p_uart_rx = XS1_PORT_8B;
+port p_uart_clk = XS1_PORT_1L;
+port sim_notif = XS1_PORT_1A;
+
+clock clk_uart = XS1_CLKBLK_4;
+
+void test(streaming chanend c_rx, client multi_uart_rx_if i_rx)
+{
+ debug_printf("Performing multi_uart rx test.\n");
+
+ i_rx.init(c_rx);
+
+ sim_notif <: 1;
+
+ size_t slot;
+ uint8_t data;
+
+ i_rx.pause();
+ i_rx.set_baud_rate(2, BAUD/2);
+ i_rx.restart();
+ for(int i = 0; i < 8;)
+ {
+ select {
+ case multi_uart_data_ready(c_rx, slot):
+ if (i_rx.read(slot, data) == UART_RX_VALID_DATA)
+ {
+ debug_printf("0x%x from UART %d\n", data, slot);
+ i++;
+ }
+ else
+ {
+ debug_printf("Failed to read from slot %d\n", slot);
+ }
+ break;
+ }
+ }
+
+ _Exit(0);
+}
+
+int main(void)
+{
+ streaming chan c_rx;
+
+ interface multi_uart_rx_if i_rx;
+
+ configure_clock_src(clk_uart, p_uart_clk);
+ configure_in_port(p_uart_rx, clk_uart);
+
+ start_clock(clk_uart);
+
+ par {
+ multi_uart_rx(c_rx, i_rx, p_uart_rx, 3, 1843200, BAUD, UART_PARITY_NONE, 8, 1);
+ test(c_rx, i_rx);
+ }
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_multi_tx/.cproject b/lib_uart/tests/app_uart_test_multi_tx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_multi_tx/.project b/lib_uart/tests/app_uart_test_multi_tx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_multi_tx/.xproject b/lib_uart/tests/app_uart_test_multi_tx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_multi_tx/LICENSE.txt b/lib_uart/tests/app_uart_test_multi_tx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_multi_tx/Makefile b/lib_uart/tests/app_uart_test_multi_tx/Makefile
new file mode 100644
index 0000000..741052e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/Makefile
@@ -0,0 +1,41 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DINTERNAL_CLOCK=$(internal_clock)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DINTERNAL_CLOCK=$(internal_clock)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_multi_tx/README.rst b/lib_uart/tests/app_uart_test_multi_tx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_multi_tx/config.xscope b/lib_uart/tests/app_uart_test_multi_tx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_multi_tx/src/debug_conf.h b/lib_uart/tests/app_uart_test_multi_tx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_multi_tx/src/uart_test.xc b/lib_uart/tests/app_uart_test_multi_tx/src/uart_test.xc
new file mode 100644
index 0000000..c426f96
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_multi_tx/src/uart_test.xc
@@ -0,0 +1,53 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+#include
+#include
+#include
+#include
+
+#include "debug_print.h"
+
+
+in buffered port:32 p_uart_rx = XS1_PORT_8A;
+out buffered port:8 p_uart_tx = XS1_PORT_8B;
+in port p_uart_clk = XS1_PORT_1F;
+
+clock clk_uart = XS1_CLKBLK_4;
+
+void test(chanend c_tx, client multi_uart_tx_if i_tx)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n", BAUD);
+ debug_printf("Performing multi_uart tx test.\n");
+ i_tx.init(c_tx);
+
+ i_tx.write(1, 0X7f);
+ i_tx.write(1, 0x00);
+ i_tx.write(1, 0x2f);
+ i_tx.write(1, 0xff);
+
+ timer tmr;
+ int t;
+ tmr :> t;
+ tmr when timerafter(t+(4*(XS1_TIMER_HZ/BAUD)*20)) :> void;
+ _Exit(0);
+}
+
+int main(void)
+{
+ chan c_tx;
+ interface multi_uart_tx_if i_tx;
+
+#if INTERNAL_CLOCK
+ #define CLK_RATE XS1_TIMER_HZ
+#else
+ configure_clock_src(clk_uart, p_uart_clk);
+ configure_out_port(p_uart_tx, clk_uart, 0);
+
+ start_clock(clk_uart);
+ #define CLK_RATE 230400
+#endif
+ par {
+ multi_uart_tx(c_tx, i_tx, p_uart_tx, 8, CLK_RATE, BAUD, UART_PARITY_NONE, 8, 1);
+ test(c_tx, i_tx);
+ }
+ return 0;
+}
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_parity/.cproject b/lib_uart/tests/app_uart_test_parity/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_parity/.project b/lib_uart/tests/app_uart_test_parity/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_parity/.xproject b/lib_uart/tests/app_uart_test_parity/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_parity/LICENSE.txt b/lib_uart/tests/app_uart_test_parity/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_parity/Makefile b/lib_uart/tests/app_uart_test_parity/Makefile
new file mode 100644
index 0000000..74e0bd4
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS) -g
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_parity/README.rst b/lib_uart/tests/app_uart_test_parity/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_parity/config.xscope b/lib_uart/tests/app_uart_test_parity/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_parity/src/debug_conf.h b/lib_uart/tests/app_uart_test_parity/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_parity/src/uart_test.xc b/lib_uart/tests/app_uart_test_parity/src/uart_test.xc
new file mode 100644
index 0000000..8b7a40c
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_parity/src/uart_test.xc
@@ -0,0 +1,50 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing tx test.\n");
+ i_uart_tx.write(0x7F);
+ i_uart_tx.write(0x00);
+ i_uart_tx.write(0x2F);
+ i_uart_tx.write(0xFF);
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_tx_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx(i_tx, i_tx_config, BAUD, PARITY, 8, 1, i_gpio_tx[0]);
+ on tile[0] : {
+ uart_test(i_tx, i_tx_config, BAUD);
+ }
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_rx/.cproject b/lib_uart/tests/app_uart_test_rx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx/.project b/lib_uart/tests/app_uart_test_rx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx/.xproject b/lib_uart/tests/app_uart_test_rx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx/LICENSE.txt b/lib_uart/tests/app_uart_test_rx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx/Makefile b/lib_uart/tests/app_uart_test_rx/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx/README.rst b/lib_uart/tests/app_uart_test_rx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx/config.xscope b/lib_uart/tests/app_uart_test_rx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx/src/uart_test.xc
new file mode 100644
index 0000000..697b4b4
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx/src/uart_test.xc
@@ -0,0 +1,61 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx, unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+ int t;
+ timer tmr;
+ tmr :> t;
+
+ for(int i = 0; i < 4;){
+ select
+ {
+ // Default timeout of 20 bit times
+ case tmr when timerafter(t + BITTIME(baud_rate)*40) :> void:
+ _Exit(0);
+ return;
+
+ case i_uart_rx.data_ready():
+ printf("0x%02x\n", i_uart_rx.read());
+ i++;
+ tmr :> t;
+ break;
+ }
+ }
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, UART_PARITY_NONE, 8, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_rx_bad/.cproject b/lib_uart/tests/app_uart_test_rx_bad/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_bad/.project b/lib_uart/tests/app_uart_test_rx_bad/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_bad/.xproject b/lib_uart/tests/app_uart_test_rx_bad/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_bad/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_bad/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_bad/Makefile b/lib_uart/tests/app_uart_test_rx_bad/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_bad/README.rst b/lib_uart/tests/app_uart_test_rx_bad/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_bad/config.xscope b/lib_uart/tests/app_uart_test_rx_bad/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_bad/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_bad/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_bad/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_bad/src/uart_test.xc
new file mode 100644
index 0000000..71f4f52
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bad/src/uart_test.xc
@@ -0,0 +1,62 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx, unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+ int t;
+ timer tmr;
+ tmr :> t;
+
+ for(int i = 0; i < 4;){
+ select
+ {
+ // Default timeout of 20 bit times
+ case tmr when timerafter(t + BITTIME(baud_rate)*40) :> void:
+ _Exit(0);
+ return;
+
+ case i_uart_rx.data_ready():
+ printf("0x%02x\n", i_uart_rx.read());
+ i++;
+ tmr :> t;
+ break;
+ }
+ }
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, UART_PARITY_EVEN, 8, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/.cproject b/lib_uart/tests/app_uart_test_rx_bpb/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/.project b/lib_uart/tests/app_uart_test_rx_bpb/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/.xproject b/lib_uart/tests/app_uart_test_rx_bpb/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_bpb/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/Makefile b/lib_uart/tests/app_uart_test_rx_bpb/Makefile
new file mode 100644
index 0000000..e63deaa
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity) -DBPB=$(bits_per_byte)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity) -DBPB=$(bits_per_byte)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/README.rst b/lib_uart/tests/app_uart_test_rx_bpb/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/config.xscope b/lib_uart/tests/app_uart_test_rx_bpb/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_bpb/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_bpb/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_bpb/src/uart_test.xc
new file mode 100644
index 0000000..1ba6b23
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_bpb/src/uart_test.xc
@@ -0,0 +1,60 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+
+ for(int i = 0; i < 4; i++)
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, PARITY, BPB, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+
+ // uart_rx_if i_rx;
+ // uart_config_if i_rx_config;
+ // input_gpio_if i_gpio_rx;
+ // par {
+
+ // on tile[0] : uart_rx(i_rx, i_rx_config, BAUD, PARITY, 8, 1, i_gpio_rx);
+ // on tile[0] : {
+ // uart_test(i_rx, i_rx_config, BAUD);
+ // }
+ // }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/.cproject b/lib_uart/tests/app_uart_test_rx_intermittent/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/.project b/lib_uart/tests/app_uart_test_rx_intermittent/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/.xproject b/lib_uart/tests/app_uart_test_rx_intermittent/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_intermittent/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/Makefile b/lib_uart/tests/app_uart_test_rx_intermittent/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/README.rst b/lib_uart/tests/app_uart_test_rx_intermittent/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/config.xscope b/lib_uart/tests/app_uart_test_rx_intermittent/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_intermittent/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_intermittent/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_intermittent/src/uart_test.xc
new file mode 100644
index 0000000..3462bcb
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_intermittent/src/uart_test.xc
@@ -0,0 +1,59 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+
+ for(int i = 0; i < 50; i++)
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, UART_PARITY_NONE, 8, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+
+ // uart_rx_if i_rx;
+ // uart_config_if i_rx_config;
+ // input_gpio_if i_gpio_rx;
+ // par {
+
+ // on tile[0] : uart_rx(i_rx, i_rx_config, BAUD, PARITY, 8, 1, i_gpio_rx);
+ // on tile[0] : {
+ // uart_test(i_rx, i_rx_config, BAUD);
+ // }
+ // }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_rx_large/.cproject b/lib_uart/tests/app_uart_test_rx_large/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_large/.project b/lib_uart/tests/app_uart_test_rx_large/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_large/.xproject b/lib_uart/tests/app_uart_test_rx_large/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_large/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_large/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_large/Makefile b/lib_uart/tests/app_uart_test_rx_large/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_large/README.rst b/lib_uart/tests/app_uart_test_rx_large/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_large/config.xscope b/lib_uart/tests/app_uart_test_rx_large/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_large/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_large/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_large/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_large/src/uart_test.xc
new file mode 100644
index 0000000..2bfb7fc
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_large/src/uart_test.xc
@@ -0,0 +1,60 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+
+ for(int i = 0; i < 128; i++)
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, PARITY, 8, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+
+ // uart_rx_if i_rx;
+ // uart_config_if i_rx_config;
+ // input_gpio_if i_gpio_rx;
+ // par {
+
+ // on tile[0] : uart_rx(i_rx, i_rx_config, BAUD, PARITY, 8, 1, i_gpio_rx);
+ // on tile[0] : {
+ // uart_test(i_rx, i_rx_config, BAUD);
+ // }
+ // }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_rx_parity/.cproject b/lib_uart/tests/app_uart_test_rx_parity/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_parity/.project b/lib_uart/tests/app_uart_test_rx_parity/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_parity/.xproject b/lib_uart/tests/app_uart_test_rx_parity/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_parity/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_parity/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_parity/Makefile b/lib_uart/tests/app_uart_test_rx_parity/Makefile
new file mode 100644
index 0000000..67277d5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DPARITY=$(parity)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_parity/README.rst b/lib_uart/tests/app_uart_test_rx_parity/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_parity/config.xscope b/lib_uart/tests/app_uart_test_rx_parity/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_parity/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_parity/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_parity/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_parity/src/uart_test.xc
new file mode 100644
index 0000000..8d0d91a
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_parity/src/uart_test.xc
@@ -0,0 +1,61 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx, unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ // Output on TX so the test framework knows the client is up
+ p_tx <: 1;
+ int t;
+ timer tmr;
+ tmr :> t;
+
+ for(int i = 0; i < 4;){
+ select
+ {
+ // Default timeout of 20 bit times
+ case tmr when timerafter(t + BITTIME(baud_rate)*40) :> void:
+ _Exit(0);
+ return;
+
+ case i_uart_rx.data_ready():
+ printf("0x%02x\n", i_uart_rx.read());
+ i++;
+ tmr :> t;
+ break;
+ }
+ }
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, PARITY, 8, 1, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/.cproject b/lib_uart/tests/app_uart_test_rx_stopbits/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/.project b/lib_uart/tests/app_uart_test_rx_stopbits/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/.xproject b/lib_uart/tests/app_uart_test_rx_stopbits/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/LICENSE.txt b/lib_uart/tests/app_uart_test_rx_stopbits/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/Makefile b/lib_uart/tests/app_uart_test_rx_stopbits/Makefile
new file mode 100644
index 0000000..4fa0899
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DSTOPBITS=$(stop_bits)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DSTOPBITS=$(stop_bits)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/README.rst b/lib_uart/tests/app_uart_test_rx_stopbits/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/config.xscope b/lib_uart/tests/app_uart_test_rx_stopbits/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/src/debug_conf.h b/lib_uart/tests/app_uart_test_rx_stopbits/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_rx_stopbits/src/uart_test.xc b/lib_uart/tests/app_uart_test_rx_stopbits/src/uart_test.xc
new file mode 100644
index 0000000..23a98d6
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_rx_stopbits/src/uart_test.xc
@@ -0,0 +1,48 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+static void uart_test(client uart_rx_if i_uart_rx,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing rx test.\n");
+ p_tx <: 1;
+
+ for(int i = 0; i < 4; i++)
+ printf("0x%02x\n", i_uart_rx.wait_for_data_and_read());
+
+ _Exit(0);
+}
+
+#define BUFFER_SIZE 64
+int main() {
+
+ interface uart_rx_if i_rx;
+ input_gpio_if i_gpio_rx;
+ par {
+ on tile[0].core[0] : input_gpio_1bit_with_events(i_gpio_rx, p_rx);
+ on tile[0].core[0] : uart_rx(i_rx, null, BUFFER_SIZE, BAUD, UART_PARITY_NONE, 8, STOPBITS, i_gpio_rx);
+ on tile[0]: uart_test(i_rx, BAUD);
+ }
+
+ return 0;
+}
diff --git a/lib_uart/tests/app_uart_test_stopbits/.cproject b/lib_uart/tests/app_uart_test_stopbits/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_stopbits/.project b/lib_uart/tests/app_uart_test_stopbits/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_stopbits/.xproject b/lib_uart/tests/app_uart_test_stopbits/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_stopbits/LICENSE.txt b/lib_uart/tests/app_uart_test_stopbits/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_stopbits/Makefile b/lib_uart/tests/app_uart_test_stopbits/Makefile
new file mode 100644
index 0000000..4fa0899
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud) -DSTOPBITS=$(stop_bits)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud) -DSTOPBITS=$(stop_bits)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_stopbits/README.rst b/lib_uart/tests/app_uart_test_stopbits/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_stopbits/config.xscope b/lib_uart/tests/app_uart_test_stopbits/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_stopbits/src/debug_conf.h b/lib_uart/tests/app_uart_test_stopbits/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_stopbits/src/uart_test.xc b/lib_uart/tests/app_uart_test_stopbits/src/uart_test.xc
new file mode 100644
index 0000000..9402bf0
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_stopbits/src/uart_test.xc
@@ -0,0 +1,51 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+
+#define CHECK_EVENTS 1
+#define CHECK_BUFFERING 1
+#define CHECK_RUNTIME_PARAMETER_CHANGE 1
+#define CHECK_PARITY_ERRORS 1
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing tx test.\n");
+ i_uart_tx.write(0x7F);
+ i_uart_tx.write(0x00);
+ i_uart_tx.write(0x2F);
+ i_uart_tx.write(0xFF);
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_tx_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx(i_tx, i_tx_config, BAUD, UART_PARITY_NONE, 8, STOPBITS, i_gpio_tx[0]);
+ on tile[0] : {
+ uart_test(i_tx, i_tx_config, BAUD);
+ // _Exit(0);
+ }
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_tx/.cproject b/lib_uart/tests/app_uart_test_tx/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_tx/.project b/lib_uart/tests/app_uart_test_tx/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_tx/.xproject b/lib_uart/tests/app_uart_test_tx/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_tx/LICENSE.txt b/lib_uart/tests/app_uart_test_tx/LICENSE.txt
new file mode 100644
index 0000000..8148733
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2015-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_tx/Makefile b/lib_uart/tests/app_uart_test_tx/Makefile
new file mode 100644
index 0000000..5eebc19
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/Makefile
@@ -0,0 +1,42 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS_smoke = $(COMMON_FLAGS) -DSMOKE_TEST=1 -DBAUD=$(baud)
+XCC_FLAGS_full = $(COMMON_FLAGS) -DFULL_TEST=1 -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+test: bin/app_uart_test.xe
+ $(info Baud: $(baud))
+ xsim bin/app_uart_test.xe --xscope "-offline uart_test.xmt"
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_tx/README.rst b/lib_uart/tests/app_uart_test_tx/README.rst
new file mode 100644
index 0000000..77c838f
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/README.rst
@@ -0,0 +1,10 @@
+UART rx/tx regression test
+==========================
+
+:scope: Directed Test
+:description: Regression test for uart rx parity
+:keywords: uart, testing
+
+This application tests the uart rx for various parities of data, with correct
+disposal of packets with incorrect parity.
+
diff --git a/lib_uart/tests/app_uart_test_tx/config.xscope b/lib_uart/tests/app_uart_test_tx/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_tx/src/debug_conf.h b/lib_uart/tests/app_uart_test_tx/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_tx/src/uart_test.xc b/lib_uart/tests/app_uart_test_tx/src/uart_test.xc
new file mode 100644
index 0000000..3274442
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx/src/uart_test.xc
@@ -0,0 +1,43 @@
+// Copyright (c) 2015-2016, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BITTIME(x) (100000000 / (x))
+
+
+static void uart_test(client uart_tx_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing tx test.\n");
+
+ for(int i = 0; i < 128; i++)
+ i_uart_tx.write(i);
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+
+#define BUFFER_SIZE 64
+int main() {
+ uart_tx_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx(i_tx, i_tx_config, BAUD, UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
+ on tile[0] : {
+ uart_test(i_tx, i_tx_config, BAUD);
+ }
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/.cproject b/lib_uart/tests/app_uart_test_tx_buffered/.cproject
new file mode 100644
index 0000000..d5f8f4e
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/.cproject
@@ -0,0 +1,524 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmake
+
+ all
+ true
+ true
+ true
+
+
+ xmake
+
+ clean
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/.project b/lib_uart/tests/app_uart_test_tx_buffered/.project
new file mode 100644
index 0000000..6eba22b
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/.project
@@ -0,0 +1,76 @@
+
+
+ app_uart_test
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?children?
+ ?name?=outputEntries\|?children?=?name?=entry\\\\|\\|\||
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.buildArguments
+ CONFIG=Debug
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ xmake
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+ com.xmos.cdt.core.XdeProjectNature
+
+
+
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/.xproject b/lib_uart/tests/app_uart_test_tx_buffered/.xproject
new file mode 100644
index 0000000..ce540a5
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/.xproject
@@ -0,0 +1 @@
+sc_uartXM-001906-SM
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/LICENSE.txt b/lib_uart/tests/app_uart_test_tx_buffered/LICENSE.txt
new file mode 100644
index 0000000..7b55bba
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/LICENSE.txt
@@ -0,0 +1,135 @@
+Software Release License Agreement
+
+Copyright (c) 2016-2017, 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 UART library software
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/Makefile b/lib_uart/tests/app_uart_test_tx_buffered/Makefile
new file mode 100644
index 0000000..b1756ad
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/Makefile
@@ -0,0 +1,37 @@
+# The TARGET variable determines what target system the application is
+# compiled for. It either refers to an XN file in the source directories
+# or a valid argument for the --target option when compiling.
+
+TARGET = SLICEKIT-L16
+
+# The APP_NAME variable determines the name of the final .xe file. It should
+# not include the .xe postfix. If left blank the name will default to
+# the project name
+
+APP_NAME =
+
+# The flags passed to xcc when building the application
+# You can also set the following to override flags for a particular language:
+#
+# XCC_XC_FLAGS, XCC_C_FLAGS, XCC_ASM_FLAGS, XCC_CPP_FLAGS
+#
+# If the variable XCC_MAP_FLAGS is set it overrides the flags passed to
+# xcc for the final link (mapping) stage.
+
+COMMON_FLAGS = -save-temps -O2 -report $(EXTRA_FLAGS)
+
+baud ?= 115200
+parity ?= UART_PARITY_NONE
+
+XCC_FLAGS = $(COMMON_FLAGS) -DBAUD=$(baud)
+
+# The USED_MODULES variable lists other module used by the application.
+
+USED_MODULES = lib_uart lib_xassert lib_logging
+
+#=============================================================================
+# 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
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/config.xscope b/lib_uart/tests/app_uart_test_tx_buffered/config.xscope
new file mode 100644
index 0000000..732fa24
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/config.xscope
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/src/debug_conf.h b/lib_uart/tests/app_uart_test_tx_buffered/src/debug_conf.h
new file mode 100644
index 0000000..97455ea
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/src/debug_conf.h
@@ -0,0 +1,5 @@
+// Copyright (c) 2014-2016, XMOS Ltd, All rights reserved
+#define DEBUG_PRINT_ENABLE 1
+#define XASSERT_ENABLE_ASSERTIONS 1
+#define XASSERT_ENABLE_DEBUG 1
+#define XASSERT_ENABLE_LINE_NUMBERS 1
diff --git a/lib_uart/tests/app_uart_test_tx_buffered/src/uart_test.xc b/lib_uart/tests/app_uart_test_tx_buffered/src/uart_test.xc
new file mode 100644
index 0000000..5464999
--- /dev/null
+++ b/lib_uart/tests/app_uart_test_tx_buffered/src/uart_test.xc
@@ -0,0 +1,59 @@
+// Copyright (c) 2015-2017, XMOS Ltd, All rights reserved
+
+#include
+#include
+#include
+#include "debug_print.h"
+#include "xassert.h"
+#include "uart.h"
+
+#define BUFFER_SIZE 64
+
+static void uart_test(client uart_tx_buffered_if i_uart_tx,
+ client uart_config_if i_tx_config,
+ unsigned baud_rate)
+{
+ debug_printf("TEST CONFIG:{'baud rate':%d}\n",baud_rate);
+ debug_printf("Performing buffered tx test.\n");
+
+ for (int i = 0; i < 128; i++) {
+ select {
+ case i_uart_tx.ready_to_transmit():
+ i_uart_tx.write(i);
+ break;
+ }
+ }
+
+ // Wait for the data to have been transmitted
+ while(1) {
+ if (i_uart_tx.get_available_buffer_size() == (BUFFER_SIZE-1)) {
+ break;
+ }
+ delay_microseconds(1);
+ }
+
+ // Wait until the last byte has been transmitted
+ timer tmr;
+ int t;
+ tmr :> t;
+ tmr when timerafter(t+(1000000/baud_rate)*10000+50000) :> void;
+
+ _Exit(0);
+}
+
+port p_rx = on tile[0] : XS1_PORT_1A;
+port p_tx = on tile[0] : XS1_PORT_1B;
+
+int main() {
+ interface uart_tx_buffered_if i_tx;
+ uart_config_if i_tx_config;
+ output_gpio_if i_gpio_tx[1];
+ par {
+
+ on tile[0] : output_gpio(i_gpio_tx, 1, p_tx, null);
+ on tile[0] : uart_tx_buffered(i_tx, i_tx_config, BUFFER_SIZE, BAUD,
+ UART_PARITY_NONE, 8, 1, i_gpio_tx[0]);
+ on tile[0] : uart_test(i_tx, i_tx_config, BAUD);
+ }
+ return 0;
+ }
diff --git a/lib_uart/tests/multi_uart_tx_test/LICENSE.txt b/lib_uart/tests/multi_uart_tx_test/LICENSE.txt
new file mode 100644
index 0000000..b5d011e
--- /dev/null
+++ b/lib_uart/tests/multi_uart_tx_test/LICENSE.txt
@@ -0,0 +1,279 @@
+Software Release License Agreement
+
+Copyright (c) 2015, XMOS, All rights reserved.
+
+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)
+
+1. Definitions
+ 1. "Licence" means this Software Licence and any schedules or annexes to it.
+
+ "Licence Fee" means the fee for the XMOS Software as detailed in the
+ Schedule.
+
+ "Licensee Modifications" means all developments and
+ modifications of the XMOS Software developed independently by
+ You.
+
+ "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
+ the Schedule.
+
+ "XMOS Software" means the XMOS software detailed in the Schedule,
+ (including related programmer comments and documentation, if any)
+ and error corrections, improvements, modifications (including
+ XMOS Modifications) and updates.
+
+ 2. The headings in this Licence do not affect its
+ interpretation. Save where the context otherwise requires,
+ references to clauses and schedules are to clauses and schedules of
+ this Licence.
+
+ 3. Unless the context otherwise requires:
+ 1. references to the Supplier and the Customer include their
+ permitted successors and assigns;
+
+ 2. references to statutory provisions include those statutory
+ provisions as amended or re-enacted; and
+
+ 3. references to any gender include all genders.
+
+ 4. Words in the singular include the plural and in the plural
+ include the singular.
+
+ 2. Licence
+
+ XMOS grants the Customer a non-exclusive licence to use, develop
+ and modify the XMOS Software with, or for the purpose of being
+ used with, XMOS Hardware.
+
+ 3. Consideration
+
+ In consideration of the mutual obligations contained in this
+ Licence, the parties agree to its terms.
+
+ 4. Term
+
+ Subject to clause 12 below, this Licence shall be perpetual.
+
+ 5. Restrictions on Use
+
+ 1. The Customer may distribute the XMOS Software (in object
+ code only) subject to clause 2.
+
+ 2. The Customer may not sell, distribute, lease or sublicense
+ the XMOS Software as standalone software, whether as object
+ or source code. 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
+
+ 1. 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
+ licence basis.
+
+ 2. XMOS will own all intellectual property rights in the XMOS
+ Modifications.
+
+ 3. The Customer may only use the Licensee Modifications and
+ XMOS Modifications on, or in relation to, XMOS Hardware.
+
+ 7. Support
+
+ 1. Support of the XMOS Software may be provided by XMOS
+ pursuant to a separate support agreement (the "XMOS Support
+ Agreement"). In the absence of a separate support agreement,
+ support may be found via the XMOS website.
+
+ 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 licence 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 LICENCE, 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 Licence 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
+ other than in accordance with the terms of this Licence.
+
+ 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. Consequently, subject to Clause 5, 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
+
+ 1. Either party may terminate this Licence at any time on
+ written notice to the other if the other:
+
+ 1. is in material or persistent breach of any of the
+ terms of this Licence 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
+
+ 2. 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.
+
+ 2. 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.
+
+ 3. On termination for any reason:
+
+ 1. all rights granted to the Customer under this
+ Licence shall cease;
+
+ 2. the Customer shall cease all activities authorised
+ by this Licence;
+
+ 3. the Customer shall immediately pay to the Supplier
+ any sums due to the Supplier under this Licence; and
+
+ 4. the Customer shall immediately destroy or return to
+ the Supplier (at the Supplier's option) all copies of
+ the XMOS Software then in its possession, custody or
+ control and, in the case of destruction, certify to the
+ Supplier that it has done so.
+
+ 4. Clauses 8, 9, 10 and 11 shall survive any effective
+ termination of this Agreement.
+
+ 13. Third party rights
+
+ No term of this Licence is intended to confer a benefit on, or
+ to be enforceable by, any person who is not a party to this
+ licence.
+
+ 14. Confidentiality and publicity
+
+ 1. Each party shall, during the term of this Licence 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 licence, or subsequently comes lawfully into the
+ possession of such party from a third party.
+
+ 2. The terms of this licence are confidential and may not be
+ disclosed by the Customer without the prior written consent
+ of XMOS.
+
+ 3. The provisions of clause 14 shall remain in full force and
+ effect notwithstanding termination of this licence for any
+ reason.
+
+ 15. Entire agreement
+
+ This Licence and the documents annexed as appendices to this
+ Licence 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 Licence or any of the rights
+ granted under it without XMOS's prior written consent.
+
+ 17. Governing law and jurisdiction
+
+ This Licence 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.
+
+Schedule
+XMOS UART library software
+No license fee.
diff --git a/lib_uart/tests/runtests.py b/lib_uart/tests/runtests.py
new file mode 100644
index 0000000..04001a3
--- /dev/null
+++ b/lib_uart/tests/runtests.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+import xmostest
+
+if __name__ == "__main__":
+ xmostest.init()
+
+ xmostest.register_group("lib_uart",
+ "sim_regression",
+ "Uart Simulator Regression",
+ """
+ Several tests are performed in simulation with a loopback between the UART Tx
+ and Rx ports. This tests the features of the individual components,
+ verifying them against each other. The various options and use cases of the
+ components are tested.
+ """)
+
+ xmostest.register_group("lib_uart", "sim_regression", "Uart Transmission Test",
+ """
+ """)
+
+
+ xmostest.runtests()
+
+
+ xmostest.finish()
diff --git a/lib_uart/tests/test_half_duplex_combined.expect b/lib_uart/tests/test_half_duplex_combined.expect
new file mode 100644
index 0000000..4f1b448
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_combined.expect
@@ -0,0 +1,27 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing combined test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x7f, 0x00, 0x2f, 0xff
+0x7f
+0x00
+0x2f
+0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_half_duplex_combined.py b/lib_uart/tests/test_half_duplex_combined.py
new file mode 100644
index 0000000..e263c20
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_combined.py
@@ -0,0 +1,34 @@
+import xmostest
+from uart_half_duplex_checker import UARTHalfDuplexChecker, Parity as Parity
+
+
+def do_test(baud, parity):
+ myenv = {'baud': baud, 'parity': parity}
+ path = "app_uart_test_half_duplex_combined"
+ resources = xmostest.request_resource("xsim")
+
+ hd_checker = UARTHalfDuplexChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B",
+ Parity[parity], baud, 4, 1, 8)
+
+ tester = xmostest.ComparisonTester(open('test_half_duplex_combined.expect'),
+ "lib_uart", "sim_regression", "half_duplex_combined", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != "UART_PARITY_NONE":
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_half_duplex_combined/bin/smoke/app_uart_test_half_duplex_combined_smoke.xe',
+ simthreads=[hd_checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for parity in ["UART_PARITY_EVEN", "UART_PARITY_ODD", "UART_PARITY_NONE"]:
+ for baud in [57600, 115200]:
+ do_test(baud, parity)
diff --git a/lib_uart/tests/test_half_duplex_rx_uart.expect b/lib_uart/tests/test_half_duplex_rx_uart.expect
new file mode 100644
index 0000000..78c06fa
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_rx_uart.expect
@@ -0,0 +1,6 @@
+TEST CONFIG:{'baud rate':115200}
+Performing combined test.
+0x7f
+0x00
+0x2f
+0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_half_duplex_rx_uart.py b/lib_uart/tests/test_half_duplex_rx_uart.py
new file mode 100644
index 0000000..a6d4424
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_rx_uart.py
@@ -0,0 +1,31 @@
+import xmostest
+from uart_rx_checker import UARTRxChecker, Parity as RxParity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_half_duplex_rx"
+ resources = xmostest.request_resource("xsim")
+
+ rx_checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", RxParity['UART_PARITY_NONE'], baud, 1, 8)
+
+ tester = xmostest.ComparisonTester(open('test_half_duplex_rx_uart.expect'),
+ "lib_uart", "sim_regression", "half_duplex_tx_simple", myenv,
+ regexp=True)
+
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_half_duplex_rx/bin/smoke/app_uart_test_half_duplex_rx_smoke.xe',
+ simthreads=[rx_checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_half_duplex_tx_uart.expect b/lib_uart/tests/test_half_duplex_tx_uart.expect
new file mode 100644
index 0000000..5e27eb0
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_tx_uart.expect
@@ -0,0 +1,23 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing combined test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x7f, 0x00, 0x2f, 0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_half_duplex_tx_uart.py b/lib_uart/tests/test_half_duplex_tx_uart.py
new file mode 100644
index 0000000..d1c8311
--- /dev/null
+++ b/lib_uart/tests/test_half_duplex_tx_uart.py
@@ -0,0 +1,33 @@
+import xmostest
+from uart_tx_checker import UARTTxChecker, Parity as TxParity
+
+
+def do_test(baud, parity):
+ myenv = {'baud': baud, 'parity': parity}
+ path = "app_uart_test_half_duplex"
+ resources = xmostest.request_resource("xsim")
+
+ tx_checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1A", TxParity[parity], baud, 4, 1, 8)
+
+ tester = xmostest.ComparisonTester(open('test_half_duplex_tx_uart.expect'),
+ "lib_uart", "sim_regression", "half_duplex_tx_simple", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != "UART_PARITY_NONE":
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_half_duplex/bin/smoke/app_uart_test_half_duplex_smoke.xe',
+ simthreads=[tx_checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [115200, 57600, 28800]:
+ for parity in ['UART_PARITY_NONE', 'UART_PARITY_EVEN', 'UART_PARITY_ODD']:
+ do_test(baud, parity)
diff --git a/lib_uart/tests/test_loopback_uart.expect b/lib_uart/tests/test_loopback_uart.expect
new file mode 100644
index 0000000..f579f0a
--- /dev/null
+++ b/lib_uart/tests/test_loopback_uart.expect
@@ -0,0 +1,23 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x7f, 0x00, 0x2f, 0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_loopback_uart.py b/lib_uart/tests/test_loopback_uart.py
new file mode 100644
index 0000000..dc247bd
--- /dev/null
+++ b/lib_uart/tests/test_loopback_uart.py
@@ -0,0 +1,36 @@
+import xmostest
+
+from uart_rx_checker import UARTRxChecker, Parity as RxParity
+from uart_tx_checker import UARTTxChecker, Parity as TxParity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ resources = xmostest.request_resource("xsim")
+
+ rx_checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B",
+ RxParity['UART_PARITY_NONE'], baud, 1, 8)
+
+ tx_checker = UARTTxChecker("tile[0]:XS1_PORT_1D", "tile[0]:XS1_PORT_1C",
+ TxParity['UART_PARITY_NONE'], baud, 4, 1, 8)
+
+ tester = xmostest.ComparisonTester(open('test_loopback_uart.expect'),
+ "lib_uart", "sim_regression", "loopback", myenv,
+ regexp=True)
+
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_loopback/bin/{}/app_uart_test_loopback_{}.xe'.format(baud, baud),
+ simthreads=[rx_checker, tx_checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -functions -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 28800, 57600, 115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_rx_bad_uart.expect b/lib_uart/tests/test_rx_bad_uart.expect
new file mode 100644
index 0000000..6aa0a1d
--- /dev/null
+++ b/lib_uart/tests/test_rx_bad_uart.expect
@@ -0,0 +1,4 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x..( We only expect 2 numbers to be printed. Depends whether we're sending bad even/odd parities which will be sent)?
+0x..
\ No newline at end of file
diff --git a/lib_uart/tests/test_rx_bad_uart.py b/lib_uart/tests/test_rx_bad_uart.py
new file mode 100644
index 0000000..1106361
--- /dev/null
+++ b/lib_uart/tests/test_rx_bad_uart.py
@@ -0,0 +1,32 @@
+import xmostest
+
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_rx_bad"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_BAD'], baud, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_rx_bad_uart.expect'),
+ "lib_uart", "sim_regression", "rx_bad", myenv,
+ regexp=True)
+
+ # Only want no parity @ 230400 baud for smoke tests
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_bad/bin/smoke/app_uart_test_rx_bad_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_rx_bpb_uart.expect b/lib_uart/tests/test_rx_bpb_uart.expect
new file mode 100644
index 0000000..bd2f62e
--- /dev/null
+++ b/lib_uart/tests/test_rx_bpb_uart.expect
@@ -0,0 +1,6 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x00
+0x1a
+0x07
+0x12
\ No newline at end of file
diff --git a/lib_uart/tests/test_rx_bpb_uart.py b/lib_uart/tests/test_rx_bpb_uart.py
new file mode 100644
index 0000000..49ddc37
--- /dev/null
+++ b/lib_uart/tests/test_rx_bpb_uart.py
@@ -0,0 +1,36 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud, parity, bpb):
+ myenv = {'parity': parity, 'baud': baud, 'bits_per_byte': bpb}
+ path = "app_uart_test_rx_bpb"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B",
+ Parity[parity], baud, 1, bpb,
+ [0x00, 0x1a, 0x07, 0x12])
+ tester = xmostest.ComparisonTester(open('test_rx_bpb_uart.expect'),
+ "lib_uart", "sim_regression", "rx_bpb", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != 'UART_PARITY_NONE':
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_bpb/bin/smoke/app_uart_test_rx_bpb_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 57600, 115200]:
+ for parity in ['UART_PARITY_NONE', 'UART_PARITY_ODD', 'UART_PARITY_EVEN']:
+ for bpb in [5, 7, 8]:
+ do_test(baud, parity, bpb)
diff --git a/lib_uart/tests/test_rx_intermittent.py b/lib_uart/tests/test_rx_intermittent.py
new file mode 100644
index 0000000..24394ee
--- /dev/null
+++ b/lib_uart/tests/test_rx_intermittent.py
@@ -0,0 +1,34 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud, 'parity': 'UART_PARITY_EVEN'}
+ path = "app_uart_test_rx_intermittent"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B",
+ Parity['UART_PARITY_BAD'], baud, 1, 8,
+ data=range(50), intermittent=True)
+ tester = xmostest.ComparisonTester(open('test_rx_intermittent_uart.expect'),
+ "lib_uart", "sim_regression", "rx_intermittent", myenv,
+ regexp=True)
+
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_intermittent/bin/smoke/app_uart_test_rx_intermittent_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_rx_intermittent_uart.expect b/lib_uart/tests/test_rx_intermittent_uart.expect
new file mode 100644
index 0000000..1349b2c
--- /dev/null
+++ b/lib_uart/tests/test_rx_intermittent_uart.expect
@@ -0,0 +1,52 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x00
+0x01
+0x02
+0x03
+0x04
+0x05
+0x06
+0x07
+0x08
+0x09
+0x0a
+0x0b
+0x0c
+0x0d
+0x0e
+0x0f
+0x10
+0x11
+0x12
+0x13
+0x14
+0x15
+0x16
+0x17
+0x18
+0x19
+0x1a
+0x1b
+0x1c
+0x1d
+0x1e
+0x1f
+0x20
+0x21
+0x22
+0x23
+0x24
+0x25
+0x26
+0x27
+0x28
+0x29
+0x2a
+0x2b
+0x2c
+0x2d
+0x2e
+0x2f
+0x30
+0x31
\ No newline at end of file
diff --git a/lib_uart/tests/test_rx_large_uart.expect b/lib_uart/tests/test_rx_large_uart.expect
new file mode 100644
index 0000000..96dae26
--- /dev/null
+++ b/lib_uart/tests/test_rx_large_uart.expect
@@ -0,0 +1,130 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x00
+0x01
+0x02
+0x03
+0x04
+0x05
+0x06
+0x07
+0x08
+0x09
+0x0a
+0x0b
+0x0c
+0x0d
+0x0e
+0x0f
+0x10
+0x11
+0x12
+0x13
+0x14
+0x15
+0x16
+0x17
+0x18
+0x19
+0x1a
+0x1b
+0x1c
+0x1d
+0x1e
+0x1f
+0x20
+0x21
+0x22
+0x23
+0x24
+0x25
+0x26
+0x27
+0x28
+0x29
+0x2a
+0x2b
+0x2c
+0x2d
+0x2e
+0x2f
+0x30
+0x31
+0x32
+0x33
+0x34
+0x35
+0x36
+0x37
+0x38
+0x39
+0x3a
+0x3b
+0x3c
+0x3d
+0x3e
+0x3f
+0x40
+0x41
+0x42
+0x43
+0x44
+0x45
+0x46
+0x47
+0x48
+0x49
+0x4a
+0x4b
+0x4c
+0x4d
+0x4e
+0x4f
+0x50
+0x51
+0x52
+0x53
+0x54
+0x55
+0x56
+0x57
+0x58
+0x59
+0x5a
+0x5b
+0x5c
+0x5d
+0x5e
+0x5f
+0x60
+0x61
+0x62
+0x63
+0x64
+0x65
+0x66
+0x67
+0x68
+0x69
+0x6a
+0x6b
+0x6c
+0x6d
+0x6e
+0x6f
+0x70
+0x71
+0x72
+0x73
+0x74
+0x75
+0x76
+0x77
+0x78
+0x79
+0x7a
+0x7b
+0x7c
+0x7d
+0x7e
+0x7f
\ No newline at end of file
diff --git a/lib_uart/tests/test_rx_large_uart.py b/lib_uart/tests/test_rx_large_uart.py
new file mode 100644
index 0000000..8fb7008
--- /dev/null
+++ b/lib_uart/tests/test_rx_large_uart.py
@@ -0,0 +1,33 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud, parity):
+ myenv = {'baud': baud, 'parity': parity}
+ path = "app_uart_test_rx_large"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity[parity], baud, 1, 8, range(128))
+ tester = xmostest.ComparisonTester(open('test_rx_large_uart.expect'),
+ "lib_uart", "sim_regression", "rx_large", myenv,
+ regexp=True)
+
+ # This test takes some time, nightly only
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_large/bin/smoke/app_uart_test_rx_large_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for parity in ['UART_PARITY_EVEN', 'UART_PARITY_ODD', 'UART_PARITY_NONE']:
+ for baud in [57600, 115200]:
+ do_test(baud, parity)
diff --git a/lib_uart/tests/test_rx_multi_uart.expect b/lib_uart/tests/test_rx_multi_uart.expect
new file mode 100644
index 0000000..a0c6e71
--- /dev/null
+++ b/lib_uart/tests/test_rx_multi_uart.expect
@@ -0,0 +1,9 @@
+Performing multi_uart rx test.
+0x7F from UART 0
+0xAA from UART 2
+0x0 from UART 0
+0x2F from UART 0
+0x1 from UART 2
+0xFF from UART 0
+0xFC from UART 2
+0x8E from UART 2
diff --git a/lib_uart/tests/test_rx_multi_uart.py b/lib_uart/tests/test_rx_multi_uart.py
new file mode 100644
index 0000000..59cb312
--- /dev/null
+++ b/lib_uart/tests/test_rx_multi_uart.py
@@ -0,0 +1,37 @@
+import xmostest
+from uart_rx_checker import DriveHigh, UARTRxChecker, Parity as RxParity
+from uart_clock_device import UARTClockDevice
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_multi_rx"
+ resources = xmostest.request_resource("xsim")
+
+ rx_checker = UARTRxChecker("tile[0]:XS1_PORT_8B.0", "tile[0]:XS1_PORT_1A", RxParity['UART_PARITY_NONE'], baud, 1, 8, data=[0x7f, 0x00, 0x2f, 0xff])
+ rx_checker2 = UARTRxChecker("tile[0]:XS1_PORT_8B.2", "tile[0]:XS1_PORT_1A", RxParity['UART_PARITY_NONE'], baud/2, 1, 8, data=[0xaa, 0x01, 0xfc, 0x8e])
+ uart_clock = UARTClockDevice("tile[0]:XS1_PORT_1L", 1843200)
+
+ drive_high0 = DriveHigh("tile[0]:XS1_PORT_8B.1")
+
+ tester = xmostest.ComparisonTester(open('test_rx_multi_uart.expect'),
+ "lib_uart", "sim_regression", "multi_rx_simple", myenv,
+ regexp=True)
+
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_multi_rx/bin/smoke/app_uart_test_multi_rx_smoke.xe',
+ simthreads=[drive_high0, rx_checker, rx_checker2, uart_clock],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--trace-to", "trace", "--vcd-tracing", "-tile tile[0] -pads -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200]:
+# for baud in [115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_rx_parity_uart.expect b/lib_uart/tests/test_rx_parity_uart.expect
new file mode 100644
index 0000000..a343959
--- /dev/null
+++ b/lib_uart/tests/test_rx_parity_uart.expect
@@ -0,0 +1,6 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x7f
+0x00
+0x2f
+0xff
diff --git a/lib_uart/tests/test_rx_parity_uart.py b/lib_uart/tests/test_rx_parity_uart.py
new file mode 100644
index 0000000..0a7f97e
--- /dev/null
+++ b/lib_uart/tests/test_rx_parity_uart.py
@@ -0,0 +1,34 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud, parity):
+ myenv = {'baud': baud, 'parity': parity}
+ path = "app_uart_test_rx_parity"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity[parity], baud, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_rx_parity_uart.expect'),
+ "lib_uart", "sim_regression", "rx_parity", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != "UART_PARITY_NONE":
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_parity/bin/smoke/app_uart_test_rx_parity_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for parity in ['UART_PARITY_EVEN', 'UART_PARITY_ODD', 'UART_PARITY_NONE']:
+ for baud in [14400, 28800, 57600, 115200]:
+ do_test(baud, parity)
diff --git a/lib_uart/tests/test_rx_stopbits_uart.expect b/lib_uart/tests/test_rx_stopbits_uart.expect
new file mode 100644
index 0000000..cfb4184
--- /dev/null
+++ b/lib_uart/tests/test_rx_stopbits_uart.expect
@@ -0,0 +1,6 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x7f
+0x00
+0x2f
+0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_rx_stopbits_uart.py b/lib_uart/tests/test_rx_stopbits_uart.py
new file mode 100644
index 0000000..1f77063
--- /dev/null
+++ b/lib_uart/tests/test_rx_stopbits_uart.py
@@ -0,0 +1,34 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud, stopbits):
+ myenv = {'stop_bits': stopbits, 'baud': baud}
+ path = "app_uart_test_rx_stopbits"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B",
+ Parity['UART_PARITY_NONE'], baud, stopbits, 8)
+ tester = xmostest.ComparisonTester(open('test_rx_stopbits_uart.expect'),
+ "lib_uart", "sim_regression", "rx_stopbits", myenv,
+ regexp=True)
+
+ # Only want 115200 baud w/ 2 stopbits for smoke tests
+ if baud != 115200 or stopbits != 2:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx_stopbits/bin/smoke/app_uart_test_rx_stopbits_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 57600, 115200]:
+ for stopbits in [1, 2, 3]:
+ do_test(baud, stopbits)
diff --git a/lib_uart/tests/test_rx_uart.expect b/lib_uart/tests/test_rx_uart.expect
new file mode 100644
index 0000000..a343959
--- /dev/null
+++ b/lib_uart/tests/test_rx_uart.expect
@@ -0,0 +1,6 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing rx test.
+0x7f
+0x00
+0x2f
+0xff
diff --git a/lib_uart/tests/test_rx_uart.py b/lib_uart/tests/test_rx_uart.py
new file mode 100644
index 0000000..25d8578
--- /dev/null
+++ b/lib_uart/tests/test_rx_uart.py
@@ -0,0 +1,31 @@
+import xmostest
+
+from uart_rx_checker import UARTRxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_rx"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTRxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_rx_uart.expect'),
+ "lib_uart", "sim_regression", "rx", myenv,
+ regexp=True)
+
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_rx/bin/smoke/app_uart_test_rx_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -ports -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 28800, 57600, 115200]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_tx_bpb_uart.expect b/lib_uart/tests/test_tx_bpb_uart.expect
new file mode 100644
index 0000000..77a617c
--- /dev/null
+++ b/lib_uart/tests/test_tx_bpb_uart.expect
@@ -0,0 +1,23 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing tx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x19, 0x12, 0x1a, 0x0f
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_bpb_uart.py b/lib_uart/tests/test_tx_bpb_uart.py
new file mode 100644
index 0000000..10c87b6
--- /dev/null
+++ b/lib_uart/tests/test_tx_bpb_uart.py
@@ -0,0 +1,34 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud, parity, bpb):
+ myenv = {'parity': parity, 'baud': baud, 'bits_per_byte': bpb}
+ path = "app_uart_test_bpb"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity[parity], baud, 4, 1, bpb)
+ tester = xmostest.ComparisonTester(open('test_tx_bpb_uart.expect'),
+ "lib_uart", "sim_regression", "tx_bpb", myenv,
+ regexp=True)
+
+ # Only want even parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != 'UART_PARITY_EVEN':
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_bpb/bin/smoke/app_uart_test_bpb_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [115200, 230400]:
+ for parity in ['UART_PARITY_NONE', 'UART_PARITY_EVEN', 'UART_PARITY_ODD']:
+ for bpb in [5, 7, 8]:
+ do_test(baud, parity, bpb)
diff --git a/lib_uart/tests/test_tx_buffered.expect b/lib_uart/tests/test_tx_buffered.expect
new file mode 100644
index 0000000..f7553bc
--- /dev/null
+++ b/lib_uart/tests/test_tx_buffered.expect
@@ -0,0 +1,643 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing buffered tx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_buffered.py b/lib_uart/tests/test_tx_buffered.py
new file mode 100644
index 0000000..da4031a
--- /dev/null
+++ b/lib_uart/tests/test_tx_buffered.py
@@ -0,0 +1,31 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_tx"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 128, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_tx_buffered.expect'),
+ "lib_uart", "sim_regression", "tx_buffered", myenv,
+ regexp=True)
+
+ # This test is long, only run on nightly
+# tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_tx_buffered/bin/app_uart_test_tx_buffered.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200, 230400]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_tx_fast_uart.py b/lib_uart/tests/test_tx_fast_uart.py
new file mode 100644
index 0000000..43222b3
--- /dev/null
+++ b/lib_uart/tests/test_tx_fast_uart.py
@@ -0,0 +1,33 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_fast_tx"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 256, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_tx_uart.expect'),
+ "lib_uart", "sim_regression", "tx_fast", myenv,
+ regexp=True)
+
+ # Only want no parity @ 230400 baud for smoke tests
+ if baud != 230400:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_fast_tx/bin/smoke/app_uart_test_fast_tx_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ return False
+ # for baud in [230400, 460800, 921600]:
+ # do_test(baud)
diff --git a/lib_uart/tests/test_tx_intermittent_uart.expect b/lib_uart/tests/test_tx_intermittent_uart.expect
new file mode 100644
index 0000000..8a5c4ad
--- /dev/null
+++ b/lib_uart/tests/test_tx_intermittent_uart.expect
@@ -0,0 +1,323 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing tx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_intermittent_uart.py b/lib_uart/tests/test_tx_intermittent_uart.py
new file mode 100644
index 0000000..4df44fd
--- /dev/null
+++ b/lib_uart/tests/test_tx_intermittent_uart.py
@@ -0,0 +1,32 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_intermittent"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 64, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_tx_intermittent_uart.expect'),
+ "lib_uart", "sim_regression", "tx_intermittent", myenv,
+ regexp=True)
+
+ # Only want no parity @ 230400 baud for smoke tests
+ if baud != 230400:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_intermittent/bin/smoke/app_uart_test_intermittent_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200, 230400]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_tx_multi_uart.expect b/lib_uart/tests/test_tx_multi_uart.expect
new file mode 100644
index 0000000..43e4e4e
--- /dev/null
+++ b/lib_uart/tests/test_tx_multi_uart.expect
@@ -0,0 +1,23 @@
+TEST CONFIG:{'baud rate':\d+}
+Performing multi_uart tx test.
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x7f, 0x00, 0x2f, 0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_multi_uart.py b/lib_uart/tests/test_tx_multi_uart.py
new file mode 100644
index 0000000..d1a6ee0
--- /dev/null
+++ b/lib_uart/tests/test_tx_multi_uart.py
@@ -0,0 +1,35 @@
+import xmostest
+from uart_tx_checker import UARTTxChecker, Parity as TxParity
+from uart_clock_device import UARTClockDevice
+
+
+def do_test(baud, internal_clock):
+ myenv = {'baud': baud, 'internal_clock': internal_clock}
+ path = "app_uart_test_multi_tx"
+ resources = xmostest.request_resource("xsim")
+
+ tx_checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_8B.1", TxParity['UART_PARITY_NONE'], baud, 4, 1, 8)
+ uart_clock = UARTClockDevice("tile[0]:XS1_PORT_1F", 230400)
+
+ tester = xmostest.ComparisonTester(open('test_tx_multi_uart.expect'),
+ "lib_uart", "sim_regression", "multi_tx_simple", myenv,
+ regexp=True)
+
+ # Only want no parity @ 230400 baud for smoke tests
+ if baud != 115200:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_multi_tx/bin/smoke/app_uart_test_multi_tx_smoke.xe',
+ simthreads=[tx_checker, uart_clock],
+ xscope_io=True,
+ tester=tester,
+ simargs=["--vcd-tracing", "-tile tile[0] -pads -o trace.vcd"],
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200]:
+ for internal_clock in [0, 1]:
+ do_test(baud, internal_clock)
diff --git a/lib_uart/tests/test_tx_parity_uart.expect b/lib_uart/tests/test_tx_parity_uart.expect
new file mode 100644
index 0000000..2405104
--- /dev/null
+++ b/lib_uart/tests/test_tx_parity_uart.expect
@@ -0,0 +1,23 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing tx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x7f, 0x00, 0x2f, 0xff
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_parity_uart.py b/lib_uart/tests/test_tx_parity_uart.py
new file mode 100644
index 0000000..d5522e7
--- /dev/null
+++ b/lib_uart/tests/test_tx_parity_uart.py
@@ -0,0 +1,33 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud, parity):
+ myenv = {'parity': parity, 'baud': baud}
+ path = "app_uart_test_parity"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity[parity], baud, 4, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_tx_parity_uart.expect'),
+ "lib_uart", "sim_regression", "tx_parity", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or parity != 'UART_PARITY_EVEN':
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_parity/bin/smoke/app_uart_test_parity_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 57600, 115200, 230400]:
+ for parity in ['UART_PARITY_NONE', 'UART_PARITY_EVEN', 'UART_PARITY_ODD']:
+ do_test(baud, parity)
diff --git a/lib_uart/tests/test_tx_stopbits_uart.py b/lib_uart/tests/test_tx_stopbits_uart.py
new file mode 100644
index 0000000..3e00c2d
--- /dev/null
+++ b/lib_uart/tests/test_tx_stopbits_uart.py
@@ -0,0 +1,34 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud, stopbits):
+ myenv = {'baud': baud, 'stop_bits': stopbits}
+ path = "app_uart_test_stopbits"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 4, stopbits,
+ 8)
+ tester = xmostest.ComparisonTester(open('test_tx_parity_uart.expect'),
+ "lib_uart", "sim_regression", "tx_stopbits", myenv,
+ regexp=True)
+
+ # Only want no parity @ 115200 baud for smoke tests
+ if baud != 115200 or stopbits != 2:
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_stopbits/bin/smoke/app_uart_test_stopbits_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [14400, 57600, 115200, 230400]:
+ for stopbits in [1, 2, 3]:
+ do_test(baud, stopbits)
diff --git a/lib_uart/tests/test_tx_uart.expect b/lib_uart/tests/test_tx_uart.expect
new file mode 100644
index 0000000..b050730
--- /dev/null
+++ b/lib_uart/tests/test_tx_uart.expect
@@ -0,0 +1,643 @@
+tx starts high: True
+TEST CONFIG:{'baud rate':\d+}
+Performing tx test.
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+tx starts high: True
+Start bit recv'd
+Parity bit correct
+tx ends high: True
+
+0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
\ No newline at end of file
diff --git a/lib_uart/tests/test_tx_uart.py b/lib_uart/tests/test_tx_uart.py
new file mode 100644
index 0000000..570812f
--- /dev/null
+++ b/lib_uart/tests/test_tx_uart.py
@@ -0,0 +1,31 @@
+import xmostest
+import os
+from xmostest.xmostest_subprocess import call
+from uart_tx_checker import UARTTxChecker, Parity
+
+
+def do_test(baud):
+ myenv = {'baud': baud}
+ path = "app_uart_test_tx"
+ resources = xmostest.request_resource("xsim")
+
+ checker = UARTTxChecker("tile[0]:XS1_PORT_1A", "tile[0]:XS1_PORT_1B", Parity['UART_PARITY_NONE'], baud, 128, 1, 8)
+ tester = xmostest.ComparisonTester(open('test_tx_uart.expect'),
+ "lib_uart", "sim_regression", "tx", myenv,
+ regexp=True)
+
+ # This test is long, only run on nightly
+ tester.set_min_testlevel('nightly')
+
+ xmostest.run_on_simulator(resources['xsim'],
+ 'app_uart_test_tx/bin/smoke/app_uart_test_tx_smoke.xe',
+ simthreads=[checker],
+ xscope_io=True,
+ tester=tester,
+ clean_before_build=True,
+ build_env=myenv)
+
+
+def runtest():
+ for baud in [57600, 115200, 230400]:
+ do_test(baud)
diff --git a/lib_uart/tests/test_uart.py b/lib_uart/tests/test_uart.py
new file mode 100644
index 0000000..f6b4536
--- /dev/null
+++ b/lib_uart/tests/test_uart.py
@@ -0,0 +1,25 @@
+import xmostest
+
+
+class UartTester(xmostest.Tester):
+ def __init__(self):
+ super(UartTester, self).__init__()
+ self.register_test("lib_uart", "sim_regression", "loopback_test", {})
+
+ def run(self, output):
+ result = True
+ for line in output:
+ if line.find("FAIL") != -1:
+ result = False
+ xmostest.set_test_result("lib_uart", "sim_regression", "loopback_test",
+ {}, result, output=''.join(output))
+
+
+def runtest():
+ resources = xmostest.request_resource("xsim")
+ # xmostest.run_on_simulator(resources['xsim'],
+ # 'app_uart_test/bin/smoke/app_uart_test_smoke.xe',
+ # xscope_io=True,
+ # loopback=[{'from': 'tile[0]:XS1_PORT_1A',
+ # 'to': 'tile[1]:XS1_PORT_1B'}],
+ # tester=UartTester())
diff --git a/lib_uart/tests/uart_clock_device.py b/lib_uart/tests/uart_clock_device.py
new file mode 100644
index 0000000..51e5614
--- /dev/null
+++ b/lib_uart/tests/uart_clock_device.py
@@ -0,0 +1,27 @@
+import xmostest
+
+class UARTClockDevice(xmostest.SimThread):
+ def __init__(self, clock_port, clock_frequency):
+ """
+ Create a clock input to a given port for the XCore.
+
+ :param: clock_port Port to clock
+ :param: clock_frequency Frequency in Hz of the clock
+ """
+ self._clock_port = clock_port
+ self._clock_frequency = clock_frequency
+
+ def run(self):
+ xsi = self.xsi
+ time = xsi.get_time()
+
+ # (1s/(freq))/2 = T for 1 edge. 1s = 1e9ns, 0.5s = 5e8ns
+ half_period_ns = float(5e8) / self._clock_frequency
+ while True:
+ xsi.drive_port_pins(self._clock_port, 1)
+ self.wait_until(time + half_period_ns)
+ time += half_period_ns
+
+ xsi.drive_port_pins(self._clock_port, 0)
+ self.wait_until(time + half_period_ns)
+ time += half_period_ns
diff --git a/lib_uart/tests/uart_half_duplex_checker.py b/lib_uart/tests/uart_half_duplex_checker.py
new file mode 100644
index 0000000..5ee2bfc
--- /dev/null
+++ b/lib_uart/tests/uart_half_duplex_checker.py
@@ -0,0 +1,47 @@
+from uart_tx_checker import UARTTxChecker as TxC
+from uart_rx_checker import UARTRxChecker as RxC
+
+import xmostest
+
+
+Parity = dict(
+ UART_PARITY_EVEN=0,
+ UART_PARITY_ODD=1,
+ UART_PARITY_NONE=2,
+)
+
+
+class UARTHalfDuplexChecker(xmostest.SimThread):
+ def __init__(self, rx_port, tx_port, notif_port, parity, baud, length, stop_bits, bpb):
+ self._rx_port = rx_port
+ self._tx_port = tx_port
+ self._notif_port = notif_port
+ self._parity = parity
+ self._baud = baud
+ self._length = length
+ self._stop_bits = stop_bits
+ self._bits_per_byte = bpb
+
+ self._tx = TxC(rx_port, tx_port, parity, baud, length, stop_bits, bpb)
+ self._rx = RxC(rx_port, tx_port, parity, baud, stop_bits, bpb)
+
+ def do_read_test(self, xsi):
+ # Device reads 4 bytes from UART.
+ [self._rx.send_byte(xsi, byte) for byte in [0x7f, 0x00, 0x2f, 0xff]]
+
+ def do_write_test(self, xsi):
+ # Device sends 4 bytes down UART
+ k = self._tx.read_packet(self.xsi, self._parity, self._length)
+ print ", ".join(map((lambda x: "0x%02x" % ord(x)), k))
+
+ def run(self):
+ # Wait for the xcore to bring the uart tx port up
+ self.wait((lambda x: self.xsi.is_port_driving(self._tx_port)))
+
+ self._tx.xsi = self.xsi
+ self.do_write_test(self.xsi)
+
+ self.wait((lambda x: self.xsi.is_port_driving(self._notif_port)))
+
+ self._rx.xsi = self.xsi
+ self.do_read_test(self.xsi)
diff --git a/lib_uart/tests/uart_rx_checker.py b/lib_uart/tests/uart_rx_checker.py
new file mode 100644
index 0000000..3f7d78b
--- /dev/null
+++ b/lib_uart/tests/uart_rx_checker.py
@@ -0,0 +1,169 @@
+from random import randint
+
+import xmostest
+
+Parity = dict(
+ UART_PARITY_EVEN=0,
+ UART_PARITY_ODD=1,
+ UART_PARITY_NONE=2,
+ UART_PARITY_BAD=3
+)
+
+
+class DriveHigh(xmostest.SimThread):
+ def __init__(self, p):
+ self._p = p
+
+ def run(self):
+ xsi = self.xsi
+
+ xsi.drive_port_pins(self._p, 1);
+
+
+class UARTRxChecker(xmostest.SimThread):
+ def __init__(self, rx_port, tx_port, parity, baud, stop_bits, bpb, data=[0x7f, 0x00, 0x2f, 0xff],
+ intermittent=False):
+ """
+ Create a UARTRxChecker instance.
+
+ :param rx_port: Receive port of the UART device under test.
+ :param tx_port: Transmit port of the UART device under test.
+ :param parity: Parity of the UART connection.
+ :param baud: BAUD rate of the UART connection.
+ :param stop_bits: Number of stop_bits for each UART byte.
+ :param bpb: Number of data bits per "byte" of UART data.
+ :param data: A list of bytes to send (default: [0x7f, 0x00, 0x2f, 0xff])
+ :param intermittent: Add a random delay between sent bytes.
+ """
+ self._rx_port = rx_port
+ self._tx_port = tx_port
+ self._parity = parity
+ self._baud = baud
+ self._stop_bits = stop_bits
+ self._bits_per_byte = bpb
+ self._data = data
+ self._intermittent = intermittent
+ # Hex value of stop bits, as MSB 1st char, e.g. 0b11 : 0xC0
+
+ def send_byte(self, xsi, byte):
+ """
+ Send a byte to the rx_port
+
+ :param xsi: XMOS Simulator Instance.
+ :param byte: Byte to send
+ """
+ # Send start bit
+ self.send_start(xsi)
+
+ # Send data
+ self.send_data(xsi, byte)
+
+ # Send parity
+ self.send_parity(xsi, byte)
+
+ # Send stop bit(s)
+ self.send_stop(xsi)
+
+ def send_start(self, xsi):
+ """
+ Send a start bit.
+
+ :param xsi: XMOS Simulator Instance.
+ """
+ xsi.drive_port_pins(self._rx_port, 0)
+ self.wait_baud_time(xsi)
+
+ def send_data(self, xsi, byte):
+ """
+ Write the data bits to the rx_port
+
+ :param xsi: XMOS Simulator Instance.
+ :param byte: Data to send.
+ """
+ # print "0x%02x:" % byte
+ for x in range(self._bits_per_byte):
+ # print " Sending bit %d of 0x%02x (%d)" % (x, byte, (byte >> x) & 0x01)
+ xsi.drive_port_pins(self._rx_port, (byte & (0x01 << x)) >= 1)
+ # print " (x): %d" % ((byte & (0x01 << x))>=1)
+ self.wait_baud_time(xsi)
+
+ def send_parity(self, xsi, byte):
+ """
+ Send the parity bit to the rx_port
+
+ :param xsi: XMOS Simulator Instance.
+ :param byte: Data to send parity of.
+ """
+ parity = self._parity
+ if parity < 2:
+ crc_sum = 0
+ for x in range(self._bits_per_byte):
+ crc_sum += ((byte & (0x01 << x)) >= 1)
+ crc_sum += parity
+ # print "Parity for 0x%02x: %d" % (byte, crc_sum%2)
+ xsi.drive_port_pins(self._rx_port, crc_sum % 2)
+ self.wait_baud_time(xsi)
+ elif parity == Parity['UART_PARITY_BAD']:
+ # print "Sending bad parity bit"
+ self.send_bad_parity(xsi)
+
+ def send_stop(self, xsi):
+ """
+ Send the stop bit(s) to the rx_port
+
+ :param xsi: XMOS Simulator Instance.
+ """
+ for x in range(self._stop_bits):
+ xsi.drive_port_pins(self._rx_port, 1)
+ self.wait_baud_time(xsi)
+
+ def send_bad_parity(self, xsi):
+ """
+ Send a parity bit of 1 to simulate an incorrect parity state.
+
+ :param xsi: XMOS Simulator Instance.
+ """
+ # Always send a parity bit of 1
+ xsi.drive_port_pins(self._rx_port, 0)
+ self.wait_baud_time(xsi)
+
+ def get_bit_time(self):
+ """
+ Returns the expected time between bits for the currently set BAUD rate.
+
+ Returns float value in nanoseconds.
+ """
+ # Return float value in ns
+ return (1.0 / self._baud) * 1e9
+
+ def wait_baud_time(self, xsi):
+ """
+ Wait for 1 bit time, as determined by the baud rate.
+ """
+ self.wait_until(xsi.get_time() + self.get_bit_time())
+
+ def wait_half_baud_time(self, xsi):
+ """
+ Wait for half a bit time, as determined by the baud rate.
+ """
+ self.wait_until(xsi.get_time() + (self.get_bit_time() / 2))
+
+ def run(self):
+ xsi = self.xsi
+ # Drive the uart line high.
+ xsi.drive_port_pins(self._rx_port, 1)
+
+ # Wait for the device to bring up it's tx port, indicating it is ready
+ self.wait((lambda _x: self.xsi.is_port_driving(self._tx_port)))
+
+ # If we're doing an intermittent send, add a delay between each byte
+ # sent. Delay is in ns. 20,000ns = 20ms, 100,000ns = 100ms. Delays could
+ # be more variable, but it hurts test time substantially.
+ if self._intermittent:
+ for x in self._data:
+ k = randint(20000, 100000)
+ self.wait_until(xsi.get_time() + k)
+ self.send_byte(xsi, x)
+ else:
+ for x in self._data:
+ self.send_byte(xsi, x)
diff --git a/lib_uart/tests/uart_tx_checker.py b/lib_uart/tests/uart_tx_checker.py
new file mode 100644
index 0000000..fac6875
--- /dev/null
+++ b/lib_uart/tests/uart_tx_checker.py
@@ -0,0 +1,232 @@
+from array import array
+
+import xmostest
+
+Parity = dict(
+ UART_PARITY_EVEN=0,
+ UART_PARITY_ODD=1,
+ UART_PARITY_NONE=2,
+)
+
+
+class UARTTxChecker(xmostest.SimThread):
+ """
+ This simulator thread will act as a UART device, and will check sent and
+ transations caused by the device, by looking at the tx pins.
+ """
+
+ def __init__(self, rx_port, tx_port, parity, baud, length, stop_bits, bpb):
+ """
+ Create a UARTTxChecker instance.
+
+ :param rx_port: Receive port of the UART device under test.
+ :param tx_port: Transmit port of the UART device under test.
+ :param parity: Parity of the UART connection.
+ :param baud: BAUD rate of the UART connection.
+ :param length: Length of transmission to check.
+ :param stop_bits: Number of stop_bits for each UART byte.
+ :param bpb: Number of data bits per "byte" of UART data.
+ """
+ self._rx_port = rx_port
+ self._tx_port = tx_port
+ self._parity = parity
+ self._baud = baud
+ self._length = length
+ self._stop_bits = stop_bits
+ self._bits_per_byte = bpb
+ # Hex value of stop bits, as MSB 1st char, e.g. 0b11 : 0xC0
+
+ def get_port_val(self, xsi, port):
+ """
+ Sample the state of a port
+
+ :rtype: int
+ :param xsi: XMOS Simulator Instance.
+ :param port: Port to sample.
+ """
+ is_driving = xsi.is_port_driving(port)
+ if not is_driving:
+ return 1
+ else:
+ return xsi.sample_port_pins(port)
+
+ def get_bit_time(self):
+ """
+ Returns the expected time between bits for the currently set BAUD rate.
+
+ Returns float value in nanoseconds.
+ :rtype: float
+ """
+ # Return float value in ns
+ return (1.0/self._baud) * 1e9
+
+ def wait_baud_time(self, xsi):
+ """
+ Wait for 1 bit time, as determined by the baud rate.
+ """
+ self.wait_until(xsi.get_time() + self.get_bit_time())
+ return True
+
+ def wait_half_baud_time(self, xsi):
+ """
+ Wait for half a bit time, as determined by the baud rate.
+ """
+ self.wait_until(xsi.get_time() + (self.get_bit_time() / 2))
+
+ def read_packet(self, xsi, parity, length=4):
+ """
+ Read a given number of bytes of UART traffic sent by the device.
+
+ Returns a list of bytes sent by the device.
+
+ :rtype: list
+ :param xsi: XMOS Simulator Instance.
+ :param parity: The UART partiy setting. See Parity.
+ :param length: The number of bytes to read. Defaults to 4.
+ """
+ packet = []
+ start_time = 0
+ got_start_bit = False
+ for x in range(length):
+ packet.append(chr(self.read_byte(xsi, parity)))
+ return packet
+
+ def read_byte(self, xsi, parity):
+ """
+ Read 1 byte of UART traffic sent by the device
+
+ Returns an int, representing a byte read from the uart. Should be in the range 0 <= x < 2^bits_per_byte
+
+ :rtype: int
+ :param xsi: XMOS Simulator Instance.
+ :param parity: The UART partiy setting. See Parity.
+ """
+ byte = 0
+ val = 0
+
+ # Recv start bit
+ print "tx starts high: %s" % ("True" if self.get_port_val(xsi, self._tx_port) else "False")
+ self.wait_for_port_pins_change([self._tx_port])
+
+ # The tx line should go low for 1 bit time
+ if self.get_val_timeout(xsi, self._tx_port) == 0:
+ print "Start bit recv'd"
+ else:
+ return False
+
+ # recv the byte
+ crc_sum = 0
+ for j in range(self._bits_per_byte):
+ val = self.get_val_timeout(xsi, self._tx_port)
+ byte += (val << j)
+ crc_sum += val
+
+ # Check the parity if needs be
+ self.check_parity(xsi, crc_sum, parity)
+
+ # Get the stop bit
+ self.check_stopbit(xsi)
+
+ # Print a new line to split bytes in output
+ print ""
+
+ return byte
+
+ def check_parity(self, xsi, crc_sum, parity):
+ """
+ Read the parity bit and check it against a crc sum. Print correctness.
+
+ :param xsi: XMOS Simulator Instance.
+ :param crc_sum: The checksum to test parity against.
+ :param parity: The UART partiy setting. See Parity.
+ """
+ if parity < 2:
+ read = self.get_val_timeout(xsi, self._tx_port)
+ if read == (crc_sum + parity) % 2:
+ print "Parity bit correct"
+ else:
+ print "Parity bit incorrect. Got %d, expected %d" % (read, (crc_sum + parity) % 2)
+ else:
+ print "Parity bit correct"
+
+ def check_stopbit(self, xsi):
+ """
+ Read the stop bit(s) of a UART transmission and print correctness.
+
+ :param xsi: XMOS Simulator Instance.
+ """
+ stop_bits_correct = True
+ for i in range(self._stop_bits):
+ # The stop bits should stay high for this time
+ if self.get_val_timeout(xsi, self._tx_port) == 0:
+ stop_bits_correct = False
+ print "tx ends high: %s" % ("True" if stop_bits_correct else "False")
+
+ def get_val_timeout(self, xsi, port):
+ """
+ Get a value from a given port of the device, with a timeout determined
+ by the BAUD rate.
+
+ Returns whether the pin is high (True) or low (False)
+
+ :rtype: bool
+ :param xsi: XMOS Simulator Instance.
+ :param port: The port to sample.
+ """
+ # This intentionally has a 0.3% slop. It is per-byte and gives some
+ # wiggle-room if the clock doesn't divide into ns nicely.
+ timeout = self.get_bit_time() * 0.5
+ short_timeout = self.get_bit_time() * 0.2485
+
+ # Allow for "rise" time
+ self.wait_until(xsi.get_time() + short_timeout)
+
+ # Get val
+ K = self.wait_time_or_pin_change(xsi, timeout, port)
+
+ # Allow for "fall" time
+ self.wait_until(xsi.get_time() + short_timeout)
+ return K
+
+ def wait_time_or_pin_change(self, xsi, timeout, port):
+ """
+ Waits for a given timeout, or until a port changes state. Which ever
+ occurs 1st. Prints an error if the former causes the function to break.
+
+ Returns whether the pin is high (True) or low (False)
+
+ :rtype: bool
+ :param xsi: XMOS Simulator Instance.
+ :param timeout: Time to wait.
+ :param port: Port to sample.
+ """
+ start_time = xsi.get_time()
+ start_val = self.get_port_val(xsi, port)
+ transitioned_during_wait = False
+
+ def _continue(_timeout, _start_time, _start_val):
+ if xsi.get_time() >= _start_time + _timeout:
+ return True
+ if self.get_port_val(xsi, port) != _start_val:
+ transitioned_during_wait = True
+ return True
+ return False
+ wait_fun = (lambda x: _continue(timeout, start_time, start_val))
+ self.wait(wait_fun)
+
+ # Start value should *not* have changed during timeout
+ if transitioned_during_wait:
+ print "FAIL :: Unexpected Transition."
+
+ return start_val
+
+ def run(self):
+ # Wait for the xcore to bring the uart tx port up
+ self.wait((lambda x: self.xsi.is_port_driving(self._tx_port)))
+ self.wait((lambda x: self.get_port_val(self.xsi, self._tx_port) == 1))
+
+ K = self.read_packet(self.xsi, self._parity, self._length)
+
+ # Print each member of K as a hex byte
+ # inline lambda function mapped over a list? awh yiss.
+ print ", ".join(map((lambda x: "0x%02x" % ord(x)), K))