├── .clang-format
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_issue.md
│ ├── build_installation_issue.md
│ ├── documentation_issue.md
│ └── feature_request.md
└── workflows
│ ├── apps.yml
│ ├── ci.yml
│ ├── docs.yml
│ └── python.yml
├── .gitignore
├── .gitmodules
├── CHANGELOG.rst
├── CMakeLists.txt
├── CODEOWNERS
├── Jenkinsfile
├── LICENSE.rst
├── README.md
├── doc
├── Doxyfile.inc
├── README.md
├── exclude_patterns.inc
├── programming_guide
│ ├── diagrams
│ │ ├── xcore-iot_component_diagram.drawio.png
│ │ └── xcore_iot_component_diagram.drawio
│ ├── faq.rst
│ ├── index.rst
│ ├── installation.rst
│ └── tutorials
│ │ ├── bare_metal
│ │ ├── bare_metal.rst
│ │ └── examples
│ │ │ ├── examples.rst
│ │ │ ├── explorer_board.rst
│ │ │ └── visual_wake_word.rst
│ │ ├── freertos
│ │ ├── common_issues.rst
│ │ ├── examples
│ │ │ ├── audio_mux.rst
│ │ │ ├── device_control.rst
│ │ │ ├── dfu.rst
│ │ │ ├── examples.rst
│ │ │ ├── explorer_board.rst
│ │ │ ├── getting_started.rst
│ │ │ ├── images
│ │ │ │ └── xscope_fileio_functional_diagram.png
│ │ │ ├── iot.rst
│ │ │ ├── l2_cache.rst
│ │ │ ├── tracealyzer.rst
│ │ │ ├── xlink.rst
│ │ │ └── xscope_fileio.rst
│ │ ├── faq.rst
│ │ └── freertos.rst
│ │ ├── platform.rst
│ │ └── tutorials.rst
├── shared
│ └── legal.rst
├── src_html
│ └── .gitkeep
└── substitutions.rst
├── examples
├── bare-metal
│ ├── explorer_board
│ │ ├── README.md
│ │ ├── XCORE-AI-EXPLORER.xn
│ │ ├── explorer_board.cmake
│ │ └── src
│ │ │ ├── app_conf.h
│ │ │ ├── audio_pipeline
│ │ │ ├── audio_pipeline.c
│ │ │ └── audio_pipeline.h
│ │ │ ├── config.xscope
│ │ │ ├── demos
│ │ │ ├── app_demos.h
│ │ │ ├── flash_demo.c
│ │ │ ├── gpio_server.c
│ │ │ ├── spi_demo.c
│ │ │ └── uart_demo.c
│ │ │ ├── main.c
│ │ │ ├── misc
│ │ │ └── burn.h
│ │ │ └── platform
│ │ │ ├── aic3204.c
│ │ │ ├── aic3204.h
│ │ │ ├── app_pll_ctrl.c
│ │ │ ├── app_pll_ctrl.h
│ │ │ ├── mic_support.h
│ │ │ ├── platform_init.h
│ │ │ ├── platform_init_tile0.c
│ │ │ ├── platform_init_tile1.c
│ │ │ ├── tile_support.c
│ │ │ └── tile_support.h
│ └── visual_wake_words
│ │ ├── README.md
│ │ ├── XCORE-AI-EXPLORER.xn
│ │ ├── model
│ │ ├── vww_model_nibble_swapped.bin
│ │ └── vww_quant.tflite
│ │ ├── src
│ │ ├── config.xscope
│ │ ├── flash_server.c
│ │ ├── main.cpp
│ │ ├── main.xc
│ │ ├── vww_model
│ │ ├── vww_model.cpp
│ │ └── vww_model.h
│ │ ├── test_image.py
│ │ └── visual_wake_words.cmake
├── examples.cmake
└── freertos
│ ├── audio_mux
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── audio_mux.cmake
│ ├── bsp_config
│ │ ├── XCORE-AI-EXPLORER
│ │ │ ├── XCORE-AI-EXPLORER.cmake
│ │ │ ├── XCORE-AI-EXPLORER.xn
│ │ │ └── platform
│ │ │ │ ├── app_pll_ctrl.c
│ │ │ │ ├── app_pll_ctrl.h
│ │ │ │ ├── dac_port.c
│ │ │ │ ├── driver_instances.c
│ │ │ │ ├── driver_instances.h
│ │ │ │ ├── platform_conf.h
│ │ │ │ ├── platform_init.c
│ │ │ │ ├── platform_init.h
│ │ │ │ └── platform_start.c
│ │ ├── bsp_config.cmake
│ │ └── dac
│ │ │ ├── aic3204
│ │ │ ├── aic3204.c
│ │ │ └── aic3204.h
│ │ │ └── dac.cmake
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── app_conf_check.h
│ │ ├── audio_pipeline
│ │ ├── audio_pipeline.c
│ │ └── audio_pipeline.h
│ │ ├── config.xscope
│ │ ├── main.c
│ │ └── usb
│ │ ├── adaptive_rate_adjust.c
│ │ ├── adaptive_rate_adjust.h
│ │ ├── tusb_config.h
│ │ ├── usb_audio.c
│ │ ├── usb_audio.h
│ │ ├── usb_descriptors.c
│ │ └── usb_descriptors.h
│ ├── device_control
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── device_control.cmake
│ ├── host
│ │ ├── CMakeLists.txt
│ │ ├── argtable
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── argtable-v3.2.1.52f24e5-amalgamation.tar.gz
│ │ │ ├── argtable3.c
│ │ │ └── argtable3.h
│ │ ├── commands.c
│ │ ├── commands.h
│ │ └── device_control_host.c
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── app_control
│ │ ├── app_control.c
│ │ └── app_control.h
│ │ ├── config.xscope
│ │ ├── main.c
│ │ ├── tusb_config.h
│ │ └── usb_descriptors.c
│ ├── dfu
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── bsp_config
│ │ ├── CMakeLists.txt
│ │ └── XCORE-AI-EXPLORER_2V0
│ │ │ └── platform
│ │ │ ├── driver_instances.c
│ │ │ ├── driver_instances.h
│ │ │ ├── platform_conf.h
│ │ │ ├── platform_init.c
│ │ │ ├── platform_init.h
│ │ │ └── platform_start.c
│ ├── dfu.cmake
│ ├── loader
│ │ └── loader.c
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── config.xscope
│ │ ├── main.c
│ │ ├── tusb_config.h
│ │ └── usb
│ │ ├── app_dfu.c
│ │ └── usb_descriptors.c
│ ├── explorer_board
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── explorer_board.cmake
│ ├── filesystem_support
│ │ └── demo.txt
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── config.xscope
│ │ ├── example_pipeline
│ │ ├── example_pipeline.c
│ │ └── example_pipeline.h
│ │ ├── ff_appconf.h
│ │ ├── filesystem
│ │ ├── filesystem_demo.c
│ │ └── filesystem_demo.h
│ │ ├── gpio_ctrl
│ │ ├── gpio_ctrl.c
│ │ └── gpio_ctrl.h
│ │ ├── main.c
│ │ ├── mem_analysis
│ │ ├── mem_analysis.c
│ │ └── mem_analysis.h
│ │ └── uart
│ │ ├── uart_demo.c
│ │ └── uart_demo.h
│ ├── getting_started
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── getting_started.cmake
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── config.xscope
│ │ └── main.c
│ ├── iot
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── filesystem_support
│ │ ├── .gitignore
│ │ ├── make_certs.ps1
│ │ ├── make_certs.sh
│ │ ├── wifi_profile.ps1
│ │ └── wifi_profile.py
│ ├── iot.cmake
│ ├── mosquitto
│ │ └── mosquitto.conf
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── FreeRTOSIPConfig.h
│ │ ├── app_conf.h
│ │ ├── config.xscope
│ │ ├── ff_appconf.h
│ │ ├── main.c
│ │ ├── mbedtls_sample_config.h
│ │ ├── mem_analysis
│ │ ├── mem_analysis.c
│ │ └── mem_analysis.h
│ │ ├── mqtt_demo
│ │ ├── mqtt_demo_client.c
│ │ └── mqtt_demo_client.h
│ │ ├── network_demos
│ │ ├── network_setup.c
│ │ └── network_setup.h
│ │ └── xcore_trace_config.h
│ ├── l2_cache
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── l2_cache.cmake
│ └── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_common.h
│ │ ├── config.xscope
│ │ ├── example_code.c
│ │ ├── example_code.h
│ │ ├── main.c
│ │ ├── print_info.c
│ │ └── print_info.h
│ ├── tracealyzer
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── host
│ │ ├── CMakeLists.txt
│ │ └── xscope2psf.c
│ ├── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── config.xscope
│ │ ├── main.c
│ │ ├── trcConfig.h
│ │ ├── trcKernelPortConfig.h
│ │ ├── trcKernelPortStreamingConfig.h
│ │ ├── trcStreamPortConfig.h
│ │ └── trcStreamingConfig.h
│ └── tracealyzer.cmake
│ ├── xlink
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── XCORE-AI-EXPLORER_tx.xn
│ ├── bsp_config
│ │ ├── CMakeLists.txt
│ │ └── XCORE-AI-EXPLORER_2V0
│ │ │ └── platform
│ │ │ ├── driver_instances.c
│ │ │ ├── driver_instances.h
│ │ │ ├── platform_conf.h
│ │ │ ├── platform_init.c
│ │ │ ├── platform_init.h
│ │ │ └── platform_start.c
│ ├── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── link
│ │ │ ├── link_helpers.c
│ │ │ └── link_helpers.h
│ │ ├── main.c
│ │ ├── xlink_rx
│ │ │ ├── xlink_rx.c
│ │ │ └── xlink_rx.h
│ │ └── xlink_tx
│ │ │ ├── xlink_tx.c
│ │ │ └── xlink_tx.h
│ └── xlink.cmake
│ └── xscope_fileio
│ ├── README.md
│ ├── XCORE-AI-EXPLORER.xn
│ ├── diagrams
│ └── functional_diagram.drawio
│ ├── in.wav
│ ├── src
│ ├── FreeRTOSConfig.h
│ ├── app_conf.h
│ ├── config.xscope
│ ├── data_pipeline
│ │ ├── api
│ │ │ └── data_pipeline.h
│ │ └── src
│ │ │ ├── data_pipeline_tile0.c
│ │ │ └── data_pipeline_tile1.c
│ ├── fileio
│ │ ├── xscope_fileio_task.c
│ │ └── xscope_fileio_task.h
│ ├── main.c
│ └── wav
│ │ ├── wav_utils.c
│ │ └── wav_utils.h
│ └── xscope_fileio.cmake
├── index.rst
├── modules
├── CMakeLists.txt
├── inferencing
│ └── CMakeLists.txt
├── sample_rate_conversion
│ └── CMakeLists.txt
└── xscope_fileio
│ └── CMakeLists.txt
├── projects
└── eclipse
│ ├── .cproject
│ ├── .project
│ └── .settings
│ └── language.settings.xml
├── settings.json
├── test
├── examples
│ ├── README.rst
│ ├── run_freertos_explorer_board_tests.sh
│ ├── run_freertos_getting_started_tests.sh
│ ├── run_freertos_l2_cache_tests.sh
│ └── run_freertos_tracealyzer_tests.sh
├── requirements.txt
├── tests.cmake
├── usb
│ ├── README.rst
│ ├── XCORE-AI-EXPLORER.xn
│ ├── dfu.sh
│ ├── src
│ │ ├── FreeRTOSConfig.h
│ │ ├── app_conf.h
│ │ ├── config.xscope
│ │ ├── dfu_demo_support.c
│ │ └── main.c
│ ├── tinyusb_demos
│ │ ├── audio_test
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── cdc_dual_ports
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── cdc_msc
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── msc_disk.c
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── dfu
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── dfu_runtime
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── flash_boot_image.c
│ │ │ │ ├── flash_boot_image.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── hid_boot_interface
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ ├── usb_descriptors.c
│ │ │ │ └── usb_descriptors.h
│ │ ├── hid_composite
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ ├── usb_descriptors.c
│ │ │ │ └── usb_descriptors.h
│ │ ├── hid_generic_inout
│ │ │ ├── hid_test.py
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── hid_multiple_interface
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── midi_test
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── msc_dual_lun
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── msc_disk_dual.c
│ │ │ │ ├── tusb_config.h
│ │ │ │ └── usb_descriptors.c
│ │ ├── uac2_headset
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ ├── usb_descriptors.c
│ │ │ │ └── usb_descriptors.h
│ │ ├── usbtmc
│ │ │ ├── demo.py
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ ├── usb_descriptors.c
│ │ │ │ ├── usbtmc_app.c
│ │ │ │ └── usbtmc_app.h
│ │ ├── video_capture
│ │ │ └── src
│ │ │ │ ├── demo_main.c
│ │ │ │ ├── demo_main.h
│ │ │ │ ├── images.h
│ │ │ │ ├── tusb_config.h
│ │ │ │ ├── usb_descriptors.c
│ │ │ │ └── usb_descriptors.h
│ │ └── webusb_serial
│ │ │ └── src
│ │ │ ├── demo_main.c
│ │ │ ├── demo_main.h
│ │ │ ├── tusb_config.h
│ │ │ ├── usb_descriptors.c
│ │ │ └── usb_descriptors.h
│ └── usb.cmake
└── verify_python_install.py
└── tools
├── ci
├── .xmos_ignore_source_check
├── build_host_apps.sh
├── build_metal_examples.sh
├── build_pdfs.sh
├── build_rtos_aiot_examples.sh
├── build_rtos_core_examples.sh
├── build_rtos_usb_tests.sh
├── build_xmath_walkthrough_pdf.sh
├── build_xmath_walkthrough_zip.sh
├── clean_xmath_walkthrough.sh
├── fetch_xmath_walkthrough.sh
├── helper_functions.sh
└── run_submodule_report.sh
└── install
└── requirements.txt
/.github/ISSUE_TEMPLATE/bug_issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a bug report to help us improve XCORE-IOT
4 | title: ''
5 | labels: type:bug
6 | assignees: keithm-xmos
7 |
8 | ---
9 |
10 | **System information**
11 | - OS: [e.g. Mac, Linux, Windows]
12 | - xcore board [e.g. Explorer, Osprey]
13 | - Version tag or commit SHA
14 |
15 | **Describe the current behavior**
16 |
17 | **Describe the expected behavior**
18 |
19 | **Standalone code to reproduce the issue**
20 | If possible, provide a reproducible test case that is the bare minimum necessary to generate
21 | the problem.
22 |
23 | **Other info or logs**
24 | Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/build_installation_issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Build or install issue
3 | about: Create a report to help us improve XCORE-IOT
4 | title: ''
5 | labels: type:build/install
6 | assignees: keithm-xmos
7 |
8 | ---
9 |
10 | **System information**
11 | - OS: [e.g. Mac, Linux, Windows]
12 | - Version tag or commit SHA
13 |
14 | **Describe the problem**
15 |
16 | **Provide the exact sequence of commands / steps that you executed before running into the problem**
17 |
18 | **Other info or logs**
19 | Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation_issue.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Documentation issue
3 | about: Create a report to help us improve the documentation
4 | title: ''
5 | labels: type:documentation
6 | assignees: keithm-xmos
7 |
8 | ---
9 |
10 | Thank you for submitting an XCORE-IOT documentation issue. Please provide as much information you can.
11 |
12 | **System information**
13 | - OS: [e.g. Mac, Linux, Windows]
14 | - xcore board [e.g. Explorer, Osprey]
15 | - Version tag or commit SHA
16 |
17 | **Describe the documentation issue**
18 |
19 | **Other information**
20 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest a new feature for XCORE-VOICE
4 | title: ''
5 | labels: type:enhancement
6 | assignees: keithm-xmos
7 |
8 | ---
9 |
10 | Thank you for submitting a feature request. Please provide as much information you can.
11 |
12 | **Describe the feature**
13 |
14 | **Will this change any current APIs? How?**
15 |
16 | **Who will benefit with this feature?**
17 |
18 | **Any Other info**
19 |
--------------------------------------------------------------------------------
/.github/workflows/docs.yml:
--------------------------------------------------------------------------------
1 | # YAML schema for GitHub Actions:
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
3 | #
4 | # Helpful YAML parser to clarify YAML syntax:
5 | # https://yaml-online-parser.appspot.com/
6 | #
7 | # This workflow uses actions that are not certified by GitHub. They are provided by a third-party and are governed by
8 | # separate terms of service, privacy policy, and support documentation.
9 | #
10 | # This file contains the workflows that are run prior to merging a pull request.
11 |
12 | name: Build Documentation
13 |
14 | on:
15 | # Allow manually triggering of the workflow.
16 | workflow_dispatch: {}
17 |
18 | # Allow workflow to be called from another.
19 | workflow_call:
20 | inputs:
21 | docs_artifact_name:
22 | description: 'The name to be given to the uploaded docs artifact.'
23 | default: ""
24 | required: true
25 | type: string
26 |
27 | env:
28 | DOC_BUILDER_IMAGE: 'ghcr.io/xmos/doc_builder:v3.0.0'
29 | DOCS_ARTIFACT_NAME: "xcore_iot_docs"
30 |
31 | jobs:
32 | build_documentation:
33 | name: Build documentation
34 | runs-on: ubuntu-latest
35 | steps:
36 | - name: Checkout
37 | uses: actions/checkout@v3
38 | with:
39 | submodules: recursive
40 |
41 | - name: Pull doc_builder docker image
42 | run: |
43 | docker pull ${DOC_BUILDER_IMAGE}
44 |
45 | - name: Build
46 | run: |
47 | docker run --rm -t -u $(id -u):$(id -g) -v ${{ github.workspace }}:/build -e PDF=1 -e REPO:/build -e EXCLUDE_PATTERNS=/build/doc/exclude_patterns.inc -e DOXYGEN_INCLUDE=/build/doc/Doxyfile.inc -e DOXYGEN_INPUT=ignore ${DOC_BUILDER_IMAGE}
48 | rm -rf doc/_build/_doxygen
49 |
50 | - name: Determine artifact names
51 | run: |
52 | if [ ! -z "${{ inputs.docs_artifact_name }}" ]; then
53 | echo "DOCS_ARTIFACT_NAME=${{ inputs.docs_artifact_name }}" >> $GITHUB_ENV
54 | fi
55 |
56 | - name: Save doc artifacts
57 | uses: actions/upload-artifact@v3
58 | with:
59 | name: ${{ env.DOCS_ARTIFACT_NAME }}
60 | path: doc/_build
61 | if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
62 |
--------------------------------------------------------------------------------
/.github/workflows/python.yml:
--------------------------------------------------------------------------------
1 | # YAML schema for GitHub Actions:
2 | # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
3 | #
4 | # Helpful YAML parser to clarify YAML syntax:
5 | # https://yaml-online-parser.appspot.com/
6 | #
7 | # This workflow uses actions that are not certified by GitHub. They are provided by a third-party and are governed by
8 | # separate terms of service, privacy policy, and support documentation.
9 | #
10 | # This file contains the workflows that are run prior to merging a pull request.
11 | # This workflow will be triggered when a PR modifies some python relevant files
12 |
13 | name: Python
14 |
15 | on:
16 | push:
17 | branches:
18 | - 'main'
19 | - 'develop'
20 |
21 | pull_request:
22 | branches:
23 | - 'main'
24 | - 'develop'
25 |
26 | # Allow manually triggering of the workflow.
27 | workflow_dispatch: {}
28 |
29 | jobs:
30 | changes:
31 | runs-on: ubuntu-latest
32 | name: Change detection
33 | # Set job outputs to values from filter step
34 | outputs:
35 | python_install: ${{ steps.filter.outputs.python_install }}
36 | steps:
37 | - name: Checkout
38 | uses: actions/checkout@v2
39 | with:
40 | submodules: recursive
41 | - name: Paths filter
42 | uses: dorny/paths-filter@v2
43 | id: filter
44 | with:
45 | filters: |
46 | python_install:
47 | - 'tools/install/requirements.txt'
48 | - '**.py'
49 |
50 | python_install:
51 | runs-on: ubuntu-latest
52 | needs: changes
53 | name: Install & verify Python packages
54 | if: ${{ needs.changes.outputs.python_install == 'true' }}
55 | steps:
56 | - name: Checkout
57 | uses: actions/checkout@v2
58 | with:
59 | submodules: recursive
60 |
61 | - name: Install Python
62 | uses: actions/setup-python@v2
63 | with:
64 | python-version: '3.8'
65 |
66 | - name: Install packages
67 | run: |
68 | python -m pip install --upgrade pip
69 | pip install -r tools/install/requirements.txt
70 |
71 | - name: Verify install
72 | run: |
73 | python test/verify_python_install.py
74 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Editor cruft
2 | **/.vscode/
3 |
4 | # Python cruft
5 | **/*.pyc
6 | **/__pycache__/*
7 | **/*.egg-info/*
8 | **/*.eggs/*
9 | **/.ipynb_checkpoints/*
10 |
11 | # Build & debug cruft
12 | **/.build*/*
13 | **/bin/*
14 | *.o
15 | *.so*
16 | *.dylib
17 | *.xe
18 | *.vcd
19 | *.s
20 | *.xi
21 | *.i
22 | *.a
23 | *.xmt
24 | **/_build/
25 | **/build_*/
26 | !doc/tutorials/build_system/
27 | **/dist*/
28 | **/run_*.log
29 | **/_doxygen/*
30 | **/_templates/*
31 | **/pdf/*
32 | **/html/*
33 | **/.settings/*
34 | .metadata
35 | **/test_results.csv
36 | **/test_results.xml
37 | **/.venv/**
38 | .metadata
39 | *.gtkw
40 | *.swmem
41 | *.bin
42 | *.fs
43 |
44 | # Test cruft
45 | **/.pytest_cache/*
46 | **/*_junit.xml
47 | **/testing/*
48 |
49 | # waf build cruft
50 | .lock-waf_*
51 | .waf-*/
52 | build/
53 |
54 | # filesystem cruft
55 | **/fatmktmp
56 | **/fat.fs
57 | **/flash_bin_node0
58 | **/fw-*
59 | **/spanning-xn-*
60 | **/target-xn-*
61 |
62 | # wifi cruft
63 | **/networks.dat
64 |
65 | # systemview debug cruft
66 | *.SVDAT
67 |
68 | # macOS cruft
69 | .DS_Store
70 |
71 | # ai_tools
72 | tools/ai/ai_tools
73 | *xcore_iot_venv/*
74 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lib_src"]
2 | path = modules/sample_rate_conversion/lib_src
3 | url = git@github.com:xmos/lib_src.git
4 | [submodule "xmos_cmake_toolchain"]
5 | path = xmos_cmake_toolchain
6 | url = git@github.com:xmos/xmos_cmake_toolchain.git
7 | [submodule "frameworks/core"]
8 | path = modules/core
9 | url = git@github.com:xmos/fwk_core.git
10 | [submodule "frameworks/io"]
11 | path = modules/io
12 | url = git@github.com:xmos/fwk_io.git
13 | [submodule "frameworks/rtos"]
14 | path = modules/rtos
15 | url = git@github.com:xmos/fwk_rtos.git
16 | [submodule "modules/xscope_fileio/xscope_fileio"]
17 | path = modules/xscope_fileio/xscope_fileio
18 | url = git@github.com:xmos/xscope_fileio.git
19 | [submodule "lib_qspi_fast_read"]
20 | path = modules/qspi_fast_read
21 | url = git@github.com:xmos/lib_qspi_fast_read.git
22 | [submodule "modules/inferencing/lib_nn"]
23 | path = modules/inferencing/lib_nn
24 | url = git@github.com:xmos/lib_nn.git
25 | [submodule "modules/inferencing/lib_tflite_micro"]
26 | path = modules/inferencing/lib_tflite_micro
27 | url = git@github.com:xmos/lib_tflite_micro.git
28 | ignore = dirty
29 |
--------------------------------------------------------------------------------
/CHANGELOG.rst:
--------------------------------------------------------------------------------
1 | XCORE-IOT change log
2 | ====================
3 |
4 | 1.0.0
5 | ------
6 |
7 | * CHANGE: Renamed to XCORE-IOT
8 | * ADDED: FreeRTOS audiomux example application
9 | * ADDED: Bare-metal Visual Wake Word example application
10 | * UPDATED: FreeRTOS iot example now supported on Windows
11 | * UPDATED: Documentation updates
12 |
13 | 0.12.0
14 | ------
15 |
16 | * ADDED: FreeRTOS Tracealyzer example application
17 | * ADDED: FreeRTOS DFU example application
18 | * ADDED: FreeRTOS xscope_fileio example application
19 | * ADDED: FreeRTOS xlink example application
20 | * ADDED: Voice framework module
21 | * REMOVED: FreeRTOS Dispatcher example application
22 | * UPDATED: Minor documentation updates
23 |
24 | 0.11.0
25 | ------
26 |
27 | * REMOVED: FreeRTOS cifar10 example application
28 | * REMOVED: Bare-metal visual_wake_word example application
29 | * REMOVED: inferencing modules
30 |
31 | 0.10.0
32 | ------
33 |
34 | Many enhancements and changes from the prior release. The list below summarizes many of the changes:
35 |
36 | * ADDED: UART library and RTOS driver
37 | * ADDED: clock control library and RTOS driver
38 | * ADDED: L2 cache library and RTOS driver
39 | * UPDATED: Redesign of mic array library to leverage VPU
40 | * REMOVED: Bare-metal cifar10, hello_world, hotdog_not_hotdog and microspeech example applications
41 | * ADDED: explorer_board bare-metal example application
42 | * REMOVED: FreeRTOS person_detection example application
43 | * UPDATED: FreeRTOS iot_aws example application redesigned and renamed
44 | * ADDED: device_control, getting_started, ls_cache and dispatcher FreeRTOS example applicatiosn
45 | * ADDED: USB support for FreeRTOS applications
46 | * UPDATED: Simplified installation steps
47 | * UPDATED: Redesign of CMake build system
48 | * UPDATED: Documentation updates
49 |
50 | 0.9.4
51 | -----
52 |
53 | * UPDATED: Reduced RAM used for models using multiple cores
54 | * UPDATED: Reduced RAM used for models containing Conv2D Depthwise operator
55 |
56 | 0.9.3
57 | -----
58 |
59 | * Initial pre-Alpha release
60 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.21)
2 |
3 | ## Disable in-source build.
4 | if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
5 | message(FATAL_ERROR "In-source build is not allowed! Please specify a build folder.\n\tex:cmake -B build")
6 | endif()
7 |
8 | ## Project declaration
9 | project(xcore_iot)
10 |
11 | ## Enable languages for project
12 | enable_language(CXX C ASM)
13 |
14 | ## Project options
15 | option(XCORE_IOT_TESTS "Enable xcore_iot tests" OFF)
16 |
17 | ## Import some helpful macros
18 | include(modules/rtos/tools/cmake_utils/xmos_macros.cmake)
19 |
20 | ## Setup a framework root path
21 | set(XCORE_IOT_ROOT ${PROJECT_SOURCE_DIR} CACHE STRING "Root folder of xcore_iot in this cmake project tree")
22 |
23 | ## Add library subdirectories
24 | add_subdirectory(modules)
25 |
26 | ## Add top level project targets
27 | if(PROJECT_IS_TOP_LEVEL)
28 | include(examples/examples.cmake)
29 | endif()
30 |
31 | if(XCORE_IOT_TESTS)
32 | include(test/tests.cmake)
33 | endif()
34 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | #* @@keithm-xmos @mbruno-xmos @xmos-jmccarthy
2 |
3 | /.github/ @keithm-xmos
--------------------------------------------------------------------------------
/doc/Doxyfile.inc:
--------------------------------------------------------------------------------
1 | # This file provides overrides to the Doxyfile configuration
2 |
3 | PROJECT_NAME = XCORE-IOT
4 | PROJECT_BRIEF = "XCORE-IOT"
5 |
6 | EXTRACT_STATIC = YES
7 |
8 | PREDEFINED = __DOXYGEN__=1
9 | PREDEFINED += DWORD_ALIGNED=
10 | PREDEFINED += __attribute__((weak))=
11 | PREDEFINED += C_API= MA_C_API= C_API_START= C_API_END= EXTERN_C=
12 |
13 | # Core library APIs
14 | INPUT += ../modules/core/modules/xcore_math/lib_xcore_math/lib_xcore_math/api ../modules/core/modules/xcore_math/lib_xcore_math/doc/programming_guide
15 |
16 | # IO library APIs
17 | INPUT += ../modules/io/modules/i2c/api
18 | INPUT += ../modules/io/modules/i2s/api
19 | INPUT += ../modules/io/modules/qspi_io/api
20 | INPUT += ../modules/io/modules/spi/api
21 | INPUT += ../modules/io/modules/uart/api
22 | INPUT += ../modules/io/modules/mic_array/lib_mic_array/api ../modules/io/modules/mic_array/etc/vanilla ../modules/io/modules/mic_array/doc/programming_guide/src
23 |
24 | # RTOS driver APIs
25 | INPUT += ../modules/rtos/modules/drivers
26 |
27 | # RTOS SW Services
28 | INPUT += ../modules/rtos/modules/sw_services/device_control/host ../modules/rtos/modules/sw_services/device_control/api
29 |
30 | USE_MATHJAX = YES
31 | MATHJAX_FORMAT = HTML-CSS
32 | MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/
33 |
34 | # Make short MATHJAX sequences prettier
35 | ALIASES += math{1}="@f$\1@f$"
36 | ALIASES += vector{1}="@f$\bar \1@f$"
37 | ALIASES += operation{1}="@par Operation Performed:^^@parblock^^@f{flalign*}{ \1 && @f}^^@endparblock"
38 |
39 | ALIASES += "beginrst=^^\verbatim embed:rst^^"
40 | ALIASES += "endrst=\endverbatim"
41 |
--------------------------------------------------------------------------------
/doc/README.md:
--------------------------------------------------------------------------------
1 | # Documentation Source
2 |
3 | This folder contains source files for the **XCORE-IOT documentation**. The sources do not render well in GitHub or an RST viewer.
4 | In addition, some information is not visible at all and some links will not be functional.
5 |
6 | ## Building Documentation
7 |
8 | ### Prerequisites
9 |
10 | Install `Docker `_.
11 |
12 | Pull the docker container:
13 |
14 | docker pull ghcr.io/xmos/doc_builder:v3.0.0
15 |
16 | ### Building
17 |
18 | To build the documentation, run the following command in the root of the repository:
19 |
20 | docker run --rm -t -u "$(id -u):$(id -g)" -v $(pwd):/build -e PDF=1 -e REPO:/build -e DOXYGEN_INCLUDE=/build/doc/Doxyfile.inc -e EXCLUDE_PATTERNS=/build/doc/exclude_patterns.inc -e DOXYGEN_INPUT=ignore ghcr.io/xmos/doc_builder:v3.0.0
21 |
22 | ## Adding a New Component
23 |
24 | Follow the following steps to add a new component.
25 |
26 | - Add an entry for the new component's top-level document to the appropriate TOC in the documents tree.
27 | - If the new component uses `Doxygen`, append the appropriate path(s) to the INPUT variable in `Doxyfile.inc`.
28 | - If the new component includes `.rst` files that should **not** be part of the documentation build, append the appropriate pattern(s) to `exclude_patterns.inc`.
29 |
--------------------------------------------------------------------------------
/doc/exclude_patterns.inc:
--------------------------------------------------------------------------------
1 | # The following patterns are to be excluded from the documentation build
2 | *_venv
3 | build_*
4 | documents/README.md
5 | modules/*/build
6 | modules/*/build_*
7 | modules/*/test
8 | modules/*/doc/shared/legal.rst
9 | modules/core/modules/legacy_compat
10 | modules/core/modules/otpinfo
11 | modules/core/modules/random
12 | modules/core/modules/trycatch
13 | modules/rtos/modules/FreeRTOS
14 | modules/io/modules/xud
15 | modules/io/doc/substitutions.rst
16 | modules/sample_rate_conversion
17 | modules/xscope_fileio
18 | projects
19 | test
20 | tools
21 | xmos_cmake_toolchain
22 | **/*.md
--------------------------------------------------------------------------------
/doc/programming_guide/diagrams/xcore-iot_component_diagram.drawio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/doc/programming_guide/diagrams/xcore-iot_component_diagram.drawio.png
--------------------------------------------------------------------------------
/doc/programming_guide/faq.rst:
--------------------------------------------------------------------------------
1 | .. _sdk-faq:
2 |
3 | #############################
4 | Frequently Asked Questions
5 | #############################
6 |
7 | *******
8 | General
9 | *******
10 |
11 | =================
12 | Submodule updates
13 | =================
14 |
15 | XCORE-IOT uses submodules. If you have cloned the repository and later perform an update, it will sometimes also be necessary to update the submodules. To update all submodules, run the following command
16 |
17 | .. code-block:: console
18 |
19 | git submodule update --init --recursive
20 |
21 | ==================
22 | Explorer Board 1v1
23 | ==================
24 |
25 | The Explorer Board 2v0 is supported by default in all example applications. However, it is possible to target the Explorer Board 1v1.
26 | In the example application CMakeLists file, change this line:
27 |
28 | .. code-block:: cmake
29 |
30 | set(APP_LINK_LIBRARIES
31 | rtos::bsp_config::xcore_ai_explorer
32 | )
33 |
34 | to this:
35 |
36 | .. code-block:: cmake
37 |
38 | set(APP_LINK_LIBRARIES
39 | rtos::bsp_config::xcore_ai_explorer_1V1
40 | )
41 |
42 | ************
43 | Build Issues
44 | ************
45 |
46 | ========================
47 | fatfs_mkimage: not found
48 | ========================
49 |
50 | This issue occurs when the ``fatfs_mkimage`` utility cannot be found. The most common cause for these issues are an incomplete installation of the XCORE-IOT.
51 |
52 | Ensure that the host applications setup has been completed. Verify that the ``fatfs_mkimage`` binary is installed to a location on PATH, or that the default application installation folder is added to PATH. See the :ref:`sdk-installation` guide for more information on installing the host applications.
53 |
54 | ===============================================
55 | xcc2clang.exe: error: no such file or directory
56 | ===============================================
57 |
58 | Those strange characters at the beginning of the path are known as a byte-order mark (BOM). CMake adds them to the beginning of the response files it generates during the configure step. Why does it add them? Because the MSVC compiler toolchain requires them. However, some compiler toolchains, like ``gcc`` and ``xcc``, do not ignore the BOM. Why did CMake think the compiler toolchain was MSVC and not the XTC toolchain? Because of a bug in which certain versions of CMake and certain versions of Visual Studio do not play nice together. The good news is that this appears to have been addressed in CMake version 3.22.3.
59 |
60 | Update to CMake version 3.22.2 or newer.
61 |
62 | ********
63 | FreeRTOS
64 | ********
65 |
66 | See the :ref:`freertos-faq` or :ref:`freertos-common_issues`
67 |
--------------------------------------------------------------------------------
/doc/programming_guide/index.rst:
--------------------------------------------------------------------------------
1 | ###########################
2 | XCORE-IOT Programming Guide
3 | ###########################
4 |
5 | ************
6 | Introduction
7 | ************
8 |
9 | XCORE-IOT is a collection of C/C++ software libraries designed to simplify and accelerate application development on xcore processors. It is composed of the following components:
10 |
11 | - Peripheral IO libraries including; UART, I2C, I2S, SPI, QSPI, PDM microphones, and USB. These libraries support bare-metal and RTOS application development.
12 | - Libraries core to DSP applications, including vectorized math. These libraries support bare-metal and RTOS application development.
13 | - Libraries that enable multi-core FreeRTOS development on xcore including a wide array of RTOS drivers and middleware.
14 | - Code Examples - Examples showing a variety of xcore features based on bare-metal and FreeRTOS programming.
15 | - Documentation - Tutorials, references and API guides.
16 |
17 | .. figure:: diagrams/xcore-iot_component_diagram.drawio.png
18 | :align: center
19 | :scale: 80 %
20 | :alt: component diagram
21 |
22 | XCORE-IOT is designed to be used in conjunction with the xcore.ai Evaluation Kit (XK-EVK-XU316). Further information about the xcore.ai Evaluation Kit and xcore.ai devices is available to on `www.xmos.ai `__.
23 |
24 | .. toctree::
25 | :maxdepth: 2
26 |
27 | installation
28 | tutorials/tutorials
29 | faq
30 | ../shared/legal
31 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/bare_metal/bare_metal.rst:
--------------------------------------------------------------------------------
1 | ##########
2 | Bare-Metal
3 | ##########
4 |
5 | .. note::
6 |
7 | Stay tuned for a bare-metal application development Getting Started Guide.
8 |
9 | .. toctree::
10 | :maxdepth: 2
11 |
12 | examples/examples
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/bare_metal/examples/examples.rst:
--------------------------------------------------------------------------------
1 | .. _sdk-baremetal-code-examples:
2 |
3 | ########################
4 | Bare-metal Code Examples
5 | ########################
6 |
7 | Several example bare-metal applications are included to illustrate the fundamental tool flow and provide a starting point for basic evaluation. The examples do not seek to exhibit the full potential of the platform, and are purposely basic to provide instruction. Select an example below for more information on what the example demonstrates, how to build the example, and how to run it.
8 |
9 | .. toctree::
10 | :maxdepth: 1
11 | :includehidden:
12 |
13 | explorer_board.rst
14 | visual_wake_words.rst
15 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/common_issues.rst:
--------------------------------------------------------------------------------
1 | .. include:: ../../../substitutions.rst
2 |
3 | .. _freertos-common_issues:
4 |
5 | ######################
6 | FreeRTOS Common Issues
7 | ######################
8 |
9 | ****************
10 | Task Stack Space
11 | ****************
12 |
13 | One easy to make mistake in FreeRTOS, is not providing enough stack space for a created task. A vast amount of questions exist online around how to select the FreeRTOS stack size, which the most common answer being to create the task with more than enough stack, force the worst case stack condition (not always trivial), and then use the FreeRTOS debug function `uxTaskGetStackHighWaterMark()` to determine how much you can decrease the stack. This method leaves plenty of room for error and must be done during runtime, and therefore on a build by build basis. The static analysis tools provided by The XTC Tools greatly simplify this process since they calculate the exact stack required for a given function call. The macro `RTOS_THREAD_STACK_SIZE` will return the `nstackwords` symbol for a given thread plus the additional space required for the kernel ISRs. Using this macro for every task create will ensure that there is appropriate stack space for each thread, and thus no stack overflow.
14 |
15 | .. code-block:: C
16 |
17 | xTaskCreate((TaskFunction_t) task_foo,
18 | "foo",
19 | RTOS_THREAD_STACK_SIZE(task_foo),
20 | NULL,
21 | configMAX_PRIORITIES-1,
22 | NULL);
23 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/examples/audio_mux.rst:
--------------------------------------------------------------------------------
1 | #########
2 | Audio Mux
3 | #########
4 |
5 | This example application can be configured for onboard mic, USB audio, or i2s input. Outputs are USB audio and I2S. No DSP is performed on the audio, but the example contains an empty 2 tile pipeline skeleton for a user to populate. In this example all USB audio endpoints are sychronous.
6 |
7 | ******************
8 | Preparing the host
9 | ******************
10 |
11 | On Linux and macOS the user may need to update their ``udev`` rules for USB configurations. Add a custom ``udev`` rule for USB device with VID ``0x20B1`` and PID ``0x0021``.
12 |
13 | ******************************************
14 | Deploying the firmware with Linux or macOS
15 | ******************************************
16 |
17 | =====================
18 | Building the firmware
19 | =====================
20 |
21 | Run the following commands in the repository root folder.
22 |
23 | .. code-block:: console
24 |
25 | cmake -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
26 | cd build
27 | make example_audio_mux
28 |
29 | ====================
30 | Running the firmware
31 | ====================
32 |
33 | Run the following commands in the build folder.
34 |
35 | .. code-block:: console
36 |
37 | make run_example_audio_mux
38 |
39 | ================================
40 | Debugging the firmware with xgdb
41 | ================================
42 |
43 | Run the following commands in the build folder.
44 |
45 | .. code-block:: console
46 |
47 | make debug_example_audio_mux
48 |
49 | ***********************************
50 | Deploying the firmware with Windows
51 | ***********************************
52 |
53 | =====================
54 | Building the firmware
55 | =====================
56 |
57 | Run the following commands in the repository root folder.
58 |
59 | .. code-block:: console
60 |
61 | cmake -G "NMake Makefiles" -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
62 | cd build
63 | nmake example_audio_mux
64 |
65 | ====================
66 | Running the firmware
67 | ====================
68 |
69 | Run the following commands in the build folder.
70 |
71 | .. code-block:: console
72 |
73 | nmake run_example_audio_mux
74 |
75 | ================================
76 | Debugging the firmware with xgdb
77 | ================================
78 |
79 | Run the following commands in the build folder.
80 |
81 | .. code-block:: console
82 |
83 | nmake debug_example_audio_mux
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/examples/examples.rst:
--------------------------------------------------------------------------------
1 | .. _sdk-freertos-code-examples:
2 |
3 | ######################
4 | FreeRTOS Code Examples
5 | ######################
6 |
7 | Several FreeRTOS code examples are included to illustrate the fundamental tool flow and provide a starting point for new applications. The examples do not seek to exhibit the full potential of the platform, and are purposely basic to provide instruction. Select an example below for more information on what the example demonstrates, how to build the example, and how to run it.
8 |
9 | .. toctree::
10 | :maxdepth: 1
11 | :includehidden:
12 |
13 | audio_mux.rst
14 | device_control.rst
15 | dfu.rst
16 | explorer_board.rst
17 | iot.rst
18 | l2_cache.rst
19 | tracealyzer.rst
20 | xlink.rst
21 | xscope_fileio.rst
22 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/examples/getting_started.rst:
--------------------------------------------------------------------------------
1 | .. _freertos-getting-started:
2 |
3 | ################################
4 | FreeRTOS Getting Started Example
5 | ################################
6 |
7 | This is a simple multi-tile FreeRTOS example application. It starts the FreeRTOS scheduler running on both `tile[0]` and `tile[1]`. `tile[0]` has two tasks running. One prints "Hello from tile 0" to the console and the other task blinks the 4 LEDs on the Explorer board. `tile[1]` has one task running that prints "Hello from tile 0" to the console.
8 |
9 | ******************************************
10 | Deploying the firmware with Linux or macOS
11 | ******************************************
12 |
13 | =====================
14 | Building the firmware
15 | =====================
16 |
17 | Run the following commands in the xcore_iot root folder to build the firmware:
18 |
19 | .. code-block:: console
20 |
21 | cmake -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
22 | cd build
23 | make example_freertos_getting_started
24 |
25 | ====================
26 | Running the firmware
27 | ====================
28 |
29 | From the build folder run:
30 |
31 | .. code-block:: console
32 |
33 | make run_example_freertos_getting_started
34 |
35 | ***********************************
36 | Deploying the firmware with Windows
37 | ***********************************
38 |
39 | =====================
40 | Building the firmware
41 | =====================
42 |
43 | Run the following commands in the xcore_iot root folder to build the firmware:
44 |
45 | .. code-block:: console
46 |
47 | cmake -G "NMake Makefiles" -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
48 | cd build
49 | nmake example_freertos_getting_started
50 |
51 | ====================
52 | Running the firmware
53 | ====================
54 |
55 | From the build folder run:
56 |
57 | .. code-block:: console
58 |
59 | nmake run_example_freertos_getting_started
60 |
61 | ******************
62 | Application output
63 | ******************
64 |
65 | If successful, you should see the following print messages in the console:
66 |
67 | .. code-block:: console
68 |
69 | Hello from tile 0
70 | Hello from tile 1
71 | Hello from tile 0
72 | Hello from tile 1
73 | Hello from tile 0
74 | Hello from tile 1
75 |
76 | And all four LEDs should be blinking.
77 |
78 | **Congratulations!** You've just built and run your first application for xcore.
79 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/examples/images/xscope_fileio_functional_diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/doc/programming_guide/tutorials/freertos/examples/images/xscope_fileio_functional_diagram.png
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/examples/l2_cache.rst:
--------------------------------------------------------------------------------
1 | ################
2 | L2 Cache Example
3 | ################
4 |
5 | The L2 cache example demonstrates how to use the software defined L2 cache.
6 |
7 | ******************************************
8 | Deploying the firmware with Linux or macOS
9 | ******************************************
10 |
11 | =====================
12 | Building the firmware
13 | =====================
14 |
15 | Run the following commands in the xcore_iot root folder to build the firmware:
16 |
17 | .. code-block:: console
18 |
19 | cmake -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
20 | cd build
21 | make example_freertos_l2_cache
22 |
23 | =======================
24 | Setting up the hardware
25 | =======================
26 |
27 | Before running the firmware, the swmem must be flashed.
28 |
29 | .. code-block:: console
30 |
31 | make flash_example_freertos_l2_cache_swmem
32 |
33 | ====================
34 | Running the firmware
35 | ====================
36 |
37 | Running with hardware.
38 |
39 | .. code-block:: console
40 |
41 | make run_example_freertos_l2_cache
42 |
43 | ***********************************
44 | Deploying the firmware with Windows
45 | ***********************************
46 |
47 | =====================
48 | Building the firmware
49 | =====================
50 |
51 | Run the following commands in the xcore_iot root folder to build the firmware:
52 |
53 | .. code-block:: console
54 |
55 | cmake -G "NMake Makefiles" -B build -DCMAKE_TOOLCHAIN_FILE=xmos_cmake_toolchain/xs3a.cmake
56 | cd build
57 | nmake example_freertos_l2_cache
58 |
59 |
60 | =======================
61 | Setting up the hardware
62 | =======================
63 |
64 | Before running the firmware, the swmem must be flashed.
65 |
66 | .. code-block:: console
67 |
68 | nmake flash_example_freertos_l2_cache_swmem
69 |
70 | ====================
71 | Running the firmware
72 | ====================
73 |
74 | Running with hardware.
75 |
76 | .. code-block:: console
77 |
78 | nmake run_example_freertos_l2_cache
79 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/freertos/freertos.rst:
--------------------------------------------------------------------------------
1 | ########
2 | FreeRTOS
3 | ########
4 |
5 | .. toctree::
6 | :maxdepth: 2
7 |
8 | examples/examples
9 | faq
10 | common_issues
11 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/platform.rst:
--------------------------------------------------------------------------------
1 | ########
2 | Platform
3 | ########
4 |
5 | *****************************
6 | Architecture & Hardware Guide
7 | *****************************
8 |
9 | See the `Architecture & Hardware Guide `_ in the XTC Tools documentation for an introduction to the xcore platform architecture and hardware.
10 |
11 | *****************
12 | Programming Guide
13 | *****************
14 |
15 | See the `Programming Guide `_ in the XTC Tools documentation for an introduction to xcore platform programming.
16 |
--------------------------------------------------------------------------------
/doc/programming_guide/tutorials/tutorials.rst:
--------------------------------------------------------------------------------
1 | .. _xcore-iot-tutorials:
2 |
3 | #########################
4 | Getting Started Tutorials
5 | #########################
6 |
7 | Follow these 3 steps:
8 |
9 | #. :ref:`Check the system requirements and prerequisites `
10 | #. :ref:`Install XCORE-IOT `
11 | #. Select the Getting Started guide below based on your preferred development path
12 |
13 | - :ref:`Build and run your first FreeRTOS application on xcore `
14 |
15 | Now you are ready to dive into the advanced tutorials.
16 |
17 | .. _sdk-advanced-tutorials:
18 |
19 | ##################
20 | Advanced Tutorials
21 | ##################
22 |
23 | .. toctree::
24 | :maxdepth: 2
25 |
26 | platform
27 | bare_metal/bare_metal
28 | freertos/freertos
29 |
--------------------------------------------------------------------------------
/doc/src_html/.gitkeep:
--------------------------------------------------------------------------------
1 | # This directory needs to exist for the doc builder
--------------------------------------------------------------------------------
/doc/substitutions.rst:
--------------------------------------------------------------------------------
1 | .. |I2C| replace:: I\ :sup:`2`\ C
2 | .. |I2S| replace:: I\ :sup:`2`\ S
3 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/README.md:
--------------------------------------------------------------------------------
1 | # Explorer Board
2 |
3 | This example application demonstrates various capabilities of the Explorer board.
4 |
5 | The example consists of pdm_mics to a simple audio processing pipeline which
6 | applies a variable gain. Pressing button 0 will increase the gain. Pressing
7 | button 1 will decrease the gain. The processed audio is sent to the DAC.
8 |
9 | When button 0 is pressed, LED 0 will be lit. When button 1 is pressed, LED 1
10 | will be lit. When the gain adjusted audio passes a frame power threshold, LED 2
11 | will be lit. Lastly, LED 3 will blink periodically.
12 |
13 | Additionally, the example demonstrates a simple flash, UART loopback and SPI setup.
14 |
15 | ## CMake Targets
16 |
17 | The following CMake targets are provided:
18 |
19 | - example_bare_metal_explorer_board
20 | - run_example_bare_metal_explorer_board
21 | - debug_example_bare_metal_explorer_board
22 |
23 | ## Deploying the Firmware
24 |
25 | See the Programming Guide for information on building and running the application.
26 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | /* Audio Pipeline Configuration */
8 | #define appconfAUDIO_FRAME_LENGTH MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME
9 | #define appconfMIC_COUNT MIC_ARRAY_CONFIG_MIC_COUNT
10 | #define appconfFRAMES_IN_ALL_CHANS (appconfAUDIO_FRAME_LENGTH * appconfMIC_COUNT)
11 | #define appconfEXP -31
12 | #define appconfINITIAL_GAIN 20
13 | #define appconfAUDIO_PIPELINE_MAX_GAIN 60
14 | #define appconfAUDIO_PIPELINE_MIN_GAIN 0
15 | #define appconfAUDIO_PIPELINE_GAIN_STEP 4
16 | #define appconfPOWER_THRESHOLD (float)0.00001
17 | #define appconfAUDIO_CLOCK_FREQUENCY 24576000
18 | #define appconfPDM_CLOCK_FREQUENCY 3072000
19 | #define appconfPIPELINE_AUDIO_SAMPLE_RATE 16000
20 |
21 | #endif /* APP_CONF_H_ */
22 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/audio_pipeline/audio_pipeline.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef AUDIO_PIPELINE_H_
5 | #define AUDIO_PIPELINE_H_
6 |
7 | #include
8 | #include
9 |
10 | DECLARE_JOB(ap_stage_a, (chanend_t, chanend_t));
11 | DECLARE_JOB(ap_stage_b, (chanend_t, chanend_t, chanend_t));
12 | DECLARE_JOB(ap_stage_c, (chanend_t, chanend_t, chanend_t));
13 |
14 | #endif /* AUDIO_PIPELINE_H_ */
15 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/demos/app_demos.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_DEMOS_H_
5 | #define APP_DEMOS_H_
6 |
7 | /* System headers */
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include
14 | #include
15 |
16 | /* Platform headers */
17 | #include "xcore_utils.h"
18 | #include "spi.h"
19 | #include "uart.h"
20 |
21 | DECLARE_JOB(spi_demo, (spi_master_device_t*));
22 | DECLARE_JOB(gpio_server, (chanend_t, chanend_t));
23 | DECLARE_JOB(flash_demo, (void));
24 | DECLARE_JOB(uart_rx_demo, (uart_rx_t *));
25 | DECLARE_JOB(uart_tx_demo, (uart_tx_t *));
26 |
27 | #endif /* APP_CONF_H_ */
28 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/demos/flash_demo.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* App headers */
5 | #include "app_demos.h"
6 |
7 | void flash_demo(void)
8 | {
9 | uint32_t flash_size = fl_getFlashSize();
10 | debug_printf("Flash size: 0x%x\n", flash_size);
11 | while(1) {;}
12 | }
13 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/demos/spi_demo.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* App headers */
5 | #include "app_demos.h"
6 |
7 | void spi_demo(spi_master_device_t* device_ctx)
8 | {
9 | uint32_t in_buf = 0;
10 | uint32_t out_buf = 0;
11 |
12 | spi_master_start_transaction(device_ctx);
13 | spi_master_transfer(device_ctx,
14 | (uint8_t *)&out_buf,
15 | (uint8_t *)&in_buf,
16 | 4);
17 | spi_master_end_transaction(device_ctx);
18 |
19 | debug_printf("SPI received: 0x%x\n", out_buf);
20 | while(1) {;}
21 | }
22 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/demos/uart_demo.c:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 | #include
7 | #include
8 |
9 | /* Platform headers */
10 | #include "soc.h"
11 | #include "xcore_utils.h"
12 | #include "uart.h"
13 |
14 | /* App headers */
15 | #include "app_conf.h"
16 | #include "app_demos.h"
17 |
18 | static bool logged_error = false;
19 |
20 | void uart_rx_demo(uart_rx_t* uart_rx_ctx)
21 | {
22 | uint8_t expected = 0;
23 |
24 | while(1) {
25 | uint8_t rx = uart_rx(uart_rx_ctx);
26 | if(rx != expected && !logged_error){
27 | debug_printf("UART data error, expected: %d got: %d\n", expected, rx);
28 | debug_printf("Further UART errors will NOT be printed. Have you connected pins X1D36 and X1D39?\n\n");
29 | logged_error = true;
30 | }
31 | expected++;
32 | }
33 | }
34 |
35 |
36 | void uart_tx_demo(uart_tx_t* uart_tx_ctx)
37 | {
38 | debug_printf("Starting tx ramp test @ %ubaud..\n", XS1_TIMER_HZ / uart_tx_ctx->bit_time_ticks);
39 |
40 | uint8_t tx_data = 0;
41 | uint32_t time_now = get_reference_time();
42 | while(get_reference_time() < (time_now + 100000)); // Wait for a millisecond
43 |
44 | while(1) {
45 | for(int i=0; i<256; i++){
46 | uart_tx(uart_tx_ctx, tx_data);
47 | tx_data+=1;
48 | }
49 | uint32_t time_now = get_reference_time();
50 | while(get_reference_time() < (time_now + 10000000)); // Wait for 100 milliseconds
51 | // debug_printf("Sent: %u\n", tx_data);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/main.c:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* App headers */
5 | #include "app_conf.h"
6 | #include "app_demos.h"
7 | #include "burn.h"
8 | #include "audio_pipeline.h"
9 | #include "platform_init.h"
10 |
11 | void main_tile0(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3)
12 | {
13 | (void)c0;
14 | (void)c2;
15 | (void)c3;
16 |
17 | platform_init_tile_0(c1);
18 |
19 | PAR_JOBS (
20 | PJOB(spi_demo, (&tile0_ctx->spi_device_ctx)),
21 | PJOB(gpio_server, (tile0_ctx->c_from_gpio, tile0_ctx->c_to_gpio)),
22 | PJOB(flash_demo, ()),
23 | PJOB(burn, ()),
24 | PJOB(burn, ()),
25 | PJOB(burn, ()),
26 | PJOB(burn, ()),
27 | PJOB(burn, ())
28 | );
29 | }
30 |
31 | void main_tile1(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3)
32 | {
33 | (void)c1;
34 | (void)c2;
35 | (void)c3;
36 |
37 | platform_init_tile_1(c0);
38 |
39 | streaming_channel_t s_chan_ab = s_chan_alloc();
40 | streaming_channel_t s_chan_bc = s_chan_alloc();
41 | streaming_channel_t s_chan_output = s_chan_alloc();
42 | channel_t chan_decoupler = chan_alloc();
43 |
44 | tile1_ctx->c_i2s_to_dac = s_chan_output.end_b;
45 |
46 | PAR_JOBS (
47 | PJOB(ma_vanilla_task, (chan_decoupler.end_a)),
48 | PJOB(ap_stage_a, (chan_decoupler.end_b, s_chan_ab.end_a)),
49 | PJOB(ap_stage_b, (s_chan_ab.end_b, s_chan_bc.end_a, tile1_ctx->c_from_gpio)),
50 | PJOB(ap_stage_c, (s_chan_bc.end_b, s_chan_output.end_a, tile1_ctx->c_to_gpio)),
51 | PJOB(i2s_master, (&tile1_ctx->i2s_cb_group, tile1_ctx->p_i2s_dout, 1, NULL, 0, tile1_ctx->p_bclk, tile1_ctx->p_lrclk, tile1_ctx->p_mclk, tile1_ctx->bclk)),
52 | PJOB(uart_rx_demo, (&tile1_ctx->uart_rx_ctx)),
53 | PJOB(uart_tx_demo, (&tile1_ctx->uart_tx_ctx)),
54 | PJOB(burn, ())
55 | );
56 | }
57 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/misc/burn.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef BURN_H_
5 | #define BURN_H_
6 |
7 | #define SETSR(c) asm volatile("setsr %0" : : "n"(c));
8 |
9 | DECLARE_JOB(burn, (void));
10 |
11 | void burn(void) {
12 | SETSR(XS1_SR_QUEUE_MASK | XS1_SR_FAST_MASK);
13 | for(;;);
14 | }
15 |
16 | #endif /* BURN_H_ */
17 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/app_pll_ctrl.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | /* System headers */
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | /* App headers */
11 | #include "app_pll_ctrl.h"
12 |
13 | void app_pll_set_numerator(int numerator)
14 | {
15 | const unsigned tileid = get_local_tile_id();
16 | uint32_t fracval = APP_PLL_FRAC_NOM & 0xFFFF00FF;
17 | uint32_t f;
18 |
19 | if (numerator > 255) {
20 | f = 255;
21 | } else if (numerator < 0) {
22 | f = 0;
23 | } else {
24 | f = numerator;
25 | }
26 |
27 | fracval |= (f << 8);
28 | write_sswitch_reg_no_ack(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, fracval);
29 | }
30 |
31 | void app_pll_init(void)
32 | {
33 | unsigned tileid = get_local_tile_id();
34 |
35 | const unsigned APP_PLL_DISABLE = 0x0201FF04;
36 | const unsigned APP_PLL_DIV_0 = 0x80000004;
37 |
38 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_DISABLE);
39 |
40 | hwtimer_t tmr = hwtimer_alloc();
41 | {
42 | xassert(tmr != 0);
43 | hwtimer_delay(tmr, 100000); // 1ms with 100 MHz timer tick
44 | }
45 | hwtimer_free(tmr);
46 |
47 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
48 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
49 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, APP_PLL_FRAC_NOM);
50 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_CLK_DIVIDER_NUM, APP_PLL_DIV_0);
51 | }
52 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/app_pll_ctrl.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef APP_PLL_CTRL_H_
5 | #define APP_PLL_CTRL_H_
6 |
7 | #include "app_conf.h"
8 |
9 | #if (appconfAUDIO_CLOCK_FREQUENCY != 24576000)
10 | #error PLL values only valid if appconfAUDIO_CLOCK_FREQUENCY == 24576000
11 | #endif
12 |
13 | #define APP_PLL_CTL_VAL 0x0A019803 // Valid for all fractional values
14 | #define APP_PLL_FRAC_NOM 0x800095F9 // 24.576000 MHz
15 |
16 | void app_pll_set_numerator(int numerator);
17 | void app_pll_init(void);
18 |
19 | #endif /* APP_PLL_CTRL_H_ */
20 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/mic_support.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef MIC_SUPPORT_H_
5 | #define MIC_SUPPORT_H_
6 |
7 | #include
8 | #include
9 |
10 | #include "app_conf.h"
11 |
12 | void mic_array_setup_ddr(
13 | xclock_t pdmclk,
14 | xclock_t pdmclk6,
15 | port_t p_mclk,
16 | port_t p_pdm_clk,
17 | port_t p_pdm_mics,
18 | int divide);
19 |
20 | void frame_power(int32_t (*audio_frame)[appconfMIC_COUNT]);
21 |
22 | inline int mic_array_decimation_factor(
23 | const unsigned pdm_clock_frequency,
24 | const unsigned sample_rate)
25 | {
26 | return pdm_clock_frequency / (8 * sizeof(int32_t)) / sample_rate;
27 | }
28 |
29 | inline mic_dual_third_stage_coef_t *mic_array_third_stage_coefs(
30 | const unsigned decimation_factor)
31 | {
32 | mic_dual_third_stage_coef_t * const fir_coefs[7] = {
33 | NULL,
34 | g_third_stage_div_2_fir_dual,
35 | g_third_stage_div_4_fir_dual,
36 | g_third_stage_div_6_fir_dual,
37 | g_third_stage_div_8_fir_dual,
38 | NULL,
39 | g_third_stage_div_12_fir_dual
40 | };
41 |
42 | return fir_coefs[decimation_factor/2];
43 | }
44 |
45 | inline int mic_array_fir_compensation(
46 | const unsigned decimation_factor)
47 | {
48 | const int fir_gain_compen[7] = {
49 | 0,
50 | FIR_COMPENSATOR_DIV_2,
51 | FIR_COMPENSATOR_DIV_4,
52 | FIR_COMPENSATOR_DIV_6,
53 | FIR_COMPENSATOR_DIV_8,
54 | 0,
55 | FIR_COMPENSATOR_DIV_12
56 | };
57 |
58 | return fir_gain_compen[decimation_factor/2];
59 | }
60 |
61 | #endif /* MIC_SUPPORT_H_ */
62 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/platform_init.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef PLATFORM_INIT_H_
5 | #define PLATFORM_INIT_H_
6 |
7 | /* System headers */
8 | #include
9 | #include
10 |
11 | /* Platform headers */
12 | #include "soc.h"
13 | #include "xcore_utils.h"
14 | #include "mic_array.h"
15 | #include "mic_array_vanilla.h"
16 |
17 | /* App headers */
18 | #include "tile_support.h"
19 | #include "app_pll_ctrl.h"
20 | #include "aic3204.h"
21 |
22 | /** TILE 0 Clock Blocks */
23 | #define SPI_CLKBLK XS1_CLKBLK_1
24 | #define FLASH_CLKBLK XS1_CLKBLK_2
25 | #define MCLK_CLKBLK XS1_CLKBLK_3
26 | // #define UNUSED_CLKBLK XS1_CLKBLK_4
27 | // #define UNUSED_CLKBLK XS1_CLKBLK_5
28 |
29 | /** TILE 1 Clock Blocks */
30 | #define PDM_CLKBLK_1 XS1_CLKBLK_1
31 | #define PDM_CLKBLK_2 XS1_CLKBLK_2
32 | #define I2S_CLKBLK XS1_CLKBLK_3
33 | // #define UNUSED_CLKBLK XS1_CLKBLK_4
34 | // #define UNUSED_CLKBLK XS1_CLKBLK_5
35 |
36 | void platform_init_tile_0(chanend_t c_other_tile);
37 | void platform_init_tile_1(chanend_t c_other_tile);
38 |
39 | #endif /* PLATFORM_INIT_H_ */
40 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/tile_support.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include "tile_support.h"
5 |
6 | static tile0_ctx_t tile0_ctx_s;
7 | tile0_ctx_t *tile0_ctx = &tile0_ctx_s;
8 |
9 | static tile1_ctx_t tile1_ctx_s;
10 | tile1_ctx_t *tile1_ctx = &tile1_ctx_s;
11 |
--------------------------------------------------------------------------------
/examples/bare-metal/explorer_board/src/platform/tile_support.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef TILE_SUPPORT_H_
5 | #define TILE_SUPPORT_H_
6 |
7 | #include
8 |
9 | #include "i2c.h"
10 | #include "i2s.h"
11 | #include "spi.h"
12 | #include "mic_array.h"
13 | #include "uart.h"
14 |
15 | #include
16 | #include
17 |
18 | typedef struct tile0_struct tile0_ctx_t;
19 | struct tile0_struct {
20 | chanend_t c_from_gpio;
21 | chanend_t c_to_gpio;
22 | spi_master_device_t spi_device_ctx;
23 | spi_master_t spi_ctx;
24 | i2c_master_t i2c_ctx;
25 | };
26 |
27 | typedef struct tile1_struct tile1_ctx_t;
28 | struct tile1_struct {
29 | chanend_t c_from_gpio;
30 | chanend_t c_to_gpio;
31 |
32 | i2s_callback_group_t i2s_cb_group;
33 | port_t p_i2s_dout[1];
34 | port_t p_bclk;
35 | port_t p_lrclk;
36 | port_t p_mclk;
37 | xclock_t bclk;
38 | chanend_t c_i2s_to_dac;
39 |
40 | uart_rx_t uart_rx_ctx;
41 | uart_tx_t uart_tx_ctx;
42 | };
43 |
44 | extern tile0_ctx_t *tile0_ctx;
45 | extern tile1_ctx_t *tile1_ctx;
46 |
47 | #endif /* TILE_SUPPORT_H_ */
48 |
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/README.md:
--------------------------------------------------------------------------------
1 | # Explorer Board
2 |
3 | This example application implements the `Visual Wake Words `__ CNN architecture. The VWW model is trained to classify images to two classes (person/not-person) and serves as a popular use-case for microcontrollers.
4 |
5 | This example demonstrates how to receive input data using `xscope`.
6 |
7 | ## CMake Targets
8 |
9 | The following CMake targets are provided:
10 |
11 | - example_bare_metal_vww
12 | - run_example_bare_metal_vww
13 | - flash_app_example_bare_metal_vww
14 |
15 | ## Deploying the Firmware & Optimizing the Model
16 |
17 | See the Programming Guide for information on building and running the application as well as information on optimizing the TFLite quantized model for xcore using the XMOS AI Tools.
18 |
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/model/vww_model_nibble_swapped.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/examples/bare-metal/visual_wake_words/model/vww_model_nibble_swapped.bin
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/model/vww_quant.tflite:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/examples/bare-metal/visual_wake_words/model/vww_quant.tflite
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/src/main.cpp:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 |
10 | #include "vww_model.h"
11 |
12 | static int8_t *input_buffer;
13 | static size_t input_size;
14 | static int8_t *output_buffer;
15 | static size_t output_size;
16 | static int input_bytes = 0;
17 |
18 | void print_output()
19 | {
20 | for (int i = 0; i < output_size; i++)
21 | {
22 | printf("Output index=%u, value=%i\n", i, (signed char)output_buffer[i]);
23 | }
24 | printf("DONE!\n");
25 | }
26 |
27 | extern "C" {
28 |
29 | #pragma stackfunction 1000
30 | void app_data(unsigned char *data, size_t size)
31 | {
32 | memcpy(input_buffer + input_bytes, data, size - 1);
33 | input_bytes += size - 1;
34 | if (input_bytes == input_size)
35 | {
36 | TfLiteStatus status = model_invoke();
37 | if (status != kTfLiteOk) {
38 | printf("ERROR: model_invoke returned %d\n", status);
39 | _Exit(1);
40 | }
41 |
42 | print_output();
43 | input_bytes = 0;
44 | }
45 | }
46 |
47 | #pragma stackfunction 1000
48 | void app_init(chanend_t flash_server)
49 | {
50 | // Initialize the model
51 | TfLiteStatus status = model_init((void *)flash_server);
52 | if (status != kTfLiteOk) {
53 | printf("ERROR: model_init returned %d\n", status);
54 | _Exit(1);
55 | }
56 |
57 | // Setup model input and output buffers
58 | input_buffer = model_input(0)->data.int8;
59 | input_size = model_input_size(0);
60 | output_buffer = model_output(0)->data.int8;
61 | output_size = model_output_size(0);
62 |
63 | printf("model initialized\n");
64 | }
65 |
66 |
67 | }
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/src/main.xc:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #include
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | extern "C" {
12 | void app_init(chanend flash_server);
13 | void app_data(unsigned char *data, size_t size);
14 | void flash_server(chanend c);
15 | }
16 |
17 |
18 | unsafe {
19 | void process_xscope(chanend c_xscope_data_in) {
20 | int bytes_read = 0;
21 | unsigned char buffer[256];
22 |
23 | xscope_connect_data_from_host(c_xscope_data_in);
24 | xscope_mode_lossless();
25 | while (1) {
26 | select {
27 | case xscope_data_from_host(c_xscope_data_in, buffer, bytes_read):
28 | app_data(buffer, bytes_read);
29 | break;
30 | }
31 | }
32 | }
33 | }
34 |
35 | int main(void) {
36 | chan c_xscope_data_in;
37 | chan c_flash_server;
38 |
39 | par {
40 | xscope_host_data(c_xscope_data_in);
41 | on tile[0] : {
42 | app_init(c_flash_server);
43 | process_xscope(c_xscope_data_in);
44 | }
45 | on tile[0] : flash_server(c_flash_server);
46 | }
47 |
48 | return 0;
49 | }
50 |
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/src/vww_model:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/examples/bare-metal/visual_wake_words/src/vww_model
--------------------------------------------------------------------------------
/examples/bare-metal/visual_wake_words/src/vww_model.h:
--------------------------------------------------------------------------------
1 | // This file is generated. Do not edit.
2 | // Generated on: 07.06.2023 12:31:17
3 |
4 | #ifndef model_GEN_H
5 | #define model_GEN_H
6 |
7 | #include "tensorflow/lite/c/common.h"
8 |
9 | // Sets up the model with init and prepare steps.
10 | TfLiteStatus model_init(void *flash_data = nullptr);
11 | // Returns the input tensor with the given index.
12 | TfLiteTensor *model_input(int index);
13 | // Returns the output tensor with the given index.
14 | TfLiteTensor *model_output(int index);
15 | // Runs inference for the model.
16 | TfLiteStatus model_invoke();
17 |
18 | // Returns the number of input tensors.
19 | inline size_t model_inputs() {
20 | return 1;
21 | }
22 | // Returns the number of output tensors.
23 | inline size_t model_outputs() {
24 | return 1;
25 | }
26 |
27 | inline void *model_input_ptr(int index) {
28 | return model_input(index)->data.data;
29 | }
30 | inline size_t model_input_size(int index) {
31 | return model_input(index)->bytes;
32 | }
33 | inline int model_input_dims_len(int index) {
34 | return model_input(index)->dims->data[0];
35 | }
36 | inline int *model_input_dims(int index) {
37 | return &model_input(index)->dims->data[1];
38 | }
39 |
40 | inline void *model_output_ptr(int index) {
41 | return model_output(index)->data.data;
42 | }
43 | inline size_t model_output_size(int index) {
44 | return model_output(index)->bytes;
45 | }
46 | inline int model_output_dims_len(int index) {
47 | return model_output(index)->dims->data[0];
48 | }
49 | inline int *model_output_dims(int index) {
50 | return &model_output(index)->dims->data[1];
51 | }
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/examples/examples.cmake:
--------------------------------------------------------------------------------
1 | ## XCORE_XS3A only examples
2 | if(${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS3A)
3 | ## Bare metal examples
4 | include(${CMAKE_CURRENT_LIST_DIR}/bare-metal/explorer_board/explorer_board.cmake)
5 | include(${CMAKE_CURRENT_LIST_DIR}/bare-metal/visual_wake_words/visual_wake_words.cmake)
6 |
7 | ## FreeRTOS examples
8 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/audio_mux/audio_mux.cmake)
9 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/dfu/dfu.cmake)
10 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/device_control/device_control.cmake)
11 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/explorer_board/explorer_board.cmake)
12 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/getting_started/getting_started.cmake)
13 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/iot/iot.cmake)
14 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/l2_cache/l2_cache.cmake)
15 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/tracealyzer/tracealyzer.cmake)
16 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/xlink/xlink.cmake)
17 | include(${CMAKE_CURRENT_LIST_DIR}/freertos/xscope_fileio/xscope_fileio.cmake)
18 | else()
19 | # Determine OS, set up install dir
20 | if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
21 | set(HOST_INSTALL_DIR "$ENV{USERPROFILE}\\.xmos\\bin")
22 | else()
23 | set(HOST_INSTALL_DIR "/opt/xmos/bin")
24 | endif()
25 |
26 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/freertos/device_control/host)
27 | add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/freertos/tracealyzer/host)
28 | add_subdirectory(modules/xscope_fileio/xscope_fileio/host)
29 | install(TARGETS xscope_host_endpoint DESTINATION ${HOST_INSTALL_DIR})
30 | endif()
31 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/README.md:
--------------------------------------------------------------------------------
1 | # Audio Mux Example Design
2 |
3 | This example application can be configured for onboard mic, usb audio, or i2s input. Outputs are usb audio and i2s. No DSP is performed on the audio, but the example contains an empty 2 tile pipeline skeleton for a user to populate. The USB audio endpoints are sychronous.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_audio_mux
10 | - run_example_audio_mux
11 | - debug_example_audio_mux
12 |
13 | ## Deploying the Firmware
14 |
15 | See the Programming Guide for information on building and running the application.
16 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/XCORE-AI-EXPLORER.cmake:
--------------------------------------------------------------------------------
1 |
2 | ## Create custom board targets for application
3 | add_library(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer INTERFACE)
4 | target_sources(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
5 | INTERFACE
6 | ${CMAKE_CURRENT_LIST_DIR}/platform/dac_port.c
7 | ${CMAKE_CURRENT_LIST_DIR}/platform/app_pll_ctrl.c
8 | ${CMAKE_CURRENT_LIST_DIR}/platform/driver_instances.c
9 | ${CMAKE_CURRENT_LIST_DIR}/platform/platform_init.c
10 | ${CMAKE_CURRENT_LIST_DIR}/platform/platform_start.c
11 | )
12 | target_include_directories(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
13 | INTERFACE
14 | ${CMAKE_CURRENT_LIST_DIR}
15 | )
16 | target_link_libraries(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
17 | INTERFACE
18 | core::general
19 | rtos::freertos
20 | rtos::drivers::general
21 | rtos::drivers::audio
22 | rtos::drivers::usb
23 | rtos::freertos_usb
24 | xcore_iot::example::audio_mux::dac::aic3204
25 | )
26 | target_compile_options(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
27 | INTERFACE
28 | ${CMAKE_CURRENT_LIST_DIR}/XCORE-AI-EXPLORER.xn
29 | )
30 | target_link_options(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
31 | INTERFACE
32 | ${CMAKE_CURRENT_LIST_DIR}/XCORE-AI-EXPLORER.xn
33 | )
34 | target_compile_definitions(xcore_iot_example_audio_mux_board_support_xcore_ai_explorer
35 | INTERFACE
36 | XCOREAI_EXPLORER=1
37 | PLATFORM_SUPPORTS_TILE_0=1
38 | PLATFORM_SUPPORTS_TILE_1=1
39 | PLATFORM_SUPPORTS_TILE_2=0
40 | PLATFORM_SUPPORTS_TILE_3=0
41 | USB_TILE_NO=0
42 | USB_TILE=tile[USB_TILE_NO]
43 |
44 | MIC_ARRAY_CONFIG_MCLK_FREQ=24576000
45 | MIC_ARRAY_CONFIG_PDM_FREQ=3072000
46 | MIC_ARRAY_CONFIG_SAMPLES_PER_FRAME=240
47 | MIC_ARRAY_CONFIG_MIC_COUNT=2
48 | MIC_ARRAY_CONFIG_CLOCK_BLOCK_A=XS1_CLKBLK_1
49 | MIC_ARRAY_CONFIG_CLOCK_BLOCK_B=XS1_CLKBLK_2
50 | MIC_ARRAY_CONFIG_PORT_MCLK=PORT_MCLK_IN
51 | MIC_ARRAY_CONFIG_PORT_PDM_CLK=PORT_PDM_CLK
52 | MIC_ARRAY_CONFIG_PORT_PDM_DATA=PORT_PDM_DATA
53 | )
54 |
55 | ## Create an alias
56 | add_library(xcore_iot::example::audio_mux::xcore_ai_explorer ALIAS xcore_iot_example_audio_mux_board_support_xcore_ai_explorer)
57 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/app_pll_ctrl.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | /* System headers */
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | /* App headers */
11 | #include "platform/app_pll_ctrl.h"
12 |
13 | void app_pll_set_numerator(int numerator)
14 | {
15 | const unsigned tileid = get_local_tile_id();
16 | uint32_t fracval = APP_PLL_FRAC_NOM & 0xFFFF00FF;
17 | uint32_t f;
18 |
19 | if (numerator > 255) {
20 | f = 255;
21 | } else if (numerator < 0) {
22 | f = 0;
23 | } else {
24 | f = numerator;
25 | }
26 |
27 | fracval |= (f << 8);
28 | write_sswitch_reg_no_ack(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, fracval);
29 | }
30 |
31 | void app_pll_init(void)
32 | {
33 | unsigned tileid = get_local_tile_id();
34 |
35 | const unsigned APP_PLL_DISABLE = 0x0201FF04;
36 | const unsigned APP_PLL_DIV_0 = 0x80000004;
37 |
38 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_DISABLE);
39 |
40 | hwtimer_t tmr = hwtimer_alloc();
41 | {
42 | xassert(tmr != 0);
43 | hwtimer_delay(tmr, 100000); // 1ms with 100 MHz timer tick
44 | }
45 | hwtimer_free(tmr);
46 |
47 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
48 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_CTL_NUM, APP_PLL_CTL_VAL);
49 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_PLL_FRAC_N_DIVIDER_NUM, APP_PLL_FRAC_NOM);
50 | write_sswitch_reg(tileid, XS1_SSWITCH_SS_APP_CLK_DIVIDER_NUM, APP_PLL_DIV_0);
51 | }
52 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/app_pll_ctrl.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef APP_PLL_CTRL_H_
5 | #define APP_PLL_CTRL_H_
6 |
7 | #include "platform_conf.h"
8 |
9 | #if (MIC_ARRAY_CONFIG_MCLK_FREQ != 24576000)
10 | #error PLL values only valid if MIC_ARRAY_CONFIG_MCLK_FREQ == 24576000
11 | #endif
12 |
13 | #define APP_PLL_CTL_VAL 0x0A019803 // Valid for all fractional values
14 | #define APP_PLL_FRAC_NOM 0x800095F9 // 24.576000 MHz
15 |
16 | void app_pll_set_numerator(int numerator);
17 | void app_pll_init(void);
18 |
19 | #endif /* APP_PLL_CTRL_H_ */
20 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/dac_port.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | /* System headers */
5 | #include
6 |
7 | /* FreeRTOS headers */
8 | #include "FreeRTOS.h"
9 |
10 | /* App headers */
11 | #include "platform_conf.h"
12 | #include "platform/driver_instances.h"
13 | #include "aic3204.h"
14 |
15 | int aic3204_reg_write(uint8_t reg, uint8_t val)
16 | {
17 | i2c_regop_res_t ret;
18 |
19 | ret = rtos_i2c_master_reg_write(i2c_master_ctx, AIC3204_I2C_DEVICE_ADDR, reg, val);
20 |
21 | if (ret == I2C_REGOP_SUCCESS) {
22 | return 0;
23 | } else {
24 | return -1;
25 | }
26 | }
27 |
28 | void aic3204_codec_reset(void)
29 | {
30 | const rtos_gpio_port_id_t codec_rst_port = rtos_gpio_port(PORT_CODEC_RST_N);
31 | rtos_gpio_port_enable(gpio_ctx_t1, codec_rst_port);
32 | rtos_gpio_port_out(gpio_ctx_t1, codec_rst_port, 0xF);
33 | }
34 |
35 | void aic3204_wait(uint32_t wait_ms)
36 | {
37 | vTaskDelay(pdMS_TO_TICKS(wait_ms));
38 | }
39 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/driver_instances.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include "platform/driver_instances.h"
5 |
6 | static rtos_intertile_t intertile_ctx_s;
7 | rtos_intertile_t *intertile_ctx = &intertile_ctx_s;
8 |
9 | static rtos_qspi_flash_t qspi_flash_ctx_s;
10 | rtos_qspi_flash_t *qspi_flash_ctx = &qspi_flash_ctx_s;
11 |
12 | static rtos_gpio_t gpio_ctx_t0_s;
13 | rtos_gpio_t *gpio_ctx_t0 = &gpio_ctx_t0_s;
14 |
15 | static rtos_gpio_t gpio_ctx_t1_s;
16 | rtos_gpio_t *gpio_ctx_t1 = &gpio_ctx_t1_s;
17 |
18 | static rtos_mic_array_t mic_array_ctx_s;
19 | rtos_mic_array_t *mic_array_ctx = &mic_array_ctx_s;
20 |
21 | static rtos_i2c_master_t i2c_master_ctx_s;
22 | rtos_i2c_master_t *i2c_master_ctx = &i2c_master_ctx_s;
23 |
24 | static rtos_i2s_t i2s_ctx_s;
25 | rtos_i2s_t *i2s_ctx = &i2s_ctx_s;
26 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/driver_instances.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DRIVER_INSTANCES_H_
5 | #define DRIVER_INSTANCES_H_
6 |
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | #include "rtos_intertile.h"
12 | #include "rtos_qspi_flash.h"
13 | #include "rtos_gpio.h"
14 | #include "rtos_i2c_master.h"
15 | #include "rtos_i2s.h"
16 |
17 | #ifdef __cplusplus
18 | };
19 | #endif
20 |
21 | #include "rtos_mic_array.h"
22 |
23 | /* Tile specifiers */
24 | #define FLASH_TILE_NO 0
25 | #define I2C_TILE_NO 0
26 | #define MICARRAY_TILE_NO 1
27 | #define I2S_TILE_NO 1
28 |
29 | /** TILE 0 Clock Blocks */
30 | #define FLASH_CLKBLK XS1_CLKBLK_1
31 | #define MCLK_CLKBLK XS1_CLKBLK_2
32 | #define XUD_CLKBLK_1 XS1_CLKBLK_4 /* Reserved for lib_xud */
33 | #define XUD_CLKBLK_2 XS1_CLKBLK_5 /* Reserved for lib_xud */
34 |
35 | /** TILE 1 Clock Blocks */
36 | #define PDM_CLKBLK_1 XS1_CLKBLK_1
37 | #define PDM_CLKBLK_2 XS1_CLKBLK_2
38 | #define I2S_CLKBLK XS1_CLKBLK_3
39 |
40 | /* Port definitions */
41 | #define PORT_MCLK PORT_MCLK_IN
42 |
43 | extern rtos_intertile_t *intertile_ctx;
44 | extern rtos_qspi_flash_t *qspi_flash_ctx;
45 | extern rtos_gpio_t *gpio_ctx_t0;
46 | extern rtos_gpio_t *gpio_ctx_t1;
47 | extern rtos_mic_array_t *mic_array_ctx;
48 | extern rtos_i2c_master_t *i2c_master_ctx;
49 | extern rtos_i2s_t *i2s_ctx;
50 |
51 | #endif /* DRIVER_INSTANCES_H_ */
52 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/XCORE-AI-EXPLORER/platform/platform_init.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef PLATFORM_INIT_H_
5 | #define PLATFORM_INIT_H_
6 |
7 | #include
8 |
9 | void platform_init(chanend_t other_tile_c);
10 | void platform_start(void);
11 |
12 | #endif /* PLATFORM_INIT_H_ */
13 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/bsp_config.cmake:
--------------------------------------------------------------------------------
1 |
2 | include(${CMAKE_CURRENT_LIST_DIR}/dac/dac.cmake)
3 | include(${CMAKE_CURRENT_LIST_DIR}/XCORE-AI-EXPLORER/XCORE-AI-EXPLORER.cmake)
4 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/bsp_config/dac/dac.cmake:
--------------------------------------------------------------------------------
1 |
2 | ## Create custom board targets for dacs
3 | add_library(xcore_iot_example_audio_mux_board_support_dac_aic3204 INTERFACE)
4 | target_sources(xcore_iot_example_audio_mux_board_support_dac_aic3204
5 | INTERFACE
6 | ${CMAKE_CURRENT_LIST_DIR}/aic3204/aic3204.c
7 | )
8 | target_include_directories(xcore_iot_example_audio_mux_board_support_dac_aic3204
9 | INTERFACE
10 | ${CMAKE_CURRENT_LIST_DIR}/aic3204
11 | )
12 | target_compile_definitions(xcore_iot_example_audio_mux_board_support_dac_aic3204
13 | INTERFACE
14 | AIC3204=1
15 | )
16 |
17 | ## Create an alias
18 | add_library(xcore_iot::example::audio_mux::dac::aic3204 ALIAS xcore_iot_example_audio_mux_board_support_dac_aic3204)
19 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/src/app_conf_check.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef APP_CONF_CHECK_H_
5 | #define APP_CONF_CHECK_H_
6 |
7 | #if !XCOREAI_EXPLORER
8 | #error Only the XCORE-AI-EXPLORER Board is supported
9 | #endif
10 |
11 | #if appconfI2S_MODE != appconfI2S_MODE_MASTER
12 | #error I2S mode other than master is not currently supported
13 | #endif
14 |
15 | #if (appconfUSB_INPUT + appconfMIC_INPUT + appconfI2S_INPUT) > 1
16 | #error Only 1 audio input mode can be selected
17 | #endif
18 |
19 | #if (appconfUSB_INPUT + appconfMIC_INPUT + appconfI2S_INPUT) == 0
20 | #error At least 1 audio input mode must be selected
21 | #endif
22 |
23 | #endif /* APP_CONF_CHECK_H_ */
24 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/src/audio_pipeline/audio_pipeline.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef AUDIO_PIPELINE_H_
5 | #define AUDIO_PIPELINE_H_
6 |
7 | #include
8 | #include "app_conf.h"
9 |
10 | #define AUDIO_PIPELINE_DONT_FREE_FRAME 0
11 | #define AUDIO_PIPELINE_FREE_FRAME 1
12 |
13 | void audio_pipeline_init(
14 | void *input_app_data,
15 | void *output_app_data);
16 |
17 | void audio_pipeline_input(
18 | void *input_app_data,
19 | int32_t **input_audio_frames,
20 | size_t ch_count,
21 | size_t frame_count);
22 |
23 | int audio_pipeline_output(
24 | void *output_app_data,
25 | int32_t **output_audio_frames,
26 | size_t ch_count,
27 | size_t frame_count);
28 |
29 | #endif /* AUDIO_PIPELINE_H_ */
30 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/src/usb/usb_audio.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef USB_AUDIO_H_
5 | #define USB_AUDIO_H_
6 |
7 | /*
8 | * frame_buffers format assumes:
9 | * raw_audio_frame
10 | */
11 | void usb_audio_send(rtos_intertile_t *intertile_ctx,
12 | size_t frame_count,
13 | int32_t **frame_buffers,
14 | size_t num_chans);
15 |
16 | /*
17 | * frame_buffers format assumes:
18 | * raw_audio_frame
19 | */
20 | void usb_audio_recv(rtos_intertile_t *intertile_ctx,
21 | size_t frame_count,
22 | int32_t **frame_buffers,
23 | size_t num_chans);
24 |
25 | void usb_audio_recv_blocking(rtos_intertile_t *intertile_ctx,
26 | size_t frame_count,
27 | int32_t **frame_buffers,
28 | size_t num_chans);
29 |
30 | void usb_audio_init(rtos_intertile_t *intertile_ctx, unsigned priority);
31 |
32 |
33 | #endif /* USB_AUDIO_H_ */
34 |
--------------------------------------------------------------------------------
/examples/freertos/audio_mux/src/usb/usb_descriptors.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef USB_DESCRIPTORS_H_
5 | #define USB_DESCRIPTORS_H_
6 |
7 | #include "tusb_config.h"
8 |
9 | #if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX > 0
10 | #define AUDIO_INPUT_ENABLED 1
11 | #else
12 | #define AUDIO_INPUT_ENABLED 0
13 | #endif
14 | #if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_RX > 0
15 | #define AUDIO_OUTPUT_ENABLED 1
16 | #else
17 | #define AUDIO_OUTPUT_ENABLED 0
18 | #endif
19 |
20 | enum {
21 | ITF_NUM_AUDIO_CONTROL = 0,
22 | #if AUDIO_OUTPUT_ENABLED
23 | ITF_NUM_AUDIO_STREAMING_SPK,
24 | #endif
25 | #if AUDIO_INPUT_ENABLED
26 | ITF_NUM_AUDIO_STREAMING_MIC,
27 | #endif
28 | ITF_NUM_TOTAL
29 | };
30 |
31 | // Unit numbers are arbitrary selected
32 | #define UAC2_ENTITY_CLOCK 0x01
33 | // Speaker path
34 | #define UAC2_ENTITY_SPK_INPUT_TERMINAL 0x11
35 | #define UAC2_ENTITY_SPK_FEATURE_UNIT 0x12
36 | #define UAC2_ENTITY_SPK_OUTPUT_TERMINAL 0x13
37 |
38 | // Microphone path
39 | #define UAC2_ENTITY_MIC_INPUT_TERMINAL 0x21
40 | #define UAC2_ENTITY_MIC_FEATURE_UNIT 0x22
41 | #define UAC2_ENTITY_MIC_OUTPUT_TERMINAL 0x23
42 |
43 | #endif /* USB_DESCRIPTORS_H_ */
44 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/README.md:
--------------------------------------------------------------------------------
1 | # Device Control
2 |
3 | This example application demonstrates how to use device control over USB and I2C.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_device_control
10 | - run_example_freertos_device_control
11 | - debug_example_freertos_device_control
12 |
13 | ## Deploying the Firmware
14 |
15 | See the Programming Guide for information on building and running the application.
16 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/host/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(APP_SOURCES
2 | "device_control_host.c"
3 | "commands.c"
4 | "argtable/argtable3.c"
5 | )
6 |
7 | set(APP_INCLUDES "")
8 |
9 | add_executable(example_freertos_device_control_host)
10 |
11 | target_link_libraries(example_freertos_device_control_host PUBLIC rtos::sw_services::device_control_host_usb)
12 | target_sources(example_freertos_device_control_host PRIVATE ${APP_SOURCES})
13 | target_include_directories(example_freertos_device_control_host PRIVATE ${APP_INCLUDES})
14 |
15 | message(STATUS "Building with ${CMAKE_C_COMPILER_ID}")
16 |
17 | if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
18 | target_link_options(example_freertos_device_control_host PRIVATE "")
19 | else ()
20 | target_compile_options(example_freertos_device_control_host PRIVATE -O2 -Wall)
21 | target_link_options(example_freertos_device_control_host PRIVATE "")
22 | endif ()
23 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/host/argtable/argtable-v3.2.1.52f24e5-amalgamation.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/examples/freertos/device_control/host/argtable/argtable-v3.2.1.52f24e5-amalgamation.tar.gz
--------------------------------------------------------------------------------
/examples/freertos/device_control/host/commands.h:
--------------------------------------------------------------------------------
1 | /*
2 | * commands.h
3 | *
4 | * Created on: Aug 25, 2021
5 | * Author: mbruno
6 | */
7 |
8 | #ifndef COMMANDS_H_
9 | #define COMMANDS_H_
10 |
11 | #include
12 | #include "device_control_host.h"
13 |
14 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
15 |
16 | #define CMDSPEC_PAR_NAME_MAX_LEN (40)
17 | #define CMDSPEC_PAR_INFO_MAX_LEN (200)
18 | #define CMD_MAX_BYTES (64)
19 |
20 | typedef enum {CMD_RO, CMD_WO, CMD_RW} cmd_rw_t;
21 | typedef enum {CMD_GET, CMD_SET} cmd_dir_t;
22 |
23 | typedef union {
24 | uint8_t u8;
25 | int8_t s8;
26 | uint32_t u32;
27 | int32_t s32;
28 | uint64_t u64;
29 | int64_t s64;
30 | float f;
31 | } cmd_param_t;
32 |
33 | /*
34 | * TODO: Maybe number of fractional bits can be stored in the
35 | * cmd_t struct. Then we'd only need type size (1,4,8) and
36 | * signed/unsigned. 0 fractional bits for ints.
37 | */
38 | typedef enum {
39 | // TYPE_FIXED_0_32,
40 | // TYPE_FIXED_1_31,
41 | // TYPE_FIXED_7_24,
42 | // TYPE_FIXED_8_24,
43 | // TYPE_FIXED_16_16,
44 | TYPE_UINT8,
45 | TYPE_INT8,
46 | TYPE_UINT32,
47 | TYPE_INT32,
48 | TYPE_UINT64,
49 | TYPE_INT64,
50 | } cmd_param_type_t;
51 |
52 | static const size_t cmd_param_type_size[] = {
53 | [TYPE_UINT8] = sizeof(uint8_t),
54 | [TYPE_INT8] = sizeof(int8_t),
55 | [TYPE_UINT32] = sizeof(uint32_t),
56 | [TYPE_INT32] = sizeof(int32_t),
57 | [TYPE_UINT64] = sizeof(uint64_t),
58 | [TYPE_INT64] = sizeof(int64_t),
59 | };
60 |
61 | typedef struct {
62 | control_resid_t resid;
63 | char *cmd_name;
64 | cmd_param_type_t type;
65 | int fractional_bits;
66 | control_cmd_t cmd;
67 | cmd_rw_t rw;
68 | unsigned num_values; //no. of values read or written from the device
69 | char *info;
70 | // unsigned device_rw_size; //no. of bytes per value read or written from the device for a given type.
71 | // unsigned app_read_result_size; //for read commands, the total amount of memory app needs to allocate and send for returning read values into .
72 | } cmd_t;
73 |
74 | void command_list_print(void);
75 | cmd_t *command_lookup(const char *s);
76 | cmd_param_t command_arg_string_to_value(cmd_t *cmd, const char *str);
77 | void command_value_print(cmd_t *cmd, cmd_param_t arg);
78 | control_ret_t command_get(cmd_t *cmd, cmd_param_t values[], int num_values);
79 | control_ret_t command_set(cmd_t *cmd, const cmd_param_t values[], int num_values);
80 |
81 |
82 | #endif /* COMMANDS_H_ */
83 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 |
6 | #define appconfGPIO_RPC_PORT 0
7 | #define appconfUSB_MANAGER_SYNC_PORT 3
8 |
9 | #define appconfI2C_CTRL_ENABLED 0
10 | #define appconfUSB_CTRL_ENABLED 1
11 | #define appconf_CONTROL_SERVICER_COUNT 2
12 | #define appconfDEVICE_CONTROL_I2C_PORT 1
13 | #define appconfDEVICE_CONTROL_USB_PORT 2
14 | #define appconfI2C_INTERRUPT_CORE 0
15 |
16 | #define GPIO_TILE_NO 0
17 | #define I2C_TILE_NO 0
18 |
19 | #define I2C_CTRL_TILE_NO 0
20 |
21 | /* Task Priorities */
22 | #define appconfDEVICE_CONTROL_I2C_CLIENT_PRIORITY (configMAX_PRIORITIES-1)
23 | #define appconfDEVICE_CONTROL_USB_CLIENT_PRIORITY (configMAX_PRIORITIES-1)
24 | #define appconfGPIO_RPC_HOST_TASK_PRIORITY (configMAX_PRIORITIES/2)
25 | #define appconfSTARTUP_TASK_PRIORITY (configMAX_PRIORITIES-1)
26 | #define appconfUSB_DEVICE_CTRL_TASK_PRIORITY (configMAX_PRIORITIES-1)
27 | #define appconfI2C_TASK_PRIORITY (configMAX_PRIORITIES/2)
28 |
29 | #endif /* APP_CONF_H_ */
30 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/src/app_control/app_control.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef APP_CONTROL_H_
5 | #define APP_CONTROL_H_
6 |
7 | #include "device_control.h"
8 |
9 | #include "app_conf.h"
10 |
11 | extern device_control_t *device_control_i2c_ctx;
12 | extern device_control_t *device_control_usb_ctx;
13 |
14 | control_ret_t app_control_servicer_register(device_control_servicer_t *ctx,
15 | const control_resid_t resources[],
16 | size_t num_resources);
17 | int app_control_init(void);
18 |
19 | #endif /* APP_CONTROL_H_ */
20 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/device_control/src/tusb_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 | * Copyright (c) 2023 XMOS LIMITED
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | *
25 | */
26 |
27 | #ifndef _TUSB_CONFIG_H_
28 | #define _TUSB_CONFIG_H_
29 |
30 | #include "rtos_printf.h"
31 |
32 | //--------------------------------------------------------------------
33 | // COMMON CONFIGURATION
34 | //--------------------------------------------------------------------
35 |
36 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
37 | #define CFG_TUSB_OS OPT_OS_CUSTOM
38 |
39 | #ifndef CFG_TUSB_DEBUG
40 | #define CFG_TUSB_DEBUG 1
41 | #endif
42 |
43 | #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
44 |
45 | #ifndef CFG_TUSB_DEBUG_PRINTF
46 | #ifdef rtos_printf
47 | #define CFG_TUSB_DEBUG_PRINTF rtos_printf
48 | #endif
49 | #endif
50 |
51 | //--------------------------------------------------------------------
52 | // DEVICE CONFIGURATION
53 | //--------------------------------------------------------------------
54 |
55 | #define CFG_TUD_EP_MAX 12
56 | #define CFG_TUD_TASK_QUEUE_SZ 8
57 | #define CFG_TUD_ENDPOINT0_SIZE 64
58 |
59 | //------------- CLASS -------------//
60 | #define CFG_TUD_CDC 0
61 | #define CFG_TUD_MSC 0
62 | #define CFG_TUD_HID 0
63 | #define CFG_TUD_MIDI 0
64 | #define CFG_TUD_AUDIO 0
65 | #define CFG_TUD_VENDOR 0
66 |
67 |
68 | #endif /* _TUSB_CONFIG_H_ */
69 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/README.md:
--------------------------------------------------------------------------------
1 | # DFU And Loader
2 |
3 | This example application demonstrates a method to add DFU to a FreeRTOS application on XCORE. It also provides an example of using a custom loader to override default image selection at boot.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_dfu_v1
10 | - example_freertos_dfu_v2
11 | - example_freertos_dfu_v3
12 | - erase_all_example_freertos_dfu_v1
13 | - erase_all_example_freertos_dfu_v2
14 | - erase_all_example_freertos_dfu_v3
15 | - flash_app_example_freertos_dfu_v1
16 | - flash_app_example_freertos_dfu_v2
17 | - flash_app_example_freertos_dfu_v3
18 | - create_upgrade_img_example_freertos_dfu_v1
19 | - create_upgrade_img_example_freertos_dfu_v2
20 | - create_upgrade_img_example_freertos_dfu_v3
21 | - create_loader_object_example_freertos_dfu_v1
22 | - create_loader_object_example_freertos_dfu_v2
23 | - create_loader_object_example_freertos_dfu_v3
24 | - run_example_freertos_dfu_v1
25 | - run_example_freertos_dfu_v2
26 | - run_example_freertos_dfu_v3
27 | - debug_example_freertos_dfu_v1
28 | - debug_example_freertos_dfu_v2
29 | - debug_example_freertos_dfu_v3
30 |
31 | ## Deploying the Firmware
32 |
33 | See the Programming Guide for information on building and running the application.
34 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/bsp_config/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ## Create Explorer Board 2V0 target
2 | add_library(example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0 INTERFACE)
3 | target_sources(example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0
4 | INTERFACE
5 | XCORE-AI-EXPLORER_2V0/platform/driver_instances.c
6 | XCORE-AI-EXPLORER_2V0/platform/platform_init.c
7 | XCORE-AI-EXPLORER_2V0/platform/platform_start.c
8 | )
9 | target_include_directories(example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0
10 | INTERFACE
11 | XCORE-AI-EXPLORER_2V0
12 | )
13 | target_link_libraries(example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0
14 | INTERFACE
15 | core::general
16 | rtos::freertos
17 | rtos::drivers::general
18 | rtos::drivers::usb
19 | rtos::drivers::dfu_image
20 | rtos::sw_services::usb
21 |
22 | )
23 | target_compile_definitions(example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0
24 | INTERFACE
25 | XCOREAI_EXPLORER=1
26 | PLATFORM_SUPPORTS_TILE_0=1
27 | PLATFORM_SUPPORTS_TILE_1=1
28 | PLATFORM_SUPPORTS_TILE_2=0
29 | PLATFORM_SUPPORTS_TILE_3=0
30 | USB_TILE_NO=0
31 | USB_TILE=tile[USB_TILE_NO]
32 | )
33 |
34 | ## Create an alias
35 | add_library(example::freertos::dfu::bsp_config::xcore_ai_explorer ALIAS example_freertos_dfu_board_support_config_xcore_ai_explorer_2V0)
36 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/bsp_config/XCORE-AI-EXPLORER_2V0/platform/driver_instances.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include "platform/driver_instances.h"
5 |
6 | static rtos_intertile_t intertile_ctx_s;
7 | rtos_intertile_t *intertile_ctx = &intertile_ctx_s;
8 |
9 | static rtos_qspi_flash_t qspi_flash_ctx_s;
10 | rtos_qspi_flash_t *qspi_flash_ctx = &qspi_flash_ctx_s;
11 |
12 | static rtos_spi_master_t spi_master_ctx_s;
13 | rtos_spi_master_t *spi_master_ctx = &spi_master_ctx_s;
14 |
15 | static rtos_spi_master_device_t wifi_device_ctx_s;
16 | rtos_spi_master_device_t *wifi_device_ctx = &wifi_device_ctx_s;
17 |
18 | static rtos_gpio_t gpio_ctx_t0_s;
19 | rtos_gpio_t *gpio_ctx_t0 = &gpio_ctx_t0_s;
20 |
21 | static rtos_gpio_t gpio_ctx_t1_s;
22 | rtos_gpio_t *gpio_ctx_t1 = &gpio_ctx_t1_s;
23 |
24 | static rtos_i2c_master_t i2c_master_ctx_s;
25 | rtos_i2c_master_t *i2c_master_ctx = &i2c_master_ctx_s;
26 |
27 | static rtos_uart_tx_t uart_tx_ctx_s;
28 | rtos_uart_tx_t *uart_tx_ctx = &uart_tx_ctx_s;
29 |
30 | static rtos_uart_rx_t uart_rx_ctx_s;
31 | rtos_uart_rx_t *uart_rx_ctx = &uart_rx_ctx_s;
32 |
33 | static rtos_dfu_image_t dfu_image_ctx_s;
34 | rtos_dfu_image_t *dfu_image_ctx = &dfu_image_ctx_s;
35 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/bsp_config/XCORE-AI-EXPLORER_2V0/platform/driver_instances.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DRIVER_INSTANCES_H_
5 | #define DRIVER_INSTANCES_H_
6 |
7 | #include "rtos_intertile.h"
8 | #include "rtos_i2c_master.h"
9 | #include "rtos_spi_master.h"
10 | #include "rtos_qspi_flash.h"
11 | #include "rtos_dfu_image.h"
12 | #include "rtos_gpio.h"
13 | #include "rtos_uart_tx.h"
14 | #include "rtos_uart_rx.h"
15 | #include "usb_support.h"
16 |
17 | #define FLASH_TILE_NO 0
18 | #define I2C_TILE_NO 0
19 | #define UART_TILE_NO 1
20 |
21 | /** TILE 0 Clock Blocks */
22 | #define FLASH_CLKBLK XS1_CLKBLK_1
23 | // #define UNUSED_CLKBLK XS1_CLKBLK_2
24 | #define SPI_CLKBLK XS1_CLKBLK_3
25 | #define XUD_CLKBLK_1 XS1_CLKBLK_4 /* Reserved for lib_xud */
26 | #define XUD_CLKBLK_2 XS1_CLKBLK_5 /* Reserved for lib_xud */
27 |
28 | /** TILE 1 Clock Blocks */
29 | // #define UNUSED_CLKBLK XS1_CLKBLK_1
30 | // #define UNUSED_CLKBLK XS1_CLKBLK_2
31 | // #define UNUSED_CLKBLK XS1_CLKBLK_3
32 | // #define UNUSED_CLKBLK XS1_CLKBLK_4
33 | // #define UNUSED_CLKBLK XS1_CLKBLK_5
34 |
35 | extern rtos_intertile_t *intertile_ctx;
36 | extern rtos_qspi_flash_t *qspi_flash_ctx;
37 | extern rtos_spi_master_t *spi_master_ctx;
38 | extern rtos_spi_master_device_t *wifi_device_ctx;
39 | extern rtos_gpio_t *gpio_ctx_t0;
40 | extern rtos_gpio_t *gpio_ctx_t1;
41 | extern rtos_i2c_master_t *i2c_master_ctx;
42 | extern rtos_uart_tx_t *uart_tx_ctx;
43 | extern rtos_uart_rx_t *uart_rx_ctx;
44 | extern rtos_dfu_image_t *dfu_image_ctx;
45 |
46 | #endif /* DRIVER_INSTANCES_H_ */
47 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_init.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef PLATFORM_INIT_H_
5 | #define PLATFORM_INIT_H_
6 |
7 | #include
8 |
9 | void platform_init(chanend_t other_tile_c);
10 | void platform_start(void);
11 |
12 | #endif /* PLATFORM_INIT_H_ */
13 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_start.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include
5 |
6 | #include "platform_conf.h"
7 | #include "platform/driver_instances.h"
8 |
9 | static void gpio_start(void)
10 | {
11 | rtos_gpio_rpc_config(gpio_ctx_t0, appconfGPIO_T0_RPC_PORT, appconfGPIO_RPC_PRIORITY);
12 | rtos_gpio_rpc_config(gpio_ctx_t1, appconfGPIO_T1_RPC_PORT, appconfGPIO_RPC_PRIORITY);
13 |
14 | #if ON_TILE(0)
15 | rtos_gpio_start(gpio_ctx_t0);
16 | #endif
17 | #if ON_TILE(1)
18 | rtos_gpio_start(gpio_ctx_t1);
19 | #endif
20 | }
21 |
22 | static void spi_start(void)
23 | {
24 | #if ON_TILE(0)
25 | rtos_spi_master_start(spi_master_ctx, appconfSPI_MASTER_TASK_PRIORITY);
26 | #endif
27 | }
28 |
29 | static void i2c_start(void)
30 | {
31 | rtos_i2c_master_rpc_config(i2c_master_ctx, appconfI2C_MASTER_RPC_PORT, appconfI2C_MASTER_RPC_PRIORITY);
32 | #if ON_TILE(I2C_TILE_NO)
33 | rtos_i2c_master_start(i2c_master_ctx);
34 | #endif
35 | }
36 |
37 | static void flash_start(void)
38 | {
39 | #if ON_TILE(0)
40 | uint32_t flash_core_map = ~((1 << appconfUSB_INTERRUPT_CORE) | (1 << appconfUSB_SOF_INTERRUPT_CORE));
41 | rtos_qspi_flash_start(qspi_flash_ctx, appconfQSPI_FLASH_TASK_PRIORITY);
42 | rtos_qspi_flash_op_core_affinity_set(qspi_flash_ctx, flash_core_map);
43 | #endif
44 | }
45 |
46 | static void usb_start(void)
47 | {
48 | #if ON_TILE(USB_TILE_NO)
49 | usb_manager_start(appconfUSB_MANAGER_TASK_PRIORITY);
50 | #endif
51 | }
52 |
53 | void platform_start(void)
54 | {
55 | rtos_intertile_start(intertile_ctx);
56 |
57 | gpio_start();
58 | spi_start();
59 | flash_start();
60 | i2c_start();
61 | usb_start();
62 | }
63 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/loader/loader.c:
--------------------------------------------------------------------------------
1 | // Copyright 2023 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | /* Store the version of the image in memory that will potentially be booted. */
11 | int candidateImageVersion = -1;
12 | /* Store the address of the image in memory that will potentially be booted. */
13 | unsigned candidateImageAddress = 0;
14 |
15 | /* Store the state of the buttons at init for image selection */
16 | unsigned btn_val = 0;
17 |
18 | enum interest
19 | {
20 | NOT_INTERESTED = 0,
21 | INTERESTED = 1
22 | };
23 |
24 | #define BTN_A_IS_PRESSED (((btn_val >> 0) & 0x01) == 0)
25 | #define BTN_B_IS_PRESSED (((btn_val >> 1) & 0x01) == 0)
26 |
27 | void init(void)
28 | {
29 | port_t p_btns = XS1_PORT_4D;
30 | port_enable(p_btns);
31 | btn_val = port_in(p_btns);
32 | port_disable(p_btns);
33 | }
34 |
35 | int checkCandidateImageVersion(int imageVersion)
36 | {
37 | /* Reject all images if btn A is pressed to force load factory image */
38 | if (BTN_A_IS_PRESSED)
39 | {
40 | return NOT_INTERESTED;
41 | }
42 |
43 | return INTERESTED;
44 | }
45 |
46 | void recordCandidateImage(int imageVersion, unsigned imageAddress)
47 | {
48 | candidateImageVersion = imageVersion;
49 | candidateImageAddress = imageAddress;
50 | }
51 |
52 | unsigned reportSelectedImage(void)
53 | {
54 | return candidateImageAddress;
55 | }
--------------------------------------------------------------------------------
/examples/freertos/dfu/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | /* Intertile Communication Configuration */
8 | #define appconfI2C_MASTER_RPC_PORT 10
9 | #define appconfI2C_MASTER_RPC_PRIORITY (configMAX_PRIORITIES/2)
10 |
11 | #define appconfGPIO_T0_RPC_PORT 11
12 | #define appconfGPIO_T1_RPC_PORT 12
13 | #define appconfGPIO_RPC_PRIORITY (configMAX_PRIORITIES/2)
14 |
15 | /* I/O and interrupt cores for Tile 0 */
16 | #define appconfI2C_IO_CORE 4 /* Must be kept off core 0 with the RTOS tick ISR */
17 | #define appconfI2C_INTERRUPT_CORE 0 /* Must be kept off I/O cores. */
18 | #define appconfXUD_IO_CORE 1 /* Must be kept off core 0 with the RTOS tick ISR */
19 | #define appconfUSB_INTERRUPT_CORE 3 /* Must be kept off I/O cores. Best kept off core 0 with the tick ISR. */
20 | #define appconfUSB_SOF_INTERRUPT_CORE 4 /* Must be kept off I/O cores. Best kept off cores with other ISRs. */
21 | #define appconfSPI_IO_CORE 4 /* Must be kept off core 0 with the RTOS tick ISR */
22 | #define appconfSPI_INTERRUPT_CORE 0 /* Must be kept off I/O cores. */
23 |
24 | /* I/O and interrupt cores for Tile 1 */
25 | #define appconfUART_RX_IO_CORE 3 /* Must be kept off core 0 with the RTOS tick ISR */
26 | #define appconfUART_RX_INTERRUPT_CORE 4 /* Must be kept off I/O cores. Best kept off core 0 with the tick ISR. */
27 |
28 | /* UART Configuration */
29 | #define appconfUART_BAUD_RATE 806400
30 |
31 | /* Task Priorities */
32 | #define appconfSTARTUP_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
33 | #define appconfSPI_MASTER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
34 | #define appconfQSPI_FLASH_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
35 | #define appconfUART_RX_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
36 | #define appconfUSB_MANAGER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
37 |
38 | #endif /* APP_CONF_H_ */
39 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/dfu/src/tusb_config.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef TUSB_CONFIG_H_
5 | #define TUSB_CONFIG_H_
6 |
7 | #ifdef __cplusplus
8 | extern "C" {
9 | #endif
10 |
11 | #include "app_conf.h"
12 | #include "rtos_printf.h"
13 |
14 | //--------------------------------------------------------------------
15 | // COMMON CONFIGURATION
16 | //--------------------------------------------------------------------
17 |
18 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
19 | #define CFG_TUSB_OS OPT_OS_CUSTOM
20 |
21 | #ifndef CFG_TUSB_DEBUG
22 | #define CFG_TUSB_DEBUG 0
23 | #endif
24 |
25 | #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(8)))
26 |
27 | #ifndef CFG_TUSB_DEBUG_PRINTF
28 | #ifdef rtos_printf
29 | #define CFG_TUSB_DEBUG_PRINTF rtos_printf
30 | #endif
31 | #endif
32 |
33 | //--------------------------------------------------------------------
34 | // DEVICE CONFIGURATION
35 | //--------------------------------------------------------------------
36 |
37 | #define CFG_TUD_EP_MAX 12
38 | #define CFG_TUD_TASK_QUEUE_SZ 8
39 | #define CFG_TUD_ENDPOINT0_SIZE 64
40 |
41 | #define CFG_TUD_XCORE_INTERRUPT_CORE appconfUSB_INTERRUPT_CORE
42 | #define CFG_TUD_XCORE_SOF_INTERRUPT_CORE appconfUSB_SOF_INTERRUPT_CORE
43 | #define CFG_TUD_XCORE_IO_CORE_MASK (1 << appconfXUD_IO_CORE)
44 |
45 | //------------- CLASS -------------//
46 | #define CFG_TUD_DFU 1
47 |
48 | // DFU buffer size, it has to be set to the buffer size used in TUD_DFU_DESCRIPTOR
49 | #define CFG_TUD_DFU_XFER_BUFSIZE 4096
50 |
51 | #ifdef __cplusplus
52 | }
53 | #endif
54 |
55 | #endif /* TUSB_CONFIG_H_ */
56 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/README.md:
--------------------------------------------------------------------------------
1 | # Explorer Board
2 |
3 | This example application demonstrates various capabilities of the Explorer board using FreeRTOS. The application uses I2C, I2S, SPI, UART, flash, mic array, and GPIO devices.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_explorer_board
10 | - flash_app_example_freertos_explorer_board
11 | - run_example_freertos_explorer_board
12 | - debug_example_freertos_explorer_board
13 |
14 | ## Deploying the Firmware
15 |
16 | See the Programming Guide for information on building and running the application.
17 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/filesystem_support/demo.txt:
--------------------------------------------------------------------------------
1 | Hello World!
2 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/example_pipeline/example_pipeline.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef SRC_EXAMPLE_PIPELINE_H_
5 | #define SRC_EXAMPLE_PIPELINE_H_
6 |
7 | #include "rtos_mic_array.h"
8 | #include "rtos_i2s.h"
9 | #include "xmath/xmath.h"
10 |
11 | enum {
12 | GET_GAIN_VAL = 1,
13 | SET_GAIN_VAL
14 | };
15 |
16 | void example_pipeline_init( UBaseType_t priority );
17 |
18 | BaseType_t audiopipeline_get_stage1_gain( void );
19 | BaseType_t audiopipeline_set_stage1_gain( BaseType_t xNewGain );
20 |
21 | #endif /* SRC_EXAMPLE_PIPELINE_H_ */
22 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/ff_appconf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | /*---------------------------------------------------------------------------/
4 | / Function Configurations
5 | /---------------------------------------------------------------------------*/
6 |
7 | #define FF_FS_MINIMIZE 0
8 | /* This option defines minimization level to remove some basic API functions.
9 | /
10 | / 0: Basic functions are fully enabled.
11 | / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
12 | / are removed.
13 | / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
14 | / 3: f_lseek() function is removed in addition to 2. */
15 |
16 |
17 |
18 | /*---------------------------------------------------------------------------/
19 | / System Configurations
20 | /---------------------------------------------------------------------------*/
21 |
22 | #define FF_FS_TINY 1
23 | /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
24 | / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
25 | / Instead of private sector buffer eliminated from the file object, common sector
26 | / buffer in the filesystem object (FATFS) is used for the file data transfer. */
27 |
28 |
29 | /*--- End of configuration options ---*/
30 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/filesystem/filesystem_demo.c:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 |
7 | /* FreeRTOS headers */
8 | #include "FreeRTOS.h"
9 | #include "task.h"
10 | #include "queue.h"
11 | #include "timers.h"
12 |
13 | /* Library headers */
14 |
15 | /* App headers */
16 | #include "app_conf.h"
17 | #include "platform/driver_instances.h"
18 | #include "filesystem/filesystem_demo.h"
19 | #include "fs_support.h"
20 |
21 | #define DEMO_FILEPATH "/flash/fs/demo.txt"
22 |
23 | static void filesystem_demo(void* args)
24 | {
25 | FIL test_file;
26 | FRESULT result;
27 | uint32_t demo_file_size = -1;
28 | uint32_t bytes_read = 0;
29 | uint8_t *file_contents_buf = NULL;
30 |
31 | result = f_open(&test_file, DEMO_FILEPATH, FA_READ);
32 | if (result == FR_OK)
33 | {
34 | rtos_printf("Found file %s\n", DEMO_FILEPATH);
35 | demo_file_size = f_size(&test_file);
36 |
37 | file_contents_buf = pvPortMalloc(sizeof(uint8_t)*demo_file_size);
38 | configASSERT(file_contents_buf != NULL);
39 |
40 | result = f_read(&test_file,
41 | (uint8_t*)file_contents_buf,
42 | demo_file_size,
43 | (unsigned int*)&bytes_read);
44 | configASSERT(bytes_read == demo_file_size);
45 | } else {
46 | rtos_printf("Failed to open file %s\n", DEMO_FILEPATH);
47 | }
48 | if (demo_file_size != -1)
49 | {
50 | rtos_printf("Loaded file %s\n", DEMO_FILEPATH);
51 | f_close(&test_file);
52 | }
53 |
54 | while(1)
55 | {
56 | rtos_printf("Contents of %s are:\n%s\n", DEMO_FILEPATH, file_contents_buf);
57 | vTaskDelay(pdMS_TO_TICKS(5000));
58 | }
59 | }
60 |
61 | void filesystem_demo_create( UBaseType_t priority )
62 | {
63 | xTaskCreate((TaskFunction_t) filesystem_demo,
64 | "filesystem_demo",
65 | RTOS_THREAD_STACK_SIZE(filesystem_demo),
66 | NULL,
67 | priority,
68 | NULL);
69 | }
70 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/filesystem/filesystem_demo.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef FILESYSTEM_DEMO_H_
5 | #define FILESYSTEM_DEMO_H_
6 |
7 | void filesystem_demo_create( UBaseType_t priority );
8 |
9 | #endif /* FILESYSTEM_DEMO_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/gpio_ctrl/gpio_ctrl.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef GPIO_CTRL_H_
5 | #define GPIO_CTRL_H_
6 |
7 | void gpio_ctrl_create( UBaseType_t priority );
8 |
9 | #endif /* GPIO_CTRL_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/mem_analysis/mem_analysis.c:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 |
7 | /* FreeRTOS headers */
8 | #include "FreeRTOS.h"
9 | #include "task.h"
10 |
11 | /* Library headers */
12 |
13 | /* App headers */
14 | #include "app_conf.h"
15 | #include "mem_analysis.h"
16 |
17 | static void mem_analysis( void *arg )
18 | {
19 | const char* task_name = ( const char* ) arg;
20 |
21 | if( strcmp( task_name, "heap" ) == 0 )
22 | {
23 | for( ;; )
24 | {
25 | debug_printf("\tMinimum heap free: %d\n", xPortGetMinimumEverFreeHeapSize());
26 | debug_printf("\tCurrent heap free: %d\n", xPortGetFreeHeapSize());
27 |
28 | vTaskDelay( pdMS_TO_TICKS( 1000 ) );
29 | }
30 | }
31 |
32 | int free_stack_words;
33 | TaskHandle_t task = NULL;
34 |
35 | for( ;; )
36 | {
37 | /* Always check to allow for tasks that can be deleted to be analyzed */
38 | task = xTaskGetHandle( task_name );
39 |
40 | if( task != NULL )
41 | {
42 | free_stack_words = uxTaskGetStackHighWaterMark( task );
43 | debug_printf("\t%s free stack words: %d\n", task_name, free_stack_words);
44 | }
45 | vTaskDelay( pdMS_TO_TICKS( 1000 ) );
46 | }
47 | }
48 |
49 | void mem_analysis_create( const char* task_name )
50 | {
51 | xTaskCreate( mem_analysis, "mem_an", RTOS_THREAD_STACK_SIZE(mem_analysis), ( void * ) task_name, appconfMEM_ANALYSIS_TASK_PRIORITY, NULL );
52 | }
53 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/mem_analysis/mem_analysis.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef MEM_ANALYSIS_H_
5 | #define MEM_ANALYSIS_H_
6 |
7 | void mem_analysis_create( const char* task_name );
8 |
9 | #endif /* MEM_ANALYSIS_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/explorer_board/src/uart/uart_demo.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef UART_DEMO_H_
5 | #define UART_DEMO_H_
6 |
7 | #include "FreeRTOS.h"
8 |
9 | void uart_demo_create(UBaseType_t priority);
10 | void uart_rx_pre_os_startup_init(void);
11 |
12 | #endif //UART_DEMO_H_
13 |
--------------------------------------------------------------------------------
/examples/freertos/getting_started/README.md:
--------------------------------------------------------------------------------
1 | # FreeRTOS Getting Started Example
2 |
3 | This is a simple multi-tile FreeRTOS example application. It starts the FreeRTOS scheduler running on both `tile[0]` and `tile[1]`. `tile[0]` has two tasks running. One prints "Hello from tile 0" to the console and the other task blinks the 4 LEDs on the Explorer board. `tile[1]` has one task running that prints "Hello from tile 0" to the console.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_getting_started
10 | - run_example_freertos_getting_started
11 |
12 | ## Deploying the Firmware
13 |
14 | See the Programming Guide for information on building and running the application.
15 |
--------------------------------------------------------------------------------
/examples/freertos/getting_started/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/iot/README.md:
--------------------------------------------------------------------------------
1 | # IoT
2 |
3 | This example demonstrates how to control GPIO using MQTT.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_iot
10 | - flash_app_example_freertos_iot
11 | - run_example_freertos_iot
12 |
13 | ## Deploying the Firmware
14 |
15 | See the Programming Guide for information on building and running the application.
16 |
--------------------------------------------------------------------------------
/examples/freertos/iot/filesystem_support/.gitignore:
--------------------------------------------------------------------------------
1 | # filesystem cruft
2 | mqtt_broker_certs/*
--------------------------------------------------------------------------------
/examples/freertos/iot/filesystem_support/make_certs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # Accepts an optional argument specifying the server's hostname/IP to connect to.
3 |
4 | DURATION=365
5 | OUTPUT="mqtt_broker_certs"
6 | GENERATE_SERVER_FILES=0
7 | GENERATE_CLIENT_FILES=0
8 |
9 | if [ ! -d "$OUTPUT" ]; then
10 | mkdir -p "$OUTPUT"
11 | fi
12 |
13 | # See: https://mosquitto.org/man/mosquitto-tls-7.html
14 |
15 | if [ ! -f "$OUTPUT/ca.key" ] || [ ! -f "$OUTPUT/ca.crt" ]; then
16 | GENERATE_SERVER_FILES=1
17 | GENERATE_CLIENT_FILES=1
18 |
19 | # Generate a certificate authority certificate and key
20 | openssl genrsa -out "$OUTPUT/ca.key" 2048
21 | openssl req -new -x509 -days $DURATION -key "$OUTPUT/ca.key" -out "$OUTPUT/ca.crt" -subj "/C=US/ST=NH/L=Hampton/O=XMOS/OU=Eng/CN=ca/emailAddress=null"
22 | fi
23 |
24 | if [ ! -f "$OUTPUT/server.key" ] || [ ! -f "$OUTPUT/server.crt" ] || [ $GENERATE_SERVER_FILES -eq 1 ]; then
25 | SERVERNAME=$1
26 | if [ -z "$SERVERNAME" ]; then
27 | while [ -z "$SERVERNAME" ]; do
28 | read -r -p "Enter the MQTT server's IP/hostname: " SERVERNAME
29 | done
30 | else
31 | echo "MQTT server's IP/hostname: '$SERVERNAME'"
32 | fi
33 |
34 | # Generate a server key without encryption
35 | openssl genrsa -out "$OUTPUT/server.key" 2048
36 |
37 | # Generate a certificate signing request to send to the CA
38 | openssl req -new -out "$OUTPUT/server.csr" -key "$OUTPUT/server.key" -subj "/C=US/ST=NH/L=Hampton/O=XMOS/OU=Eng/CN=$SERVERNAME/emailAddress=null"
39 |
40 | # Send the CSR to the CA, or sign it with your CA key
41 | openssl x509 -req -sha256 -in "$OUTPUT/server.csr" -CA "$OUTPUT/ca.crt" -CAkey "$OUTPUT/ca.key" -CAcreateserial -out "$OUTPUT/server.crt" -days $DURATION
42 | fi
43 |
44 | if [ ! -f "$OUTPUT/client.key" ] || [ ! -f "$OUTPUT/client.crt" ] || [ $GENERATE_CLIENT_FILES -eq 1 ]; then
45 | # Generate a client key without encryption
46 | openssl genrsa -out "$OUTPUT/client.key" 2048
47 |
48 | # Generate a certificate signing request to send to the CA
49 | openssl req -new -out "$OUTPUT/client.csr" -key "$OUTPUT/client.key" -subj "/C=US/ST=NH/L=Hampton/O=XMOS/OU=Eng/CN=explorer/emailAddress=null"
50 |
51 | # Send the CSR to the CA, or sign it with your CA key
52 | openssl x509 -req -in "$OUTPUT/client.csr" -CA "$OUTPUT/ca.crt" -CAkey "$OUTPUT/ca.key" -CAcreateserial -out "$OUTPUT/client.crt" -days $DURATION
53 | fi
54 |
--------------------------------------------------------------------------------
/examples/freertos/iot/filesystem_support/wifi_profile.ps1:
--------------------------------------------------------------------------------
1 | # Copyright 2023 XMOS LIMITED.
2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | $outFile = Join-Path -Path $PSScriptRoot -ChildPath "networks.dat"
5 | $offset = 0
6 | $maxPassLen = 32
7 | $maxSsidLen = 32
8 |
9 | # Offsets
10 | $ssidOffset = 0
11 | $ssidLenOffset = $ssidOffset + $maxSsidLen + 1
12 | $bssidOffset = $ssidLenOffset + 1
13 | $passOffset = $bssidOffset + 6
14 | $passLenOffset = $passOffset + $maxPassLen + 1
15 | $secOffset = $passLenOffset + 1
16 | $secOffset = $secOffset + ($secOffset % 4) # Apply DWORD alignment
17 |
18 | # Size of one WiFi Entry
19 | $entrySize = $secOffset + 4
20 |
21 | $enc = [System.Text.Encoding]::ASCII
22 |
23 | [byte[]]$dat = New-Object byte[] $entrySize
24 | [byte[]]$bssid = @(0,0,0,0,0,0)
25 |
26 | if (Test-Path $outFile) {
27 | Write-Output "WiFi profile ($outFile) already exists."
28 |
29 | $reconfig = Read-Host -Prompt 'Reconfigure? y/[n]'
30 |
31 | if ($reconfig.ToLower() -ne 'y') {
32 | exit 0
33 | }
34 | }
35 |
36 | while ($true) {
37 | while ($true) {
38 | $ssid = Read-Host -Prompt 'Enter the WiFi network SSID'
39 | if (($ssid.Length -gt 0) -and ($ssid.Length -le $maxSsidLen)) {
40 | break
41 | }
42 | }
43 |
44 | while ($true) {
45 | $passSecure = Read-Host -AsSecureString -Prompt 'Enter the WiFi network password'
46 | if ($passSecure.Length -le $maxSsidLen) {
47 | break
48 | }
49 | }
50 |
51 | do {
52 | $security = [Int32](Read-Host -Prompt 'Enter the security (0=open, 1=WEP, 2=WPA)')
53 | } while ($security -lt 0 || $security -gt 2)
54 |
55 | # Copy data into byte array
56 | $enc.GetBytes($ssid).CopyTo($dat, $offset + $ssidOffset)
57 | [BitConverter]::GetBytes(([byte]$ssid.Length)).CopyTo($dat, $offset + $ssidLenOffset)
58 | $bssid.CopyTo($dat, $offset + $bssidOffset)
59 | $passPlainText = ConvertFrom-SecureString $passSecure -AsPlainText
60 | $enc.GetBytes($passPlainText).CopyTo($dat, $offset + $passOffset)
61 | [BitConverter]::GetBytes([byte]$passPlainText.Length).CopyTo($dat, $offset + $passLenOffset)
62 | [BitConverter]::GetBytes($security).CopyTo($dat, $offset + $secOffset)
63 |
64 | $more = Read-Host -Prompt 'Add another WiFi network? y/[n]'
65 |
66 | if ($more.ToLower() -ne 'y') {
67 | break
68 | }
69 |
70 | $newDat = New-Object byte[] ($dat.Length + $entrySize)
71 | $dat.CopyTo($newDat, 0)
72 | $dat = $newDat
73 | $offset += $entrySize
74 | }
75 |
76 | [IO.File]::WriteAllBytes($outFile, $dat)
77 |
--------------------------------------------------------------------------------
/examples/freertos/iot/filesystem_support/wifi_profile.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright 2020-2023 XMOS LIMITED.
3 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
4 |
5 | import os
6 | import sys
7 | import getpass
8 | import struct
9 |
10 | more = "y"
11 | max_ssid_len = 32
12 | max_pass_len = 32
13 |
14 | s = bytearray()
15 | out_file = "networks.dat"
16 |
17 | if os.path.isfile(out_file):
18 | print(f"WiFi profile {out_file} already exists.")
19 | reconfig = input("Reconfigure? y/[n]: ")
20 | if reconfig.lower() != 'y':
21 | sys.exit(0)
22 |
23 | while more.lower() == "y":
24 | while True:
25 | ssid = input("Enter the WiFi network SSID: ")
26 | if len(ssid) > 0 and len(ssid) <= max_ssid_len:
27 | break
28 |
29 | while True:
30 | password = getpass.getpass("Enter the WiFi network password: ")
31 | if len(password) <= max_pass_len:
32 | break
33 |
34 | security = -1
35 | while security < 0 or security > 2:
36 | security = eval(input("Enter the security (0=open, 1=WEP, 2=WPA): "))
37 |
38 | bssid = b"\x00\x00\x00\x00\x00\x00"
39 |
40 | more = input("Add another WiFi network? y/[n]: ")
41 |
42 | s += struct.pack(
43 | "<32sxB6s32sxBxxi",
44 | bytearray(ssid, "ascii"),
45 | min(len(ssid), max_ssid_len),
46 | bssid,
47 | bytearray(password, "ascii"),
48 | min(len(password), max_pass_len),
49 | security,
50 | )
51 |
52 | file = open("networks.dat", "wb")
53 | file.write(s)
54 | file.close()
55 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | #define QSPI_RPC_PORT 14
8 | #define QSPI_RPC_HOST_TASK_PRIORITY (configMAX_PRIORITIES / 2 - 1)
9 |
10 | /* Network Setup Configuration */
11 | #define appconfSOFT_AP_SSID "xcore.ai"
12 | #define appconfSOFT_AP_PASSWORD ""
13 |
14 | /* MQTT demo defines */
15 | #define appconfMQTT_PORT 8883
16 | // If connecting to a MQTT broker on your PC, like mosquitto,
17 | // appconfMQTT_HOSTNAME will likely be your IP address
18 | #define appconfMQTT_HOSTNAME "your endpoint here"
19 | #define appconfMQTT_CLIENT_ID "explorer"
20 | #define appconfMQTT_DEMO_TOPIC "explorer/ledctrl"
21 |
22 | /* Task Priorities */
23 | #define appconfMQTT_TASK_PRIORITY (configMAX_PRIORITIES - 3)
24 | #define appconfSNTPD_TASK_PRIORITY (configMAX_PRIORITIES - 2)
25 | #define appconfSTARTUP_TASK_PRIORITY (configMAX_PRIORITIES - 1)
26 | #define appconfMEM_ANALYSIS_TASK_PRIORITY (configMAX_PRIORITIES - 1)
27 | #define appconfWIFI_SETUP_TASK_PRIORITY (configMAX_PRIORITIES / 2 - 1)
28 | #define appconfWIFI_CONN_MNGR_TASK_PRIORITY (configMAX_PRIORITIES - 3)
29 | #define appconfWIFI_DHCP_SERVER_TASK_PRIORITY (configMAX_PRIORITIES - 3)
30 | #define appconfQSPI_FLASH_TASK_PRIORITY (configMAX_PRIORITIES - 1)
31 | #define appconfSPI_TASK_PRIORITY (configMAX_PRIORITIES - 1)
32 |
33 | #endif /* APP_CONF_H_ */
34 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/ff_appconf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | /*---------------------------------------------------------------------------/
4 | / Function Configurations
5 | /---------------------------------------------------------------------------*/
6 |
7 | #define FF_FS_MINIMIZE 0
8 | /* This option defines minimization level to remove some basic API functions.
9 | /
10 | / 0: Basic functions are fully enabled.
11 | / 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
12 | / are removed.
13 | / 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
14 | / 3: f_lseek() function is removed in addition to 2. */
15 |
16 |
17 |
18 | /*---------------------------------------------------------------------------/
19 | / System Configurations
20 | /---------------------------------------------------------------------------*/
21 |
22 | #define FF_FS_TINY 1
23 | /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
24 | / At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
25 | / Instead of private sector buffer eliminated from the file object, common sector
26 | / buffer in the filesystem object (FATFS) is used for the file data transfer. */
27 |
28 |
29 | /*--- End of configuration options ---*/
30 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/mem_analysis/mem_analysis.c:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* FreeRTOS headers */
5 | #include "FreeRTOS.h"
6 | #include "task.h"
7 |
8 | /* FreeRTOS Plus headers */
9 | #include "FreeRTOS_IP.h"
10 | #include "FreeRTOS_Sockets.h"
11 |
12 | /* Library headers */
13 |
14 | /* App headers */
15 | #include "app_conf.h"
16 | #include "mem_analysis.h"
17 |
18 | static void mem_analysis( void *arg )
19 | {
20 | const char* task_name = ( const char* ) arg;
21 |
22 | if( strcmp( task_name, "heap" ) == 0 )
23 | {
24 | for( ;; )
25 | {
26 | debug_printf("\tMinimum heap free: %d\n", xPortGetMinimumEverFreeHeapSize());
27 | debug_printf("\tCurrent heap free: %d\n", xPortGetFreeHeapSize());
28 |
29 | vTaskDelay( pdMS_TO_TICKS( 1000 ) );
30 | }
31 | }
32 |
33 | int free_stack_words;
34 | TaskHandle_t task = NULL;
35 |
36 | for( ;; )
37 | {
38 | /* Always check to allow for tasks that can be deleted to be analyzed */
39 | task = xTaskGetHandle( task_name );
40 |
41 | if( task != NULL )
42 | {
43 | free_stack_words = uxTaskGetStackHighWaterMark( task );
44 | debug_printf("\t%s free stack words: %d\n", task_name, free_stack_words);
45 | }
46 | vTaskDelay( pdMS_TO_TICKS( 1000 ) );
47 | }
48 | }
49 |
50 | void mem_analysis_create( const char* task_name )
51 | {
52 | xTaskCreate( mem_analysis, "mem_an", portTASK_STACK_DEPTH(mem_analysis), ( void * ) task_name, appconfMEM_ANALYSIS_TASK_PRIORITY, NULL );
53 | }
54 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/mem_analysis/mem_analysis.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef MEM_ANALYSIS_H_
5 | #define MEM_ANALYSIS_H_
6 |
7 | void mem_analysis_create( const char* task_name );
8 |
9 | #endif /* MEM_ANALYSIS_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/mqtt_demo/mqtt_demo_client.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef MQTT_DEMO_CLIENT_H_
5 | #define MQTT_DEMO_CLIENT_H_
6 |
7 | void mqtt_demo_create( rtos_gpio_t *gpio_ctx, UBaseType_t priority );
8 |
9 | #endif /* MQTT_DEMO_CLIENT_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/network_demos/network_setup.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #ifndef NETWORK_SETUP_H_
4 | #define NETWORK_SETUP_H_
5 |
6 | /* Initalize WiFi */
7 | void wifi_start(rtos_spi_master_device_t *wifi_device_ctx, rtos_gpio_t *gpio_ctx);
8 |
9 | #endif /* NETWORK_SETUP_H_ */
10 |
--------------------------------------------------------------------------------
/examples/freertos/iot/src/xcore_trace_config.h:
--------------------------------------------------------------------------------
1 | // Copyright 2019-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef XCORE_TRACE_CONFIG_H_
5 | #define XCORE_TRACE_CONFIG_H_
6 |
7 | /* Enable trace system */
8 | #define xcoretraceconfigSYSVIEW 0
9 | #define xcoretraceconfigASCII 1
10 |
11 | /* Setup xScope trace Macros */
12 | #define xcoretraceconfigXSCOPE_TRACE_BUFFER 2000
13 | #define xcoretraceconfigXSCOPE_TRACE_RAW_BYTES 0
14 |
15 | /* Include Plus tracing */
16 | #define xcoretraceconfigENABLE_PLUS_IP_TRACES 0
17 |
18 | #endif /* XCORE_TRACE_CONFIG_H_ */
19 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/README.md:
--------------------------------------------------------------------------------
1 | # L2 Cache Example
2 |
3 | The L2 cache example demonstrates how to use the software defined L2 cache.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_l2_cache
10 | - flash_example_freertos_l2_cache_swmem
11 | - run_example_freertos_l2_cache
12 |
13 | ## Deploying the Firmware
14 |
15 | See the Programming Guide for information on building and running the application.
16 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/src/app_common.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_COMMON_H_
5 | #define APP_COMMON_H_
6 |
7 | // #include "l2_cache_config.h"
8 |
9 | #ifndef __ASSEMBLER__
10 |
11 | #include
12 | #include
13 | #include
14 |
15 | #include
16 | #include
17 |
18 | #define WORD_ALIGNED __attribute__((aligned(4)))
19 | #define DWORD_ALIGNED __attribute__((aligned(8)))
20 |
21 | #define THREAD_STACK_SIZE(thread_entry) \
22 | ({ uint32_t stack_size; \
23 | asm volatile ( "ldc %0, " #thread_entry ".nstackwords" : "=r"(stack_size) ); \
24 | stack_size; })
25 |
26 |
27 | static inline void* STACK_BASE(void * const __mem_base, size_t const __words) _XCORE_NOTHROW
28 | {
29 | int *stack_top;
30 | int *stack_buf = __mem_base;
31 | stack_top = &(stack_buf[__words - 1]);
32 | stack_top = (int *) ((uint32_t) stack_top & ~(_XCORE_STACK_ALIGN_REQUIREMENT - 1));
33 | /* Check the alignment of the calculated top of stack is correct. */
34 | assert(((uint32_t) stack_top & (_XCORE_STACK_ALIGN_REQUIREMENT - 1)) == 0UL);
35 | return stack_top;
36 | }
37 |
38 | #endif // ! __ASSEMBLER__
39 | #endif //APP_COMMON_H_
40 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/src/example_code.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef BENCHMARK_CODE_H_
5 | #define BENCHMARK_CODE_H_
6 |
7 | int unrolled_loop(void);
8 | void example_code(void);
9 |
10 | #endif // BENCHMARK_CODE_H_
11 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/src/print_info.c:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #include // for PLATFORM_REFERENCE_MHZ
5 | #include
6 | #include
7 |
8 | #include "l2_cache.h"
9 | #include "print_info.h"
10 | #include "xcore_utils.h"
11 |
12 | void print_info(uint32_t timer_ticks)
13 | {
14 | #if PRINT_TIMING_INFO
15 | #if L2_CACHE_DEBUG_FLOAT_ON
16 | // NOTE: This is invalid if L2 Cache debug is enabled, so don't print it.
17 | printf(" Timing: %0.01f us\n", timer_ticks / 100.0f);
18 | #else
19 | debug_printf(" Timing: %lu us\n", timer_ticks / 100);
20 | #endif
21 | #endif // PRINT_TIMING_INFO
22 |
23 | #if L2_CACHE_DEBUG_ON
24 | // NOTE: This info isn't collected unless L2 Cache debug is enabled.
25 | #if L2_CACHE_DEBUG_FLOAT_ON
26 | printf(" Cache Hit Rate: %0.04f\n", l2_cache_debug_hit_rate() );
27 | #else
28 | debug_printf(" Cache Hit Rate: %lu\n", l2_cache_debug_hit_rate() );
29 | #endif
30 | debug_printf(" Hit Count: %lu\n", get_hit_count() );
31 | debug_printf(" Fill Request Count: %lu\n", get_fill_request_count() );
32 |
33 | l2_cache_debug_stats_reset();
34 | #endif // L2_CACHE_DEBUG_ON
35 | }
36 |
--------------------------------------------------------------------------------
/examples/freertos/l2_cache/src/print_info.h:
--------------------------------------------------------------------------------
1 | // Copyright 2020-2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef PRINT_INFO_H_
5 | #define PRINT_INFO_H_
6 |
7 | #include
8 | #include "xcore_utils.h"
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | void print_info(uint32_t timer_ticks);
15 |
16 | #ifdef __cplusplus
17 | }
18 | #endif
19 |
20 | #endif // PRINT_INFO_H_
21 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/README.md:
--------------------------------------------------------------------------------
1 | # Tracealyzer Example
2 |
3 | This is a simple multi-tile FreeRTOS example application illustrating how to use
4 | FreeRTOS' trace functionality with Percepio's Tracealyzer.
5 |
6 | ## CMake Targets
7 |
8 | The following CMake targets are provided:
9 |
10 | - example_freertos_tracealyzer
11 | - run_xscope_to_file_example_freertos_tracealyzer
12 |
13 | ## Deploying the Firmware
14 |
15 | See the Programming Guide for information on building and running the application.
16 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/host/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.20)
2 |
3 | # Compile for x86_64 on Mac as we can't support the M1 ARM architecture yet
4 | set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE INTERNAL "")
5 |
6 | project(xscope2psf LANGUAGES C)
7 | set(TARGET_NAME xscope2psf)
8 |
9 | set(FATFS_HOST_PATH "${CMAKE_CURRENT_LIST_DIR}")
10 |
11 | # Determine OS, set up output dirs
12 | if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
13 | set(XSCOPE2PSF_INSTALL_DIR "/opt/xmos/bin")
14 | elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
15 | set(XSCOPE2PSF_INSTALL_DIR "/opt/xmos/bin")
16 | elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
17 | set(XSCOPE2PSF_INSTALL_DIR "$ENV{USERPROFILE}\\.xmos\\bin")
18 | endif()
19 |
20 | set(APP_SOURCES
21 | "${CMAKE_CURRENT_LIST_DIR}/xscope2psf.c"
22 | )
23 |
24 | set(APP_INCLUDES
25 | "$ENV{XMOS_TOOL_PATH}/include/"
26 | )
27 |
28 | find_library(XSCOPE_ENDPOINT_LIB NAMES xscope_endpoint.so xscope_endpoint.lib
29 | PATHS $ENV{XMOS_TOOL_PATH}/lib)
30 |
31 | add_executable(${TARGET_NAME})
32 |
33 | target_sources(${TARGET_NAME} PRIVATE ${APP_SOURCES})
34 | target_include_directories(${TARGET_NAME} PRIVATE ${APP_INCLUDES})
35 | target_link_libraries(${TARGET_NAME} PRIVATE ${XSCOPE_ENDPOINT_LIB})
36 | install(TARGETS ${TARGET_NAME} DESTINATION ${XSCOPE2PSF_INSTALL_DIR})
37 |
38 | if ((CMAKE_C_COMPILER_ID STREQUAL "Clang") OR (CMAKE_C_COMPILER_ID STREQUAL "AppleClang"))
39 | message(STATUS "Configuring for Clang")
40 | target_compile_options(${TARGET_NAME} PRIVATE -O2 -Wall)
41 | target_link_options(${TARGET_NAME} PRIVATE "")
42 | elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
43 | message(STATUS "Configuring for GCC")
44 | target_compile_options(${TARGET_NAME} PRIVATE -O2 -Wall)
45 | target_link_options(${TARGET_NAME} PRIVATE "")
46 | elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
47 | message(STATUS "Configuring for MSVC")
48 | target_compile_options(${TARGET_NAME} PRIVATE /W3)
49 | target_link_options(${TARGET_NAME} PRIVATE "")
50 | add_compile_definitions(_CRT_SECURE_NO_WARNINGS=1)
51 | else ()
52 | message(FATAL_ERROR "Unsupported compiler: ${CMAKE_C_COMPILER_ID}")
53 | endif()
54 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/src/trcKernelPortStreamingConfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Trace Recorder for Tracealyzer v4.6.6
3 | * Copyright 2021 Percepio AB
4 | * www.percepio.com
5 | *
6 | * SPDX-License-Identifier: Apache-2.0
7 | *
8 | * Kernel port configuration parameters for streaming mode.
9 | */
10 |
11 | #ifndef TRC_KERNEL_PORT_STREAMING_CONFIG_H
12 | #define TRC_KERNEL_PORT_STREAMING_CONFIG_H
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | /* Nothing yet */
19 |
20 | #ifdef __cplusplus
21 | }
22 | #endif
23 |
24 | #endif /* TRC_KERNEL_PORT_STREAMING_CONFIG_H */
25 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/src/trcStreamPortConfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Trace Recorder for Tracealyzer v4.6.6
3 | * Copyright 2021 Percepio AB
4 | * www.percepio.com
5 | *
6 | * SPDX-License-Identifier: Apache-2.0
7 | *
8 | * The configuration for trace streaming ("stream ports").
9 | */
10 |
11 | #ifndef TRC_STREAM_PORT_CONFIG_H
12 | #define TRC_STREAM_PORT_CONFIG_H
13 |
14 | #ifdef __cplusplus
15 | extern "C" {
16 | #endif
17 |
18 | /* This define will determine whether to use the internal buffer or not.
19 | If file writing creates additional trace events (i.e. it uses semaphores or mutexes),
20 | then the internal buffer must be enabled to avoid infinite recursion. */
21 | #define TRC_CFG_STREAM_PORT_USE_INTERNAL_BUFFER 0
22 |
23 | /**
24 | * @def TRC_CFG_INTERNAL_BUFFER_SIZE
25 | *
26 | * @brief Configures the size of the internal buffer if used.
27 | * is enabled.
28 | */
29 | #define TRC_CFG_STREAM_PORT_INTERNAL_BUFFER_SIZE 35000
30 |
31 | #ifdef __cplusplus
32 | }
33 | #endif
34 |
35 | #endif /* TRC_STREAM_PORT_CONFIG_H */
36 |
--------------------------------------------------------------------------------
/examples/freertos/tracealyzer/src/trcStreamingConfig.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Trace Recorder for Tracealyzer v4.6.6
3 | * Copyright 2021 Percepio AB
4 | * www.percepio.com
5 | *
6 | * SPDX-License-Identifier: Apache-2.0
7 | *
8 | * Configuration parameters for the trace recorder library in streaming mode.
9 | * Read more at http://percepio.com/2016/10/05/rtos-tracing/
10 | */
11 |
12 | #ifndef TRC_STREAMING_CONFIG_H
13 | #define TRC_STREAMING_CONFIG_H
14 |
15 | #ifdef __cplusplus
16 | extern "C" {
17 | #endif
18 |
19 | /**
20 | * @def TRC_CFG_ENTRY_SLOTS
21 | * @brief The maximum number of objects and symbols that can be stored. This includes:
22 | * - Task names
23 | * - Named ISRs (vTraceSetISRProperties)
24 | * - Named kernel objects (vTraceStoreKernelObjectName)
25 | * - User event channels (xTraceStringRegister)
26 | *
27 | * If this value is too small, not all symbol names will be stored and the
28 | * trace display will be affected. In that case, there will be warnings
29 | * (as User Events) from TzCtrl task, that monitors this.
30 | */
31 | #define TRC_CFG_ENTRY_SLOTS 250
32 |
33 | /**
34 | * @def TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH
35 | * @brief The maximum length of symbol names, including:
36 | * - Task names
37 | * - Named ISRs (vTraceSetISRProperties)
38 | * - Named kernel objects (vTraceStoreKernelObjectName)
39 | * - User event channel names (xTraceStringRegister)
40 | *
41 | * If longer symbol names are used, they will be truncated by the recorder,
42 | * which will affect the trace display. In that case, there will be warnings
43 | * (as User Events) from TzCtrl task, that monitors this.
44 | */
45 | #define TRC_CFG_ENTRY_SYMBOL_MAX_LENGTH 32
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 |
51 | #endif /* TRC_STREAMING_CONFIG_H */
52 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/README.md:
--------------------------------------------------------------------------------
1 | # XLINK
2 |
3 | This example application demonstrates the `AN01024 `_ application note in FreeRTOS on xcore.ai.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_xlink_both
10 |
11 | ## Deploying the Firmware
12 |
13 | See the Programming Guide for information on building and running the application.
14 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS3A)
2 | ## Create Explorer Board 2V0 target
3 | add_library(example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0 INTERFACE)
4 | target_sources(example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0
5 | INTERFACE
6 | XCORE-AI-EXPLORER_2V0/platform/driver_instances.c
7 | XCORE-AI-EXPLORER_2V0/platform/platform_init.c
8 | XCORE-AI-EXPLORER_2V0/platform/platform_start.c
9 | )
10 | target_include_directories(example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0
11 | INTERFACE
12 | XCORE-AI-EXPLORER_2V0
13 | )
14 | target_link_libraries(example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0
15 | INTERFACE
16 | core::general
17 | rtos::freertos
18 | rtos::drivers::general
19 | )
20 | target_compile_definitions(example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0
21 | INTERFACE
22 | XCOREAI_EXPLORER=1
23 | PLATFORM_SUPPORTS_TILE_0=1
24 | PLATFORM_SUPPORTS_TILE_1=1
25 | PLATFORM_SUPPORTS_TILE_2=0
26 | PLATFORM_SUPPORTS_TILE_3=0
27 | )
28 |
29 | ## Create an alias
30 | add_library(example::freertos::xlink::bsp_config::xcore_ai_explorer_2V0 ALIAS example_freertos_xlink_board_support_config_xcore_ai_explorer_2V0)
31 | endif()
32 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/driver_instances.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include "platform/driver_instances.h"
5 |
6 | static rtos_intertile_t intertile_ctx_s;
7 | rtos_intertile_t *intertile_ctx = &intertile_ctx_s;
8 |
9 | static rtos_gpio_t gpio_ctx_t0_s;
10 | rtos_gpio_t *gpio_ctx_t0 = &gpio_ctx_t0_s;
11 |
12 | static rtos_gpio_t gpio_ctx_t1_s;
13 | rtos_gpio_t *gpio_ctx_t1 = &gpio_ctx_t1_s;
14 |
15 | static rtos_i2c_master_t i2c_master_ctx_s;
16 | rtos_i2c_master_t *i2c_master_ctx = &i2c_master_ctx_s;
17 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/driver_instances.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DRIVER_INSTANCES_H_
5 | #define DRIVER_INSTANCES_H_
6 |
7 | #include "rtos_intertile.h"
8 | #include "rtos_i2c_master.h"
9 | #include "rtos_gpio.h"
10 |
11 | #define I2C_TILE_NO 0
12 |
13 | /** TILE 0 Clock Blocks */
14 | // #define UNUSED_CLKBLK XS1_CLKBLK_1
15 | // #define UNUSED_CLKBLK XS1_CLKBLK_2
16 | // #define UNUSED_CLKBLK XS1_CLKBLK_3
17 | // #define UNUSED_CLKBLK XS1_CLKBLK_4 /* Reserved for lib_xud */
18 | // #define UNUSED_CLKBLK XS1_CLKBLK_5 /* Reserved for lib_xud */
19 |
20 | /** TILE 1 Clock Blocks */
21 | // #define UNUSED_CLKBLK XS1_CLKBLK_1
22 | // #define UNUSED_CLKBLK XS1_CLKBLK_2
23 | // #define UNUSED_CLKBLK XS1_CLKBLK_3
24 | // #define UNUSED_CLKBLK XS1_CLKBLK_4
25 | // #define UNUSED_CLKBLK XS1_CLKBLK_5
26 |
27 | extern rtos_intertile_t *intertile_ctx;
28 | extern rtos_gpio_t *gpio_ctx_t0;
29 | extern rtos_gpio_t *gpio_ctx_t1;
30 | extern rtos_i2c_master_t *i2c_master_ctx;
31 |
32 | #endif /* DRIVER_INSTANCES_H_ */
33 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef PLATFORM_CONF_H_
5 | #define PLATFORM_CONF_H_
6 |
7 | /*
8 | * This file contains defaults to build a basic project targetting the
9 | * XCORE-AI-EXPLORER board. Users may create their own app_conf.h to override
10 | * any default settings.
11 | *
12 | * For a different soft tapeout design, it is recommended to create an entirely
13 | * different board support package.
14 | */
15 |
16 | #if __has_include("app_conf.h")
17 | #include "app_conf.h"
18 | #endif /* __has_include("app_conf.h") */
19 |
20 | /*****************************************/
21 | /* Intertile Communication Configuration */
22 | /*****************************************/
23 | #ifndef appconfI2C_MASTER_RPC_PORT
24 | #define appconfI2C_MASTER_RPC_PORT 10
25 | #endif /* appconfI2C_MASTER_RPC_PORT */
26 |
27 | #ifndef appconfI2C_MASTER_RPC_PRIORITY
28 | #define appconfI2C_MASTER_RPC_PRIORITY (configMAX_PRIORITIES/2)
29 | #endif /* appconfI2C_MASTER_RPC_PRIORITY */
30 |
31 | #ifndef appconfGPIO_T0_RPC_PORT
32 | #define appconfGPIO_T0_RPC_PORT 11
33 | #endif /* appconfGPIO_T0_RPC_PORT */
34 |
35 | #ifndef appconfGPIO_T1_RPC_PORT
36 | #define appconfGPIO_T1_RPC_PORT 12
37 | #endif /* appconfGPIO_T1_RPC_PORT */
38 |
39 | #ifndef appconfGPIO_RPC_PRIORITY
40 | #define appconfGPIO_RPC_PRIORITY (configMAX_PRIORITIES/2)
41 | #endif /* appconfGPIO_RPC_PRIORITY */
42 |
43 | /*****************************************/
44 | /* I/O and interrupt cores for Tile 0 */
45 | /*****************************************/
46 | #ifndef appconfI2C_IO_CORE
47 | #define appconfI2C_IO_CORE 3 /* Must be kept off core 0 with the RTOS tick ISR */
48 | #endif /* appconfI2C_IO_CORE */
49 |
50 | #ifndef appconfI2C_INTERRUPT_CORE
51 | #define appconfI2C_INTERRUPT_CORE 0 /* Must be kept off I/O cores. */
52 | #endif /* appconfI2C_INTERRUPT_CORE */
53 |
54 | /*****************************************/
55 | /* I/O and interrupt cores for Tile 1 */
56 | /*****************************************/
57 |
58 | /*****************************************/
59 | /* I/O Task Priorities */
60 | /*****************************************/
61 |
62 | #endif /* PLATFORM_CONF_H_ */
63 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_init.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include
5 |
6 | #include "platform_conf.h"
7 | #include "platform/driver_instances.h"
8 |
9 | static void gpio_init(void)
10 | {
11 | static rtos_driver_rpc_t gpio_rpc_config_t0;
12 | static rtos_driver_rpc_t gpio_rpc_config_t1;
13 | rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
14 |
15 | #if ON_TILE(0)
16 | rtos_gpio_init(gpio_ctx_t0);
17 |
18 | rtos_gpio_rpc_host_init(
19 | gpio_ctx_t0,
20 | &gpio_rpc_config_t0,
21 | client_intertile_ctx,
22 | 1);
23 |
24 | rtos_gpio_rpc_client_init(
25 | gpio_ctx_t1,
26 | &gpio_rpc_config_t1,
27 | intertile_ctx);
28 | #endif
29 |
30 | #if ON_TILE(1)
31 | rtos_gpio_init(gpio_ctx_t1);
32 |
33 | rtos_gpio_rpc_client_init(
34 | gpio_ctx_t0,
35 | &gpio_rpc_config_t0,
36 | intertile_ctx);
37 |
38 | rtos_gpio_rpc_host_init(
39 | gpio_ctx_t1,
40 | &gpio_rpc_config_t1,
41 | client_intertile_ctx,
42 | 1);
43 | #endif
44 | }
45 |
46 | static void i2c_init(void)
47 | {
48 | static rtos_driver_rpc_t i2c_rpc_config;
49 |
50 | #if ON_TILE(I2C_TILE_NO)
51 | rtos_intertile_t *client_intertile_ctx[1] = {intertile_ctx};
52 | rtos_i2c_master_init(
53 | i2c_master_ctx,
54 | PORT_I2C_SCL, 0, 0,
55 | PORT_I2C_SDA, 0, 0,
56 | 0,
57 | 100);
58 |
59 | rtos_i2c_master_rpc_host_init(
60 | i2c_master_ctx,
61 | &i2c_rpc_config,
62 | client_intertile_ctx,
63 | 1);
64 | #else
65 | rtos_i2c_master_rpc_client_init(
66 | i2c_master_ctx,
67 | &i2c_rpc_config,
68 | intertile_ctx);
69 | #endif
70 | }
71 |
72 | void platform_init(chanend_t other_tile_c)
73 | {
74 | rtos_intertile_init(intertile_ctx, other_tile_c);
75 |
76 | gpio_init();
77 | i2c_init();
78 | }
79 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_init.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef PLATFORM_INIT_H_
5 | #define PLATFORM_INIT_H_
6 |
7 | #include
8 |
9 | void platform_init(chanend_t other_tile_c);
10 | void platform_start(void);
11 |
12 | #endif /* PLATFORM_INIT_H_ */
13 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/bsp_config/XCORE-AI-EXPLORER_2V0/platform/platform_start.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #include
5 |
6 | #include "platform_conf.h"
7 | #include "platform/driver_instances.h"
8 |
9 | static void gpio_start(void)
10 | {
11 | rtos_gpio_rpc_config(gpio_ctx_t0, appconfGPIO_T0_RPC_PORT, appconfGPIO_RPC_PRIORITY);
12 | rtos_gpio_rpc_config(gpio_ctx_t1, appconfGPIO_T1_RPC_PORT, appconfGPIO_RPC_PRIORITY);
13 |
14 | #if ON_TILE(0)
15 | rtos_gpio_start(gpio_ctx_t0);
16 | #endif
17 | #if ON_TILE(1)
18 | rtos_gpio_start(gpio_ctx_t1);
19 | #endif
20 | }
21 |
22 | static void i2c_start(void)
23 | {
24 | rtos_i2c_master_rpc_config(i2c_master_ctx, appconfI2C_MASTER_RPC_PORT, appconfI2C_MASTER_RPC_PRIORITY);
25 | #if ON_TILE(I2C_TILE_NO)
26 | rtos_i2c_master_start(i2c_master_ctx);
27 | #endif
28 | }
29 |
30 | void platform_start(void)
31 | {
32 | rtos_intertile_start(intertile_ctx);
33 |
34 | gpio_start();
35 | i2c_start();
36 | }
37 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | /* XLINK Configuration */
8 | /* 0 = 2 wire; 1 = 5 wire */
9 | #define appconfXLINK_WIRE_TYPE 0
10 | #define appconfLINK_NUM 2
11 | #define appconfINTER_DELAY 2
12 | #define appconfINTRA_DELAY 3
13 |
14 |
15 | #define appconfRX_DIRECTION 0
16 | #define appconfRX_NODE_ID 0x20
17 | #define appconfRX_DEBUG_I2C_SLAVE_ADDR 0xc
18 | #define appconfRX_TIME_OUT_TICKS 500000000
19 |
20 | #define appconfTX_DIRECTION 5
21 | #define appconfRE_ENABLE_TX_PERIOD 6
22 | #define appconfSEND_CTRL_TOKEN 2500000
23 |
24 | /* Intertile Communication Configuration */
25 | #define appconfI2C_MASTER_RPC_PORT 10
26 | #define appconfI2C_MASTER_RPC_PRIORITY (configMAX_PRIORITIES/2)
27 |
28 | #define appconfGPIO_T0_RPC_PORT 11
29 | #define appconfGPIO_T1_RPC_PORT 12
30 | #define appconfGPIO_RPC_PRIORITY (configMAX_PRIORITIES/2)
31 |
32 | /* I/O and interrupt cores for Tile 0 */
33 | #define appconfI2C_IO_CORE 3 /* Must be kept off core 0 with the RTOS tick ISR */
34 | #define appconfI2C_INTERRUPT_CORE 0 /* Must be kept off I/O cores. */
35 |
36 | /* I/O and interrupt cores for Tile 1 */
37 | #define appconfXLINK_RX_IO_CORE 1 /* Must be kept off core 0 with the RTOS tick ISR */
38 | #define appconfXLINK_TX_IO_CORE 1 /* Must be kept off core 0 with the RTOS tick ISR */
39 |
40 | /* Task Priorities */
41 | #define appconfSTARTUP_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
42 | #define appconfGPIO_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )
43 | #define appconfXLINK_RX_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
44 | #define appconfXLINK_TX_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
45 |
46 | #endif /* APP_CONF_H_ */
47 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/link/link_helpers.c:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 | #include
7 | #include
8 |
9 | /* Library headers */
10 |
11 | /* App headers */
12 | #include "app_conf.h"
13 | #include "link_helpers.h"
14 | #include "platform/platform_init.h"
15 | #include "platform/driver_instances.h"
16 |
17 | #ifdef appconfXLINK_WIRE_TYPE
18 | #define W appconfXLINK_WIRE_TYPE
19 | #else
20 | /* default to 2 wire */
21 | #define W 0
22 | #endif
23 |
24 | /* Disable link by resetting ENABLE bit in link's control register */
25 | void link_disable(unsigned tileid, unsigned link_num) {
26 | unsigned x = 0;
27 | (void) read_sswitch_reg(tileid, XS1_SSWITCH_XLINK_0_NUM + link_num, &x);
28 | x &= ~XS1_XLINK_ENABLE_MASK;
29 | (void) write_sswitch_reg(tileid, XS1_SSWITCH_XLINK_0_NUM + link_num, x);
30 | }
31 |
32 | /* Configure link by performing the following in the link's control register
33 | * - Set intertoken and intratoken delays
34 | * - Set ENABLE bit
35 | * - Set WIDE bit if 5-bit link required
36 | */
37 | void link_enable(unsigned tileid, unsigned link_num) {
38 | unsigned x = 0;
39 | (void) read_sswitch_reg(tileid, XS1_SSWITCH_XLINK_0_NUM + link_num, &x);
40 | x |= XS1_XLINK_INTER_TOKEN_DELAY_SET(x, appconfINTER_DELAY);
41 | x |= XS1_XLINK_INTRA_TOKEN_DELAY_SET(x, appconfINTRA_DELAY);
42 | x |= XS1_XLINK_ENABLE_MASK;
43 | x |= W * XS1_XLINK_WIDE_MASK;
44 | (void) write_sswitch_reg(tileid, XS1_SSWITCH_XLINK_0_NUM + link_num, x);
45 | }
46 |
47 | /* Reset link by setting RESET bit in link's control register */
48 | void link_reset(unsigned tileid, unsigned link_num) {
49 | unsigned x = 0;
50 | unsigned l = XS1_SSWITCH_XLINK_0_NUM + link_num;
51 | (void) read_sswitch_reg(tileid, l, &x);
52 | x |= XS1_XLINK_RX_RESET_MASK;
53 | (void) write_sswitch_reg(tileid, l, x);
54 | }
55 |
56 | /* Send a HELLO by setting HELLO bit in link's control register */
57 | void link_hello(unsigned tileid, unsigned link_num) {
58 | unsigned x = 0;
59 | unsigned l = XS1_SSWITCH_XLINK_0_NUM + link_num;
60 | (void) read_sswitch_reg(tileid, l, &x);
61 | x |= XS1_XLINK_HELLO_MASK;
62 | (void) write_sswitch_reg(tileid, l, x);
63 | }
64 |
65 | unsigned link_got_credit(unsigned tileid, unsigned link_num) {
66 | unsigned x = 0;
67 | unsigned l = XS1_SSWITCH_XLINK_0_NUM + link_num;
68 | (void) read_sswitch_reg(tileid, l, &x);
69 | return XS1_TX_CREDIT(x);
70 | }
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/link/link_helpers.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef LINK_HELPERS_H_
5 | #define LINK_HELPERS_H_
6 |
7 | void link_disable(unsigned tileid, unsigned link_num);
8 | void link_enable(unsigned tileid, unsigned link_num);
9 | void link_reset(unsigned tileid, unsigned link_num);
10 | void link_hello(unsigned tileid, unsigned link_num);
11 | unsigned link_got_credit(unsigned tileid, unsigned link_num);
12 |
13 | #endif /* LINK_HELPERS_H_ */
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/main.c:
--------------------------------------------------------------------------------
1 | // Copyright 2019-2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | /* System headers */
5 | #include
6 | #include
7 |
8 | /* FreeRTOS headers */
9 | #include "FreeRTOS.h"
10 | #include "queue.h"
11 |
12 | /* Library headers */
13 |
14 | /* App headers */
15 | #include "app_conf.h"
16 | #include "link_helpers.h"
17 | #include "xlink_rx.h"
18 | #include "xlink_tx.h"
19 | #include "platform/platform_init.h"
20 | #include "platform/driver_instances.h"
21 |
22 | void vApplicationMallocFailedHook( void )
23 | {
24 | rtos_printf("Malloc Failed on tile %d!\n", THIS_XCORE_TILE);
25 | for(;;);
26 | }
27 |
28 | void vApplicationStackOverflowHook(TaskHandle_t pxTask, char *pcTaskName) {
29 | rtos_printf("\nStack Overflow!!! %d %s!\n", THIS_XCORE_TILE, pcTaskName);
30 | configASSERT(0);
31 | }
32 |
33 | void startup_task(void *arg)
34 | {
35 | rtos_printf("Startup task running from tile %d on core %d\n", THIS_XCORE_TILE, portGET_CORE_ID());
36 |
37 | platform_start();
38 |
39 | #if ON_TILE(1)
40 | #if DEMO_TILE == 0
41 | create_xlink_rx_tasks(appconfXLINK_RX_TASK_PRIORITY);
42 | #else
43 | create_xlink_tx_tasks(appconfXLINK_TX_TASK_PRIORITY);
44 | #endif
45 | #endif
46 |
47 | #if ON_TILE(0)
48 | /* 1s Heartbeat */
49 | const rtos_gpio_port_id_t led_port = rtos_gpio_port(PORT_LEDS);
50 | rtos_gpio_port_enable(gpio_ctx_t0, led_port);
51 | int led_status=0;
52 |
53 | for (;;) {
54 | rtos_gpio_port_out(gpio_ctx_t0, led_port, led_status);
55 | led_status ^= 1;
56 | vTaskDelay(pdMS_TO_TICKS(1000));
57 | }
58 | #else
59 | vTaskSuspend(NULL);
60 | #endif
61 | }
62 |
63 | static void tile_common_init(chanend_t c)
64 | {
65 | platform_init(c);
66 | chanend_free(c);
67 |
68 | xTaskCreate((TaskFunction_t) startup_task,
69 | "startup_task",
70 | RTOS_THREAD_STACK_SIZE(startup_task),
71 | NULL,
72 | appconfSTARTUP_TASK_PRIORITY,
73 | NULL);
74 |
75 | rtos_printf("start scheduler on tile %d\n", THIS_XCORE_TILE);
76 | vTaskStartScheduler();
77 | }
78 |
79 | #if ON_TILE(0)
80 | void main_tile0(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3) {
81 | (void)c0;
82 | (void)c2;
83 | (void)c3;
84 |
85 | tile_common_init(c1);
86 | }
87 | #endif
88 |
89 | #if ON_TILE(1)
90 | void main_tile1(chanend_t c0, chanend_t c1, chanend_t c2, chanend_t c3) {
91 | (void)c1;
92 | (void)c2;
93 | (void)c3;
94 |
95 | tile_common_init(c0);
96 | }
97 | #endif
98 |
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/xlink_rx/xlink_rx.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef XLINK_RX_H_
5 | #define XLINK_RX_H_
6 |
7 | void create_xlink_rx_tasks(unsigned priority);
8 |
9 | #endif /* XLINK_RX_H_ */
--------------------------------------------------------------------------------
/examples/freertos/xlink/src/xlink_tx/xlink_tx.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef XLINK_TX_H_
5 | #define XLINK_TX_H_
6 |
7 | void create_xlink_tx_tasks(unsigned priority);
8 |
9 | #endif /* XLINK_TX_H_ */
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/README.md:
--------------------------------------------------------------------------------
1 | # XSCOPE File I/O
2 |
3 | This example application reads a WAV file from the host over an XSCOPE server, propagates the data through multiple threads across both tiles, and then writes the output to a WAV file on the host PC, also over an XSCOPE server.
4 |
5 | ## CMake Targets
6 |
7 | The following CMake targets are provided:
8 |
9 | - example_freertos_xscope_fileio
10 | - run_example_freertos_xscope_fileio
11 |
12 | ## Deploying the Firmware
13 |
14 | See the Programming Guide for information on building and running the application.
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/in.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xmos/xcore_iot/85ecd0dcfa3c7dbf421243b63b7d83098c4e4990/examples/freertos/xscope_fileio/in.wav
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | /* Intertile port settings */
8 | #define appconfEXAMPLE_DATA_PORT 16
9 |
10 | /* Application tile specifiers */
11 | #include "platform/driver_instances.h"
12 |
13 | /* App configuration */
14 | #define appconfINPUT_FILENAME "in.wav\0"
15 | #define appconfOUTPUT_FILENAME "out.wav\0"
16 | #define appconfMAX_CHANNELS 1
17 | #define appconfFRAME_ADVANCE 240
18 | #define appconfFRAME_ELEMENT_SIZE sizeof(int32_t)
19 | #define appconfDATA_FRAME_SIZE_BYTES (appconfFRAME_ADVANCE * appconfFRAME_ELEMENT_SIZE)
20 |
21 | #define appconfAPP_NOTIFY_FILEIO_DONE 0
22 |
23 | /* Task Priorities */
24 | #define appconfSTARTUP_TASK_PRIORITY (configMAX_PRIORITIES - 2)
25 | #define appconfXSCOPE_IO_TASK_PRIORITY (configMAX_PRIORITIES - 1)
26 | #define appconfDATA_PIPELINE_TASK_PRIORITY (configMAX_PRIORITIES - 1)
27 |
28 | #endif /* APP_CONF_H_ */
29 |
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/data_pipeline/api/data_pipeline.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DATA_PIPELINE_H_
5 | #define DATA_PIPELINE_H_
6 |
7 | #include
8 | #include "app_conf.h"
9 |
10 | #define DATA_PIPELINE_DONT_FREE_FRAME 0
11 | #define DATA_PIPELINE_FREE_FRAME 1
12 |
13 | typedef struct {
14 | int32_t data[appconfFRAME_ADVANCE];
15 | } frame_data_t;
16 |
17 | void data_pipeline_init(
18 | void *input_app_data,
19 | void *output_app_data);
20 |
21 | void data_pipeline_input(
22 | void *input_app_data,
23 | int8_t **input_data_frame,
24 | size_t frame_count);
25 |
26 | int data_pipeline_output(
27 | void *output_app_data,
28 | int8_t **output_data_frame,
29 | size_t frame_count);
30 |
31 | #endif /* DATA_PIPELINE_H_ */
32 |
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/data_pipeline/src/data_pipeline_tile0.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | /* STD headers */
5 | #include
6 | #include
7 | #include
8 |
9 | /* FreeRTOS headers */
10 | #include "FreeRTOS.h"
11 | #include "task.h"
12 | #include "queue.h"
13 |
14 | /* Library headers */
15 | #include "generic_pipeline.h"
16 |
17 | /* App headers */
18 | #include "app_conf.h"
19 | #include "data_pipeline.h"
20 |
21 | #if ON_TILE(0)
22 |
23 | static void *data_pipeline_input_i(void *input_app_data)
24 | {
25 | frame_data_t *frame_data;
26 |
27 | frame_data = pvPortMalloc(sizeof(frame_data_t));
28 | memset(frame_data, 0x00, sizeof(frame_data_t));
29 |
30 | size_t bytes_received = 0;
31 | bytes_received = rtos_intertile_rx_len(
32 | intertile_ctx,
33 | appconfEXAMPLE_DATA_PORT,
34 | portMAX_DELAY);
35 |
36 | xassert(bytes_received == sizeof(frame_data_t));
37 |
38 | rtos_intertile_rx_data(
39 | intertile_ctx,
40 | frame_data,
41 | bytes_received);
42 |
43 | return frame_data;
44 | }
45 |
46 | static int data_pipeline_output_i(frame_data_t *frame_data,
47 | void *output_app_data)
48 | {
49 | return data_pipeline_output(output_app_data,
50 | (int8_t **)frame_data->data,
51 | appconfDATA_FRAME_SIZE_BYTES);
52 | }
53 |
54 | static void stage_3(frame_data_t *frame_data)
55 | {
56 | /* Do nothing */
57 | }
58 |
59 | void data_pipeline_init(
60 | void *input_app_data,
61 | void *output_app_data)
62 | {
63 | const int stage_count = 1;
64 |
65 | const pipeline_stage_t stages[] = {
66 | (pipeline_stage_t) stage_3,
67 | };
68 |
69 | const configSTACK_DEPTH_TYPE stage_stack_sizes[] = {
70 | configMINIMAL_STACK_SIZE + RTOS_THREAD_STACK_SIZE(stage_3) + RTOS_THREAD_STACK_SIZE(data_pipeline_input_i) + RTOS_THREAD_STACK_SIZE(data_pipeline_output_i),
71 | };
72 |
73 | generic_pipeline_init((pipeline_input_t)data_pipeline_input_i,
74 | (pipeline_output_t)data_pipeline_output_i,
75 | input_app_data,
76 | output_app_data,
77 | stages,
78 | (const size_t*) stage_stack_sizes,
79 | appconfDATA_PIPELINE_TASK_PRIORITY,
80 | stage_count);
81 | }
82 |
83 | #endif /* ON_TILE(0)*/
84 |
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/fileio/xscope_fileio_task.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef XSCOPE_FILEIO_TASK_H_
5 | #define XSCOPE_FILEIO_TASK_H_
6 |
7 | #include
8 |
9 | void xscope_fileio_tasks_create(unsigned priority, void* app_data);
10 |
11 | /* Signal to fileio that the application is done and files can be closed */
12 | void xscope_fileio_user_done(void);
13 |
14 | /* Send len_bytes
15 | * returns number of bytes sent */
16 | size_t xscope_fileio_tx_to_host(uint8_t *buf, size_t len_bytes);
17 |
18 | size_t xscope_fileio_rx_from_host(void *input_app_data, int8_t **input_data_frame, size_t frame_count);
19 |
20 | #endif /* XSCOPE_FILEIO_TASK_H_ */
21 |
--------------------------------------------------------------------------------
/examples/freertos/xscope_fileio/src/wav/wav_utils.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 | #ifndef WAV_UTILS_H
4 | #define WAV_UTILS_H
5 |
6 | #include
7 |
8 | #include "xscope_io_device.h"
9 |
10 | #define WAV_HEADER_BYTES 44
11 |
12 | typedef struct wav_header {
13 | // RIFF Header
14 | char riff_header[4]; // Should be "RIFF"
15 | int wav_size; // File size - 8 = data_bytes + WAV_HEADER_BYTES - 8
16 | char wave_header[4]; // Should be "WAVE"
17 |
18 | // Format Subsection
19 | char fmt_header[4]; // Should be "fmt "
20 | int fmt_chunk_size; // Size of the rest of this subchunk
21 | short audio_format;
22 | short num_channels;
23 | int sample_rate;
24 | int byte_rate; // sample_rate * num_channels * (bit_depth/8)
25 | short sample_alignment; // num_channels * (bit_depth/8)
26 | short bit_depth; // bits per sample
27 |
28 | // Data Subsection
29 | char data_header[4]; // Should be "data"
30 | int data_bytes; // frame count * num_channels * (bit_depth/8)
31 | } wav_header;
32 |
33 | int get_wav_header_details(xscope_file_t *input_file, wav_header *s, unsigned *header_size);
34 |
35 | int wav_form_header(wav_header *header,
36 | short audio_format,
37 | short num_channels,
38 | int sample_rate,
39 | short bit_depth,
40 | int num_frames);
41 |
42 | unsigned wav_get_num_bytes_per_frame(const wav_header *s);
43 |
44 | int wav_get_num_frames(const wav_header *s);
45 |
46 | long wav_get_frame_start(const wav_header *s, unsigned frame_number, uint32_t wavheader_size);
47 |
48 | #endif // WAV_UTILS_H
49 |
--------------------------------------------------------------------------------
/index.rst:
--------------------------------------------------------------------------------
1 | .. _xcore_iot_programming_guide:
2 |
3 | .. include::
4 |
5 | ###############
6 | XCORE |reg| IOT
7 | ###############
8 |
9 | This is the user guide for the `XCORE-IOT Software `_.
10 |
11 | .. toctree::
12 | :maxdepth: 1
13 |
14 | doc/programming_guide/index
15 | modules/rtos/doc/programming_guide/index
16 | modules/rtos/doc/build_system_guide/index
17 | modules/io/doc/programming_guide/index
18 | modules/io/modules/mic_array/doc/programming_guide/index.rst
19 | modules/qspi_fast_read/doc/programming_guide/index.rst
20 | modules/core/modules/xcore_math/lib_xcore_math/doc/programming_guide/index.rst
21 |
22 | *********
23 | Licensing
24 | *********
25 |
26 | This Software is subject to the terms of the `XMOS Public Licence: Version 1 `_. Copyrights and licenses for third party components can be found in :ref:`xcore_iot_copyright`.
27 |
28 | .. only:: html
29 |
30 | ******************
31 | Indices and tables
32 | ******************
33 |
34 | * :ref:`genindex`
35 |
--------------------------------------------------------------------------------
/modules/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Add frameworks
4 | if(${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS3A)
5 | ## Need to guard so host targets will not be built
6 | add_subdirectory(core)
7 | add_subdirectory(inferencing)
8 | endif()
9 |
10 | add_subdirectory(io)
11 | add_subdirectory(rtos)
12 |
13 | ## Add additional modules
14 | add_subdirectory(qspi_fast_read)
15 | add_subdirectory(sample_rate_conversion)
16 | add_subdirectory(xscope_fileio)
17 |
--------------------------------------------------------------------------------
/modules/sample_rate_conversion/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | if((${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS3A) OR (${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS2A))
3 | ## Source files
4 | file(GLOB_RECURSE LIB_C_SOURCES lib_src/lib_src/src/*.c )
5 | file(GLOB_RECURSE LIB_CXX_SOURCES lib_src/lib_src/src/*.cc)
6 | file(GLOB_RECURSE LIB_XC_SOURCES lib_src/lib_src/src/*.xc)
7 | file(GLOB_RECURSE LIB_ASM_SOURCES lib_src/lib_src/src/*.S )
8 |
9 | ## cmake doesn't recognize .S files as assembly by default
10 | set_source_files_properties(LIB_ASM_SOURCES PROPERTIES LANGUAGE ASM)
11 |
12 | ## Assume all asm is XS3A for now
13 | set(XCORE_XS3A_SOURCES ${LIB_ASM_SOURCES})
14 |
15 | ## Gather library sources
16 | set(LIB_PUBLIC_SOURCES "")
17 | set(LIB_PRIVATE_SOURCES ${LIB_C_SOURCES} ${LIB_CXX_SOURCES} ${LIB_XC_SOURCES})
18 |
19 | ## Append platform specific sources
20 | list(APPEND LIB_PRIVATE_SOURCES ${${CMAKE_SYSTEM_NAME}_SOURCES})
21 |
22 | ## Create library target
23 | add_library(lib_src STATIC)
24 | target_sources(lib_src
25 | PRIVATE
26 | ${LIB_PRIVATE_SOURCES}
27 | )
28 | target_include_directories(lib_src
29 | PUBLIC
30 | lib_src/lib_src/api
31 | lib_src/lib_src/src/fixed_factor_of_3
32 | lib_src/lib_src/src/fixed_factor_of_3/ds3
33 | lib_src/lib_src/src/fixed_factor_of_3/os3
34 | lib_src/lib_src/src/fixed_factor_of_3_voice
35 | lib_src/lib_src/src/fixed_factor_of_3_voice/ds3_voice
36 | lib_src/lib_src/src/fixed_factor_of_3_voice/us3_voice
37 | lib_src/lib_src/src/multirate_hifi
38 | lib_src/lib_src/src/multirate_hifi/asrc
39 | lib_src/lib_src/src/multirate_hifi/ssrc
40 | )
41 | target_link_libraries(lib_src
42 | PUBLIC
43 | framework_core_legacy_compat
44 | )
45 | endif()
46 |
--------------------------------------------------------------------------------
/modules/xscope_fileio/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(xscope_fileio INTERFACE)
2 |
3 | target_sources(xscope_fileio
4 | INTERFACE
5 | ${CMAKE_CURRENT_LIST_DIR}/xscope_fileio/xscope_fileio/src/xscope_io_device.c)
6 |
7 | target_include_directories(xscope_fileio
8 | INTERFACE
9 | ${CMAKE_CURRENT_LIST_DIR}/xscope_fileio/xscope_fileio
10 | ${CMAKE_CURRENT_LIST_DIR}/xscope_fileio/xscope_fileio/api)
11 |
12 | target_compile_definitions(xscope_fileio
13 | INTERFACE
14 | TEST_WAV_XSCOPE=1)
15 |
--------------------------------------------------------------------------------
/projects/eclipse/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | xcore_sdk
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 |
17 |
18 |
19 |
20 |
21 | org.eclipse.cdt.core.cnature
22 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
23 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
24 |
25 |
26 |
27 | modules
28 | 2
29 | MODULES_ROOT
30 |
31 |
32 |
33 |
34 | MODULES_ROOT
35 | $%7BREPO_ROOT%7D/modules
36 |
37 |
38 | REPO_ROOT
39 | $%7BPARENT-2-PROJECT_LOC%7D
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/projects/eclipse/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "title": "XCORE-IOT Software",
3 | "project": "xcore_iot",
4 | "version": "1.0.0"
5 | }
--------------------------------------------------------------------------------
/test/examples/README.rst:
--------------------------------------------------------------------------------
1 | #########################
2 | Example Application Tests
3 | #########################
4 |
5 | The example application tests are designed to regression test behavior for many of the example applications. These tests should be run whenever the code of an example is changed.
6 |
7 | **************
8 | Hardware Setup
9 | **************
10 |
11 | The target hardware for these tests is the XCORE-AI-EXPLORER board.
12 |
13 | *************
14 | Running Tests
15 | *************
16 |
17 | **NOTE: The example application tests are a work in progress. Expect changes here soon.**
18 |
19 | FreeRTOS Examples
20 | =================
21 |
22 | First, build all the FreeRTOS example applications.
23 |
24 | .. code-block:: console
25 |
26 | bash tools/ci/build_rtos_core_examples.sh
27 |
28 | Run the tests with the following commands:
29 |
30 | .. code-block:: console
31 |
32 | bash test/examples/run_freertos_getting_started_tests.sh
33 | bash test/examples/run_freertos_explorer_board_tests.sh
34 | bash test/examples/run_freertos_l2_cache_tests.sh
35 | bash test/examples/run_freertos_tracealyzer_tests.sh
36 |
37 |
38 | Bare-metal Examples
39 | ===================
40 |
41 | First, build all the bare-metal example applications.
42 |
43 | .. code-block:: console
44 |
45 | bash tools/ci/build_metal_examples.sh
46 |
47 | TODO: The bare-metal tests are a work in progress.
48 |
--------------------------------------------------------------------------------
/test/examples/run_freertos_explorer_board_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
6 |
7 | BUILD_DIR="${XCORE_IOT_ROOT}/dist"
8 | APPLICATION="example_freertos_explorer_board"
9 |
10 | if [ ! -z "$1" ]
11 | then
12 | ADAPTER_ID="--adapter-id $1"
13 | fi
14 |
15 | TIMEOUT_EXE=$(get_timeout)
16 | DURATION="10s"
17 |
18 | APP_XE=${BUILD_DIR}/${APPLICATION}.xe
19 | APP_FS=${BUILD_DIR}/${APPLICATION}_fat.fs
20 | APP_LOG=${APPLICATION}.log
21 |
22 | (xflash $ADAPTER_ID --force --quad-spi-clock 50MHz --factory $APP_XE --boot-partition-size 0x100000 --data $APP_FS)
23 | ($TIMEOUT_EXE $DURATION xrun $ADAPTER_ID --xscope $APP_XE 2>&1 | tee $APP_LOG)
24 |
25 | # Search the log file for strings that indicate the app ran OK
26 |
27 | # Expect one or more matches found
28 | result_hello_world=$(grep -c "Hello World!" $APP_LOG || true)
29 |
30 | if [ $result_hello_world -le 1 ]; then
31 | echo "FAIL"
32 | exit 1
33 | fi
34 |
35 | echo "PASS"
36 |
--------------------------------------------------------------------------------
/test/examples/run_freertos_getting_started_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
6 |
7 | BUILD_DIR="${XCORE_IOT_ROOT}/dist"
8 | APPLICATION="example_freertos_getting_started"
9 |
10 | if [ ! -z "$1" ]
11 | then
12 | ADAPTER_ID="--adapter-id $1"
13 | fi
14 |
15 | TIMEOUT_EXE=$(get_timeout)
16 | DURATION="10s"
17 |
18 | APP_XE=${BUILD_DIR}/${APPLICATION}.xe
19 | APP_LOG=${APPLICATION}.log
20 |
21 | ($TIMEOUT_EXE $DURATION xrun $ADAPTER_ID --xscope $APP_XE 2>&1 | tee $APP_LOG)
22 |
23 | # Search the log file for strings that indicate the app ran OK
24 |
25 | # Expect exactly one match found
26 | result_blinky_tile0=$(grep -c "Blinky task running from tile 0" $APP_LOG || true)
27 |
28 | # Expect one or more matches found
29 | result_hello_tile0=$(grep -c "Hello from tile 0" $APP_LOG || true)
30 | result_hello_tile1=$(grep -c "Hello from tile 1" $APP_LOG || true)
31 |
32 | if [ $result_hello_tile0 -le 1 ] || [ $result_hello_tile1 -le 1 ] || [ $result_blinky_tile0 -ne 1 ]; then
33 | echo "FAIL"
34 | exit 1
35 | fi
36 |
37 | echo "PASS"
38 |
--------------------------------------------------------------------------------
/test/examples/run_freertos_l2_cache_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
6 |
7 | BUILD_DIR="${XCORE_IOT_ROOT}/dist"
8 | APPLICATION="example_freertos_l2_cache"
9 |
10 | if [ ! -z "$1" ]
11 | then
12 | ADAPTER_ID="--adapter-id $1"
13 | fi
14 |
15 | TIMEOUT_EXE=$(get_timeout)
16 | DURATION="20s"
17 |
18 | APP_XE=${BUILD_DIR}/${APPLICATION}.xe
19 | APP_FLASH_CONTENTS=${BUILD_DIR}/${APPLICATION}_flash.bin
20 | APP_LOG=${APPLICATION}.log
21 |
22 | (xflash $ADAPTER_ID --force --quad-spi-clock 50MHz --write-all $APP_FLASH_CONTENTS --target XCORE-AI-EXPLORER)
23 | ($TIMEOUT_EXE -v $DURATION xrun $ADAPTER_ID --xscope $APP_XE 2>&1 | tee $APP_LOG)
24 |
25 | # Search the log file for strings that indicate the app ran OK
26 |
27 | # Expect one or more matches found
28 | result=$(grep -c "Run examples" $APP_LOG || true)
29 |
30 | if [ $result -le 1 ]; then
31 | echo "FAIL"
32 | exit 1
33 | fi
34 |
35 | echo "PASS"
36 |
--------------------------------------------------------------------------------
/test/requirements.txt:
--------------------------------------------------------------------------------
1 | matplotlib
2 | nbval
3 | numpy
4 | pytest
5 | pytest-forked
6 | pytest-xdist
--------------------------------------------------------------------------------
/test/tests.cmake:
--------------------------------------------------------------------------------
1 | if(${CMAKE_SYSTEM_NAME} STREQUAL XCORE_XS3A)
2 | include(${CMAKE_CURRENT_LIST_DIR}/usb/usb.cmake)
3 | endif()
4 |
--------------------------------------------------------------------------------
/test/usb/dfu.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | function trace_help() {
4 | echo "Options:"
5 | echo "--upgrade / -u : Create upgrade image"
6 | echo "--flash / -f : Flash factory image"
7 | return
8 | }
9 |
10 | if [ $# == 1 ]
11 | then
12 | if [ "$1" == "--help" ] || [ "$1" == "-h" ]
13 | then
14 | trace_help
15 | elif [ "$1" == "--upgrade" ] || [ "$1" == "-u" ]
16 | then
17 | xflash --factory-version 15.0 --upgrade 0 bin/usb.xe -o upgrade.bin
18 | echo "Created upgrade.bin"
19 | elif [ "$1" == "--flash" ] || [ "$1" == "-f" ]
20 | then
21 | xflash --quad-spi-clock 50MHz --factory bin/usb.xe --boot-partition-size 0x400000
22 | fi
23 | else
24 | echo "Error! --help or -h for help"
25 | fi
26 |
--------------------------------------------------------------------------------
/test/usb/src/app_conf.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021 XMOS LIMITED.
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef APP_CONF_H_
5 | #define APP_CONF_H_
6 |
7 | /* Task Priorities */
8 | #define appconfSTARTUP_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
9 | #define appconfUSB_MANAGER_TASK_PRIORITY ( configMAX_PRIORITIES - 3 )
10 | #define appconfTINYUSB_DEMO_TASK_PRIORITY ( configMAX_PRIORITIES - 6 )
11 |
12 | #endif /* APP_CONF_H_ */
13 |
--------------------------------------------------------------------------------
/test/usb/src/config.xscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/audio_test/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/cdc_dual_ports/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/cdc_msc/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/dfu/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 | #include "rtos_qspi_flash.h"
9 |
10 | typedef struct demo_args {
11 | rtos_gpio_t *gpio_ctx;
12 | rtos_qspi_flash_t *qspi_ctx;
13 | } demo_args_t;
14 |
15 | void create_tinyusb_demo(demo_args_t *ctx, unsigned priority);
16 |
17 | #endif /* DEMO_MAIN_H_ */
18 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/dfu_runtime/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 | #include "rtos_qspi_flash.h"
9 |
10 | typedef struct demo_args {
11 | rtos_gpio_t *gpio_ctx;
12 | rtos_qspi_flash_t *qspi_ctx;
13 | } demo_args_t;
14 |
15 | void create_tinyusb_demo(demo_args_t *args, unsigned priority);
16 |
17 | void set_dfu_mode(void);
18 | void set_rt_mode(void);
19 | int check_dfu_mode(void);
20 |
21 | #endif /* DEMO_MAIN_H_ */
22 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_boot_interface/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_boot_interface/src/usb_descriptors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 | * Copyright (c) 2023 XMOS LIMITED
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | #ifndef USB_DESCRIPTORS_H_
27 | #define USB_DESCRIPTORS_H_
28 |
29 | enum
30 | {
31 | ITF_NUM_KEYBOARD,
32 | ITF_NUM_MOUSE,
33 | ITF_NUM_TOTAL
34 | };
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_composite/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_composite/src/usb_descriptors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 | * Copyright (c) 2023 XMOS LIMITED
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | #ifndef USB_DESCRIPTORS_H_
27 | #define USB_DESCRIPTORS_H_
28 |
29 | enum
30 | {
31 | REPORT_ID_KEYBOARD = 1,
32 | REPORT_ID_MOUSE,
33 | REPORT_ID_CONSUMER_CONTROL,
34 | REPORT_ID_GAMEPAD,
35 | REPORT_ID_COUNT
36 | };
37 |
38 | #endif /* USB_DESCRIPTORS_H_ */
39 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_generic_inout/hid_test.py:
--------------------------------------------------------------------------------
1 | # Install python3 HID package https://pypi.org/project/hid/
2 | import hid
3 |
4 | USB_VID = 0xcafe
5 |
6 | print("Openning HID device with VID = 0x%X" % USB_VID)
7 |
8 | for dict in hid.enumerate(USB_VID):
9 | print(dict)
10 | dev = hid.Device(dict['vendor_id'], dict['product_id'])
11 | if dev:
12 | while True:
13 | # Get input from console and encode to UTF8 for array of chars.
14 | str_out = input("Send text to HID Device : ").encode('utf-8')
15 | dev.write(str_out)
16 | str_in = dev.read(64)
17 | print("Received from HID Device:", str_in, '\n')
18 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_generic_inout/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/hid_multiple_interface/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/midi_test/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/msc_dual_lun/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/uac2_headset/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/usbtmc/demo.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 |
3 | import usb.core
4 | import usb.util
5 | import usbtmc
6 | import time
7 | import sys
8 |
9 | idVendor = 0xcafe
10 | idProduct = 0x4000
11 |
12 | print("Get instrument")
13 | inst = usbtmc.Instrument(idVendor, idProduct)
14 |
15 | print("Open instrument")
16 | inst.open()
17 | inst.timeout = 3
18 |
19 | inst.clear()
20 |
21 | print("Test idn")
22 | idn = inst.ask("*idn?");
23 | print("Got: {0}".format(idn))
24 | assert (idn == "TinyUSB,ModelNumber,SerialNumber,FirmwareVer123456")
25 | assert (inst.is_usb488)
26 |
27 | print("Test echo")
28 | longstr = "0123456789" * 10
29 | for i in range(1,len(longstr)):
30 | x = longstr[0:i]
31 | y = inst.ask(x)
32 | print("Test len of {0}".format(i))
33 | assert(x == y), f"failed i={i}"
34 |
35 | print("Tests complete")
36 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/usbtmc/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 | void led_indicator_pulse(void);
11 |
12 | #endif /* DEMO_MAIN_H_ */
13 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/usbtmc/src/tusb_config.h:
--------------------------------------------------------------------------------
1 | /*
2 | * tusb_config.h
3 | *
4 | * Created on: Sep 5, 2019
5 | * Author: nconrad
6 | */
7 |
8 | #ifndef TUSB_CONFIG_H_
9 | #define TUSB_CONFIG_H_
10 |
11 | #ifdef __cplusplus
12 | extern "C" {
13 | #endif
14 |
15 | //--------------------------------------------------------------------
16 | // COMMON CONFIGURATION
17 | //--------------------------------------------------------------------
18 |
19 | // defined by board.mk
20 | #ifndef CFG_TUSB_MCU
21 | #error CFG_TUSB_MCU must be defined
22 | #endif
23 |
24 | // RHPort number used for device can be defined by board.mk, default to port 0
25 | #ifndef BOARD_DEVICE_RHPORT_NUM
26 | #define BOARD_DEVICE_RHPORT_NUM 0
27 | #endif
28 |
29 | // RHPort max operational speed can defined by board.mk
30 | // Default to max (auto) speed for MCU with internal HighSpeed PHY
31 | #ifndef BOARD_DEVICE_RHPORT_SPEED
32 | #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_DEFAULT_SPEED
33 | #endif
34 |
35 | // Device mode with rhport and speed defined by board.mk
36 | #if BOARD_DEVICE_RHPORT_NUM == 0
37 | #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
38 | #elif BOARD_DEVICE_RHPORT_NUM == 1
39 | #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
40 | #else
41 | #error "Incorrect RHPort configuration"
42 | #endif
43 |
44 | #ifndef CFG_TUSB_OS
45 | #define CFG_TUSB_OS OPT_OS_NONE
46 | #endif
47 |
48 | // CFG_TUSB_DEBUG is defined by compiler in DEBUG build
49 | // #define CFG_TUSB_DEBUG 0
50 |
51 | /* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
52 | * Tinyusb use follows macros to declare transferring memory so that they can be put
53 | * into those specific section.
54 | * e.g
55 | * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
56 | * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
57 | */
58 | #ifndef CFG_TUSB_MEM_SECTION
59 | #define CFG_TUSB_MEM_SECTION
60 | #endif
61 |
62 | #ifndef CFG_TUSB_MEM_ALIGN
63 | #define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
64 | #endif
65 |
66 | //--------------------------------------------------------------------
67 | // DEVICE CONFIGURATION
68 | //--------------------------------------------------------------------
69 |
70 | #ifndef CFG_TUD_ENDPOINT0_SIZE
71 | #define CFG_TUD_ENDPOINT0_SIZE 64
72 | #endif
73 |
74 | //------------- CLASS -------------//
75 |
76 | #define CFG_TUD_USBTMC 1
77 | #define CFG_TUD_USBTMC_ENABLE_INT_EP 1
78 | #define CFG_TUD_USBTMC_ENABLE_488 1
79 |
80 | #ifdef __cplusplus
81 | }
82 | #endif
83 |
84 | #endif /* TUSB_CONFIG_H_ */
85 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/usbtmc/src/usbtmc_app.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef USBTMC_APP_H
3 | #define USBTMC_APP_H
4 |
5 | void usbtmc_app_task_iter(void);
6 |
7 | #endif
8 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/video_capture/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/webusb_serial/src/demo_main.h:
--------------------------------------------------------------------------------
1 | // Copyright 2021-2022 XMOS LIMITED. This Software is subject to the terms of the
2 | // XMOS Public License: Version 1
3 |
4 | #ifndef DEMO_MAIN_H_
5 | #define DEMO_MAIN_H_
6 |
7 | #include "rtos_gpio.h"
8 |
9 | void create_tinyusb_demo(rtos_gpio_t *ctx, unsigned priority);
10 |
11 | #endif /* DEMO_MAIN_H_ */
12 |
--------------------------------------------------------------------------------
/test/usb/tinyusb_demos/webusb_serial/src/usb_descriptors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2019 Ha Thach (tinyusb.org)
5 | * Copyright (c) 2023 XMOS LIMITED
6 | *
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy
8 | * of this software and associated documentation files (the "Software"), to deal
9 | * in the Software without restriction, including without limitation the rights
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | * copies of the Software, and to permit persons to whom the Software is
12 | * furnished to do so, subject to the following conditions:
13 | *
14 | * The above copyright notice and this permission notice shall be included in
15 | * all copies or substantial portions of the Software.
16 | *
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | * THE SOFTWARE.
24 | */
25 |
26 | #ifndef USB_DESCRIPTORS_H_
27 | #define USB_DESCRIPTORS_H_
28 |
29 | enum
30 | {
31 | VENDOR_REQUEST_WEBUSB = 1,
32 | VENDOR_REQUEST_MICROSOFT = 2
33 | };
34 |
35 | extern uint8_t const desc_ms_os_20[];
36 |
37 | #endif /* USB_DESCRIPTORS_H_ */
38 |
--------------------------------------------------------------------------------
/test/verify_python_install.py:
--------------------------------------------------------------------------------
1 | # Copyright 2021 XMOS LIMITED.
2 | # This Software is subject to the terms of the XMOS Public Licence: Version 1.
3 |
4 | # importing several requirements to verify the install
5 |
6 | import numpy
7 | import matplotlib
8 |
--------------------------------------------------------------------------------
/tools/ci/build_host_apps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 |
6 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
7 |
8 | # setup distribution folder
9 | DIST_DIR=${XCORE_IOT_ROOT}/dist_host
10 | mkdir -p ${DIST_DIR}
11 |
12 | # row format is: "target copy_path"
13 | applications=(
14 | "example_freertos_device_control_host examples/freertos/device_control/host"
15 | "fatfs_mkimage modules/rtos/tools/fatfs_mkimage"
16 | "datapartition_mkimage modules/rtos/tools/datapartition_mkimage"
17 | "xscope_host_endpoint modules/xscope_fileio/xscope_fileio/host"
18 | "xscope2psf examples/freertos/tracealyzer/host"
19 | )
20 |
21 | # perform builds
22 | path="${XCORE_IOT_ROOT}"
23 | echo '******************************************************'
24 | echo '* Building host applications'
25 | echo '******************************************************'
26 |
27 | (cd ${path}; rm -rf build_host)
28 | (cd ${path}; mkdir -p build_host)
29 | (cd ${path}/build_host; log_errors cmake ../)
30 |
31 | for ((i = 0; i < ${#applications[@]}; i += 1)); do
32 | read -ra FIELDS <<< ${applications[i]}
33 | target="${FIELDS[0]}"
34 | copy_path="${FIELDS[1]}"
35 | (cd ${path}/build_host; log_errors make ${target} -j)
36 | (cd ${path}/build_host; cp ${copy_path}/${target} ${DIST_DIR})
37 | done
38 |
--------------------------------------------------------------------------------
/tools/ci/build_metal_examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 |
6 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
7 |
8 | # setup distribution folder
9 | DIST_DIR=${XCORE_IOT_ROOT}/dist
10 | mkdir -p ${DIST_DIR}
11 |
12 | # row format is: "app_target board toolchain"
13 | applications=(
14 | "example_bare_metal_explorer_board XCORE-AI-EXPLORER xmos_cmake_toolchain/xs3a.cmake"
15 | "example_bare_metal_vww XCORE-AI-EXPLORER xmos_cmake_toolchain/xs3a.cmake"
16 | )
17 |
18 | # perform builds
19 | for ((i = 0; i < ${#applications[@]}; i += 1)); do
20 | read -ra FIELDS <<< ${applications[i]}
21 | make_target="${FIELDS[0]}"
22 | board="${FIELDS[1]}"
23 | toolchain_file="${XCORE_IOT_ROOT}/${FIELDS[2]}"
24 | path="${XCORE_IOT_ROOT}"
25 | echo '******************************************************'
26 | echo '* Building' ${make_target} 'for' ${board}
27 | echo '******************************************************'
28 |
29 | (cd ${path}; rm -rf build_${board})
30 | (cd ${path}; mkdir -p build_${board})
31 | (cd ${path}/build_${board}; log_errors cmake ../ -DCMAKE_TOOLCHAIN_FILE=${toolchain_file} -DBOARD=${board}; log_errors make install_${make_target} -j)
32 | done
33 |
--------------------------------------------------------------------------------
/tools/ci/build_rtos_aiot_examples.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | XCORE_IOT_ROOT=`git rev-parse --show-toplevel`
5 | source ${XCORE_IOT_ROOT}/tools/ci/helper_functions.sh
6 |
7 | # setup distribution folder
8 | DIST_DIR=${XCORE_IOT_ROOT}/dist
9 | DIST_HOST_DIR=${XCORE_IOT_ROOT}/dist_host
10 | mkdir -p ${DIST_DIR}
11 |
12 | if [ -d "${DIST_HOST_DIR}" ]; then
13 | # add DIST_HOST_DIR to path.
14 | # This is used in CI for fatfs_mkimage
15 | PATH="${DIST_HOST_DIR}":$PATH
16 | find ${DIST_HOST_DIR} -type f -exec chmod a+x {} +
17 | fi
18 |
19 | # row format is: "name app_target run_fs_target run_swmem_target board toolchain"
20 | applications=(
21 | "example_freertos_iot No No XCORE-AI-EXPLORER xmos_cmake_toolchain/xs3a.cmake"
22 | )
23 |
24 | # perform builds
25 | for ((i = 0; i < ${#applications[@]}; i += 1)); do
26 | read -ra FIELDS <<< ${applications[i]}
27 | app_target="${FIELDS[0]}"
28 | run_fs_target="${FIELDS[1]}"
29 | run_swmem_target="${FIELDS[2]}"
30 | board="${FIELDS[3]}"
31 | toolchain_file="${XCORE_IOT_ROOT}/${FIELDS[4]}"
32 | path="${XCORE_IOT_ROOT}"
33 | echo '******************************************************'
34 | echo '* Building' ${app_target} 'for' ${board}
35 | echo '******************************************************'
36 |
37 | (cd ${path}; rm -rf build_${board})
38 | (cd ${path}; mkdir -p build_${board})
39 | (cd ${path}/build_${board}; log_errors cmake ../ -DCMAKE_TOOLCHAIN_FILE=${toolchain_file} -DBOARD=${board}; log_errors make install_${app_target} -j)
40 | if [ "$run_fs_target" = "Yes" ]; then
41 | echo '======================================================'
42 | echo '= Making filesystem for' ${app_target}
43 | echo '======================================================'
44 | (cd ${path}/build_${board}; log_errors make make_fs_${app_target} -j)
45 | (cd ${path}/build_${board}; cp ${app_target}_fat.fs ${DIST_DIR})
46 | fi
47 | if [ "$run_swmem_target" = "Yes" ]; then
48 | echo '======================================================'
49 | echo '= Making swmem for' ${app_target}
50 | echo '======================================================'
51 | (cd ${path}/build_${board}; log_errors make make_swmem_${app_target} -j)
52 | (cd ${path}/build_${board}; cp ${app_target}.swmem ${DIST_DIR})
53 | fi
54 | done
55 |
--------------------------------------------------------------------------------
/tools/ci/build_xmath_walkthrough_pdf.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | set -x
4 |
5 | XCORE_VOICE_ROOT=`git rev-parse --show-toplevel`
6 |
7 | source tools/ci/helper_functions.sh
8 |
9 | # setup distribution folder
10 | DIST_DIR=${XCORE_VOICE_ROOT}/dist_pdfs
11 | mkdir -p ${DIST_DIR}
12 |
13 | # set doc_builder version
14 | DOC_BUILDER=ghcr.io/xmos/doc_builder:v3.0.0
15 |
16 | echo '******************************************************'
17 | echo '* Building PDFs for xmath_walkthrough'
18 | echo '******************************************************'
19 | # xmath_walkthrough is non standard because it is a stand-alone project that we redistribute with the xcore_iot project
20 | full_path="${XCORE_VOICE_ROOT}/xmath_walkthrough"
21 | # build docs
22 | (cd ${full_path}; docker run --rm -t -u "$(id -u):$(id -g)" -v $(pwd):/build -e PDF=1 -e SKIP_LINK=1 -e REPO:/build ${DOC_BUILDER})
23 | # copy to dist folder
24 | (cd ${full_path}/doc/_build/pdf; cp tutorial.pdf ${DIST_DIR}/xmath_walkthrough_tutorial.pdf)
25 |
--------------------------------------------------------------------------------
/tools/ci/build_xmath_walkthrough_zip.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | set -x
4 |
5 | # make zip archive
6 | zip -r --symlinks xmath_walkthrough.zip xmath_walkthrough
7 |
--------------------------------------------------------------------------------
/tools/ci/clean_xmath_walkthrough.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | set -x
4 |
5 | rm -rf xmath_walkthrough
6 | rm -rf .west
7 |
--------------------------------------------------------------------------------
/tools/ci/fetch_xmath_walkthrough.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 | set -x
4 |
5 | # get the repo and dependencies
6 | west init -m https://github.com/xmos/xmath_walkthrough/
7 | west update
8 |
--------------------------------------------------------------------------------
/tools/ci/helper_functions.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Collection of helper functions that can be used in the different continuous
4 | # integration scripts.
5 |
6 | # A small utility to run a command and only print logs if the command fails.
7 | # On success, all logs are hidden.
8 | function log_errors {
9 | if log=$("$@" 2>&1); then
10 | echo "'$@' completed successfully!"
11 | else
12 | echo "$log"
13 | return 1
14 | fi
15 | }
16 |
17 | # Get the system timeout command
18 | function get_timeout {
19 | uname=`uname`
20 | if [[ "$uname" == 'Linux' ]]; then
21 | echo "timeout"
22 | elif [[ "$uname" == 'Darwin' ]]; then
23 | echo "gtimeout"
24 | fi
25 | }
26 |
27 | function check_tools_version {
28 | # Get required version fields
29 | IFS='.' read -ra FIELDS <<< "$@"
30 | MIN_VERSION_MAJOR=${FIELDS[0]}
31 | MIN_VERSION_MINOR=${FIELDS[1]}
32 | MIN_VERSION_PATCH=${FIELDS[2]}
33 | # Run xcc --version
34 | xcc_version_output_string=`cat "$XMOS_TOOL_PATH"/doc/version.txt`
35 | # Find the semantic version substring
36 | prefix=${xcc_version_output_string%%" "*}
37 | space_position=${#prefix}
38 | xcc_semver_substring=`echo $xcc_version_output_string | cut -c1-$space_position`
39 | # Split semver substring into fields
40 | IFS='.' read -ra FIELDS <<< "$xcc_semver_substring"
41 | XTC_VERSION_MAJOR=${FIELDS[0]}
42 | XTC_VERSION_MINOR=${FIELDS[1]}
43 | XTC_VERSION_PATCH=${FIELDS[2]}
44 | # Check version
45 | if [ "$XTC_VERSION_MAJOR" -lt "$MIN_VERSION_MAJOR" ]
46 | then
47 | return 1
48 | else
49 | if [ "$XTC_VERSION_MINOR" -lt "$MIN_VERSION_MINOR" ]
50 | then
51 | return 1
52 | else
53 | if [ "$XTC_VERSION_PATCH" -lt "$MIN_VERSION_PATCH" ]
54 | then
55 | return 1
56 | fi
57 | fi
58 | fi
59 | }
60 |
--------------------------------------------------------------------------------
/tools/ci/run_submodule_report.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | git submodule foreach --quiet 'echo $name `git describe --all --contains --always`'
5 |
6 |
--------------------------------------------------------------------------------
/tools/install/requirements.txt:
--------------------------------------------------------------------------------
1 | matplotlib
2 | numpy
3 | Pillow
4 |
--------------------------------------------------------------------------------