├── .github └── workflows │ ├── before_install.sh │ ├── build.yml │ └── script.sh ├── .gitignore ├── LICENSE ├── README.md ├── doc ├── Makefile └── documents │ ├── _static │ ├── style_overrides.css │ └── synopsys_wht.png │ ├── appendix │ └── appendix.rst │ ├── conf.py │ ├── getting_started │ └── getting_started.rst │ ├── glossary.rst │ ├── img │ ├── dsp_figure_1.1.png │ ├── dsp_figure_1.2.png │ ├── dsp_figure_1.3.png │ ├── dsp_figure_2.1.png │ ├── dsp_figure_2.2.png │ ├── dsp_icon_2.1.png │ ├── dsp_icon_2.2.png │ ├── dsp_icon_2.3.png │ ├── dsp_icon_2.4.png │ ├── dsp_icon_3.1.png │ ├── dsp_icon_3.2.png │ ├── lab10.2_figure1.png │ ├── lab10.2_figure2.png │ ├── lab10.2_figure3.png │ ├── lab10.2_figure4.png │ ├── lab11_builds_1.png │ ├── lab11_builds_2.png │ ├── lab11_builds_3.png │ ├── lab11_emsk_connections.png │ ├── lab11_smarthome_system.png │ ├── lab11_steps_1.png │ ├── lab11_steps_10.png │ ├── lab11_steps_2.png │ ├── lab11_steps_3.png │ ├── lab11_steps_4.png │ ├── lab11_steps_5.png │ ├── lab11_steps_6.png │ ├── lab11_steps_7.png │ ├── lab11_steps_8.png │ ├── lab11_steps_9.png │ ├── lab1_figure1.png │ ├── lab1_figure10.png │ ├── lab1_figure11.png │ ├── lab1_figure12.png │ ├── lab1_figure13.png │ ├── lab1_figure14.png │ ├── lab1_figure15.png │ ├── lab1_figure16.png │ ├── lab1_figure17.png │ ├── lab1_figure18.png │ ├── lab1_figure2.png │ ├── lab1_figure3.png │ ├── lab1_figure4.png │ ├── lab1_figure5.png │ ├── lab1_figure6.png │ ├── lab1_figure7.png │ ├── lab1_figure8.png │ ├── lab1_figure9.png │ ├── lab1_icon1.png │ ├── lab1_icon10.png │ ├── lab1_icon11.png │ ├── lab1_icon12.png │ ├── lab1_icon13.png │ ├── lab1_icon14.png │ ├── lab1_icon15.png │ ├── lab1_icon16.png │ ├── lab1_icon17.png │ ├── lab1_icon18.png │ ├── lab1_icon19.png │ ├── lab1_icon2.png │ ├── lab1_icon20.png │ ├── lab1_icon21.png │ ├── lab1_icon3.png │ ├── lab1_icon4.png │ ├── lab1_icon5.png │ ├── lab1_icon6.png │ ├── lab1_icon7.png │ ├── lab1_icon8.png │ ├── lab1_icon9.png │ ├── lab3_debug_view_1.png │ ├── lab3_debug_view_2.png │ ├── lab3_program_flow_chart.png │ ├── lab3_register_TIMER_BUILD.png │ ├── lab5_emsk.png │ ├── lab5_iotdk_pin_connect.png │ ├── lab6_emsk_boot.png │ ├── lab6_emsk_bootloader_onspiflash.jpg │ ├── lab6_emsk_bootloader_program2spiflash.jpg │ ├── lab6_iotdk_bootloader_bootjson.jpg │ ├── lab6_iotdk_bootloader_onspiflash.jpg │ ├── lab6_iotdk_bootloader_program2spiflash.jpg │ ├── lab7_figure1.png │ ├── lab7_figure2.png │ ├── lab7_figure3.png │ ├── lab7_figure4.png │ ├── lab7_figure5.png │ ├── lab7_figure6.png │ ├── lab8_figure1.png │ ├── lab8_figure2.png │ ├── lab8_figure3.png │ ├── lab9_program_flow_chart.png │ ├── mwdt_1.png │ ├── mwdt_2.png │ ├── mwdt_3.png │ ├── mwdt_4.png │ └── mwdt_5.png │ ├── index.rst │ ├── introduction │ └── introduction.rst │ └── labs │ ├── labs.rst │ ├── level1.rst │ ├── level1 │ ├── lab1.rst │ ├── lab2.rst │ ├── lab3.rst │ ├── lab4.rst │ ├── lab5.rst │ └── lab6.rst │ ├── level2.rst │ ├── level2 │ ├── lab10.rst │ ├── lab7.rst │ ├── lab8.rst │ ├── lab9.rst │ ├── lab_dsp1.rst │ ├── lab_dsp2.rst │ └── lab_dsp3.rst │ ├── level3.rst │ └── level3 │ └── lab11.rst └── labs ├── dsp_lab1_compiler_opt ├── main.c └── makefile ├── dsp_lab2_fxapi ├── main.c ├── main.c.fxapi └── makefile ├── dsp_lab3_dsp_lib ├── dsp_matrix_mul.c ├── main.c ├── main.c.dsplib.c └── makefile ├── lab10_temp_monitor ├── esp8266_wifi │ ├── FreeRTOSConfig.h │ ├── README.rst │ ├── at_parser.c │ ├── at_parser.h │ ├── esp8266.c │ ├── esp8266.h │ ├── main.c │ └── makefile └── pmwifi │ ├── FreeRTOSConfig.h │ ├── lwipopts.h │ ├── main.c │ └── makefile ├── lab1_core_test └── CoreTest.c ├── lab3_timer ├── makefile └── timer.c ├── lab4_interrupt ├── part1 │ ├── main.c │ └── makefile └── part2 │ ├── main.c │ └── makefile ├── lab5_emsk ├── main.c └── makefile ├── lab5_iotdk ├── main.c └── makefile ├── lab6_ble_rn4020 ├── main.c └── makefile ├── lab7_ble_hm10 ├── main.c └── makefile ├── lab7_ble_rn4020 ├── main.c └── makefile ├── lab8_linker ├── link.cmd └── main.c ├── lab9_freertos ├── FreeRTOSConfig.h ├── main.c └── makefile └── testcase.yaml /.github/workflows/before_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | die() { 4 | echo " *** ERROR: " $* 5 | exit 1 6 | } 7 | 8 | #set -x 9 | 10 | 11 | [ "$TRAVIS_OS_NAME" != "linux" ] || { 12 | if [ "$STATUS" != "" ] && [ "$NAME" != "" ] ; then 13 | bash -c "$STATUS" pending "Local $NAME testing is in progress" || \ 14 | die "Not able to post status to github, did you set EMBARC_BOT variable in travis ci setting page" 15 | fi 16 | sudo apt-get update || die "Failed to update software" 17 | sudo apt-get install lib32z1 || die 18 | sudo apt-get install dos2unix || die 19 | sudo apt-get install doxygen || die 20 | 21 | if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ] ; then 22 | # only install texlive on non pull request master branch 23 | sudo apt-get install texlive-full || die "Failed to install texlive-full" 24 | fi 25 | pip install --upgrade pip || die "Failed to upgrade pip" 26 | pip install Sphinx || die "Failed to install Sphinx" 27 | pip install breathe || die "Failed to install breathe" 28 | pip install recommonmark || die "Failed to install recommonmark" 29 | pip install sphinx_rtd_theme || die "Failed to install sphinx_rtd_theme" 30 | pip install PrettyTable || die 31 | pip install colorama || die 32 | pip install configparser || die 33 | pip install requests || die 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | env: 4 | GIT_AUTHOR_NAME: svc-arcoss_auto arc 5 | GIT_COMMITTER_NAME: svc-arcoss_auto arc 6 | GIT_AUTHOR_EMAIL: svc-arcoss_auto@synopsys.com 7 | GIT_COMMITTER_EMAIL: svc-arcoss_auto@synopsys.com 8 | TOOLCHAIN: gnu 9 | TOOLCHAIN_VER: 2020.09 10 | on: 11 | push: 12 | branches: 13 | - master 14 | - jingru-github-ci-flow 15 | 16 | jobs: 17 | example-build-on-iotdk: 18 | name: "Build arc_labs tests on iotdk" 19 | runs-on: ubuntu-latest 20 | env: 21 | BOARD: iotdk 22 | 23 | steps: 24 | - name: checkout 25 | uses: actions/checkout@v2 26 | with: 27 | submodules: true 28 | - name: checkout-embarc_osp 29 | uses: actions/checkout@v2 30 | with: 31 | repository: foss-for-synopsys-dwc-arc-processors/embarc_osp 32 | path: 'embarc_osp' 33 | ref: scripts-allow-insert-tests 34 | submodules: true 35 | 36 | - name: install-dependencies 37 | run: | 38 | bash ./embarc_osp/scripts/.ci/before_install.sh 39 | 40 | - name: build 41 | run: | 42 | bash .github/workflows/script.sh 43 | 44 | example-build-on-nsim: 45 | name: "Build arc_labs tests on nsim" 46 | runs-on: ubuntu-latest 47 | env: 48 | BOARD: nsim 49 | 50 | steps: 51 | - name: checkout 52 | uses: actions/checkout@v2 53 | with: 54 | submodules: true 55 | - name: checkout-embarc_osp 56 | uses: actions/checkout@v2 57 | with: 58 | repository: foss-for-synopsys-dwc-arc-processors/embarc_osp 59 | path: 'embarc_osp' 60 | ref: scripts-allow-insert-tests 61 | submodules: true 62 | 63 | - name: install-dependencies 64 | run: | 65 | bash ./embarc_osp/scripts/.ci/before_install.sh 66 | 67 | - name: build 68 | run: | 69 | bash .github/workflows/script.sh -------------------------------------------------------------------------------- /.github/workflows/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -eux 2 | 3 | readonly _DIR="$(readlink -e $(dirname $(readlink -e $0)))" 4 | 5 | die() { 6 | echo " *** ERROR: " $* 7 | exit 1 8 | } 9 | 10 | prepare_env() { 11 | out_dir="${_DIR}/out" 12 | logs_dir="${_DIR}/logs" 13 | test_log="$logs_dir/test.log" 14 | 15 | mkdir -p $logs_dir $out_dir 16 | : >$test_log 17 | 18 | TOOLCHAIN_CACHE_FOLDER=".cache/toolchain" 19 | 20 | [ "${TRAVIS}" == "true" || "${GITHUB_ACTIONS}" == "true" ] && { 21 | if [ "${TOOLCHAIN}" == "gnu" ] ; then 22 | python scripts/.ci/toolchain.py -v $TOOLCHAIN_VER -c $TOOLCHAIN_CACHE_FOLDER || die 23 | if [ -d $TOOLCHAIN_CACHE_FOLDER ] ; then 24 | if [ -d $TOOLCHAIN_CACHE_FOLDER/$TOOLCHAIN_VER ] ; then 25 | ARC_DEV_TOOL_ROOT="${TOOLCHAIN_CACHE_FOLDER}/${TOOLCHAIN_VER}" 26 | fi 27 | fi 28 | else 29 | die "Toolchain ${TOOLCHAIN} not supported in travis ci" 30 | fi 31 | } 32 | 33 | if [ -d $ARC_DEV_TOOL_ROOT ] ; then 34 | REAL_ARC_DEV_ROOT=$(readlink -f ${ARC_DEV_TOOL_ROOT}) 35 | export ARC_GNU_ROOT=${REAL_ARC_DEV_ROOT} 36 | export PATH=${REAL_ARC_DEV_ROOT}/bin:${PATH} 37 | arc-elf32-gcc -v || die "ARC GNU toolchain is not installed correctly" 38 | else 39 | die "The toolchain path ${ARC_DEV_TOOL_ROOT} does not exist " 40 | fi 41 | git checkout -- . || die 42 | 43 | echo "Using ${TOOLCHAIN}-${TOOLCHAIN_VER}" || die 44 | . apply_embARC_patch.sh 45 | } 46 | 47 | run_test() { 48 | local target_flags="" 49 | if [[ ${BD_VER:-} ]]; then 50 | target_flags="$target_flags --platform-version $BD_VER" 51 | fi 52 | export PYTHONUNBUFFERED=1 53 | { 54 | hostname 55 | python ./scripts/test.py --platform $BOARD --testcase-root arc_labs/labs --toolchain $TOOLCHAIN $target_flags --build-only --report-dir $logs_dir -v -v || true 56 | } 2>&1 | tee -a $test_log 57 | } 58 | 59 | parse_logs() { 60 | # get rid of MAC \r and change it to UNIX \n 61 | sed -i 's/\r/\n/g' $test_log 62 | 63 | METRICS=$(cat $test_log | grep "test configurations passed" | sed -n 's/^.* \([0-9]\+\) of.*, \([0-9]\+\).*failed, \([0-9]\+\).*in \([0-9]\+\).*$/\1 \2 \3 \4/p') 64 | if ! ([ ${#METRICS[@]} -eq 4 ] && [ ${METRICS[1]} == "0" ]); then 65 | exit 1 66 | fi 67 | } 68 | 69 | main() { 70 | mkdir embarc_osp/arc_labs 71 | cp -r labs embarc_osp/arc_labs 72 | pushd embarc_osp 73 | prepare_env 74 | run_test 75 | # parse_logs 76 | popd 77 | } 78 | 79 | main -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | *.bin 7 | *.hex 8 | *.dasm 9 | 10 | # Libraries 11 | *.lib 12 | *.a 13 | 14 | # Shared objects (inc. Windows DLLs) 15 | *.dll 16 | *.so 17 | *.so.* 18 | *.dylib 19 | 20 | # Executables 21 | *.exe 22 | *.out 23 | *.app 24 | *.i*86 25 | *.x86_64 26 | *.hex 27 | *.pyc 28 | 29 | # Map file 30 | *.map 31 | 32 | # vim swap file 33 | *.swp 34 | 35 | # dependency file 36 | *.o.d 37 | 38 | # TAGS 39 | *.tags* 40 | *TAGS* 41 | *tags* 42 | 43 | # logs 44 | *.log 45 | 46 | # generated link file 47 | *.ldf 48 | *.mkdir_done 49 | 50 | # metaware debugger temp files 51 | **/.sc.project 52 | 53 | # ide project temporary files 54 | **/.metadata 55 | **/.settings 56 | 57 | # embARC generated 58 | **/embARC_generated 59 | 60 | # embARC object folders 61 | **/obj_*/gnu_*/* 62 | **/obj_*/mw_*/* 63 | 64 | # Ignore Doxygen Generated Documents 65 | doc/build 66 | doc/documents/example/example 67 | 68 | ## Ignore unnecessary sources and keep necessary files 69 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018, Synopsys, Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 10 | 11 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = embARC 8 | SOURCEDIR = documents 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile doxygen 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /doc/documents/_static/style_overrides.css: -------------------------------------------------------------------------------- 1 | /* override table width restrictions */ 2 | @media screen and (min-width: 767px) { 3 | 4 | .wy-table-responsive table td, 5 | .wy-table-responsive table th { 6 | /* !important prevents the common CSS stylesheets from overriding 7 | * this as on RTD they are loaded after this stylesheet */ 8 | white-space: normal !important; 9 | } 10 | 11 | .wy-table-responsive { 12 | overflow: visible !important; 13 | } 14 | } 15 | 16 | @media screen { 17 | .wy-side-nav-search { 18 | background-color: #5a2a82; 19 | } 20 | 21 | .wy-side-nav-search>div.version { 22 | color: #b1b3b3; 23 | } 24 | 25 | .wy-nav-side { 26 | background-color: #2e3b4e; 27 | } 28 | 29 | .wy-nav-content { 30 | background-color: #f7f7fa; 31 | } 32 | 33 | body { 34 | background-color: #f0f0f4; 35 | } 36 | 37 | .wy-side-nav-search::before { 38 | content: ""; 39 | background-image: url("synopsys_wht.png"); 40 | width: 230px; 41 | height: 50px; 42 | display: block; 43 | margin: 30px 0 30px 25px; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /doc/documents/_static/synopsys_wht.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/_static/synopsys_wht.png -------------------------------------------------------------------------------- /doc/documents/appendix/appendix.rst: -------------------------------------------------------------------------------- 1 | .. _appendix: 2 | 3 | Appendix 4 | ======== 5 | 6 | Reference 7 | ######### 8 | 9 | #. `Online docs `__ 10 | #. `ARC EM Starter Kit Webpage `_ 11 | #. `ARC IoT Development Kit Webpage `_ 12 | #. `Github Repository of embARC Open Software Platform (OSP) `__ -------------------------------------------------------------------------------- /doc/documents/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # embARC documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jan 09 16:40:16 2018. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | # If extensions (or modules to document with autodoc) are in another directory, 16 | # add these directories to sys.path here. If the directory is relative to the 17 | # documentation root, use os.path.abspath to make it absolute, like shown here. 18 | # 19 | import sys 20 | import os 21 | import shlex 22 | # import os 23 | # import sys 24 | 25 | sys.path.insert(0, os.path.abspath('..')) 26 | sys.path.insert(0, os.path.abspath('../../')) 27 | 28 | 29 | # -- General configuration ------------------------------------------------ 30 | 31 | # If your documentation needs a minimal Sphinx version, state it here. 32 | # 33 | # needs_sphinx = '1.0' 34 | 35 | # Add any Sphinx extension module names here, as strings. They can be 36 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 37 | # ones. 38 | extensions = ['sphinx.ext.autodoc', 39 | 'sphinx.ext.intersphinx', 40 | 'sphinx.ext.todo', 41 | 'sphinx.ext.ifconfig'] 42 | 43 | # Add any paths that contain templates here, relative to this directory. 44 | templates_path = ['_templates'] 45 | 46 | source_parsers = { 47 | '.md': 'recommonmark.parser.CommonMarkParser', 48 | } 49 | 50 | # The suffix(es) of source filenames. 51 | # You can specify multiple suffix as a list of string: 52 | # 53 | # source_suffix = ['.rst', '.md'] 54 | source_suffix = ['.rst', '.md'] 55 | 56 | # The master toctree document. 57 | master_doc = 'index' 58 | 59 | # General information about the project. 60 | project = u'ARC Labs' 61 | copyright = u'2018, Synopsys' 62 | author = u'Synopsys' 63 | today_fmt = '%Y' 64 | 65 | # The version info for the project you're documenting, acts as replacement for 66 | # |version| and |release|, also used in various other places throughout the 67 | # built documents. 68 | # 69 | # The short X.Y version. 70 | version = u'2018.09' 71 | # The full version, including alpha/beta/rc tags. 72 | release = u'2018.09' 73 | 74 | # The language for content autogenerated by Sphinx. Refer to documentation 75 | # for a list of supported languages. 76 | # 77 | # This is also used if you do content translation via gettext catalogs. 78 | # Usually you set "language" from the command line for these cases. 79 | language = None 80 | 81 | # List of patterns, relative to source directory, that match files and 82 | # directories to ignore when looking for source files. 83 | # This patterns also effect to html_static_path and html_extra_path 84 | exclude_patterns = [] 85 | 86 | # The name of the Pygments (syntax highlighting) style to use. 87 | pygments_style = 'sphinx' 88 | 89 | # If true, `todo` and `todoList` produce output, else they produce nothing. 90 | todo_include_todos = True 91 | 92 | 93 | # -- Options for HTML output ---------------------------------------------- 94 | 95 | # The theme to use for HTML and HTML Help pages. See the documentation for 96 | # a list of builtin themes. 97 | # 98 | html_theme = 'sphinx_rtd_theme' 99 | 100 | # Theme options are theme-specific and customize the look and feel of a theme 101 | # further. For a list of options available for each theme, see the 102 | # documentation. 103 | # 104 | # html_theme_options = {} 105 | 106 | # Add any paths that contain custom static files (such as style sheets) here, 107 | # relative to this directory. They are copied after the builtin static files, 108 | # so a file named "default.css" will overwrite the builtin "default.css". 109 | html_static_path = ['_static'] 110 | 111 | 112 | html_context = { 113 | 'css_files': [ 114 | '_static/style_overrides.css', 115 | ], 116 | } 117 | 118 | # -- Options for HTMLHelp output ------------------------------------------ 119 | 120 | # Output file base name for HTML help builder. 121 | htmlhelp_basename = 'embARCdoc' 122 | 123 | 124 | # -- Options for LaTeX output --------------------------------------------- 125 | 126 | latex_elements = { 127 | # The paper size ('letterpaper' or 'a4paper'). 128 | # 129 | 'papersize': 'a4paper', 130 | 131 | # The font size ('10pt', '11pt' or '12pt'). 132 | # 133 | 'pointsize': '10pt', 134 | 135 | # Additional stuff for the LaTeX preamble. 136 | # 137 | 'preamble': '', 138 | 139 | # Latex figure (float) alignment 140 | # 141 | 'figure_align': 'htbp', 142 | } 143 | 144 | # Grouping the document tree into LaTeX files. List of tuples 145 | # (source start file, target name, title, 146 | # author, documentclass [howto, manual, or own class]). 147 | latex_documents = [ 148 | (master_doc, 'arc_labs.tex', u'ARC labs handbook', 149 | u'Synopsys', 'manual'), 150 | ] 151 | 152 | 153 | # -- Options for manual page output --------------------------------------- 154 | 155 | # One entry per manual page. List of tuples 156 | # (source start file, name, description, authors, manual section). 157 | man_pages = [ 158 | (master_doc, 'arc_labs', u'ARC labs handbook', 159 | [author], 1) 160 | ] 161 | 162 | 163 | # -- Options for Texinfo output ------------------------------------------- 164 | 165 | # Grouping the document tree into Texinfo files. List of tuples 166 | # (source start file, target name, title, author, 167 | # dir menu entry, description, category) 168 | texinfo_documents = [ 169 | (master_doc, 'arc_labs', u'ARC labs handbook', 170 | author, 'embARC', 'One line description of project.', 171 | 'Miscellaneous'), 172 | ] 173 | 174 | # Example configuration for intersphinx: refer to the Python standard library. 175 | intersphinx_mapping = {'https://docs.python.org/': None} 176 | 177 | 178 | 179 | rst_epilog = u""" 180 | .. |arc| replace:: DesignWare® ARC® processors 181 | .. |embarc| replace:: embARC OSP 182 | .. |iotdk| replace:: IoT Development Kit 183 | .. |emsk| replace:: EM Starter Kit 184 | .. |mwdt| replace:: MetaWare Development Toolkit 185 | .. |arcgnu| replace:: GNU Toolchain for ARC Processors 186 | """ -------------------------------------------------------------------------------- /doc/documents/glossary.rst: -------------------------------------------------------------------------------- 1 | :orphan: 2 | 3 | .. _glossary: 4 | 5 | Glossary of Terms 6 | ################# 7 | 8 | .. glossary:: 9 | :sorted: 10 | 11 | AUX 12 | Auxiliar registers in |arc|. These registers are not memory mapped and require kernel privilege and specific instructions(``lr`` and ``sr``) to access. 13 | 14 | BCR 15 | (Build Configuration Register). The |arc| is highly configurable, the corresponding features can be extracted from BCR. 16 | 17 | TCF 18 | (Tool Configuration File) 19 | 20 | DEV 21 | Abbreviation of device 22 | 23 | INT 24 | Abbreviation of interrupt 25 | 26 | ISR 27 | (Interrupt Service Routine) Also known as an interrupt handler, an ISR 28 | is a callback function whose execution is triggered by a hardware 29 | interrupt (or software interrupt instructions) and is used to handle 30 | high-priority conditions that require interrupting the current code 31 | executing on the processor. 32 | 33 | EXC 34 | Abbreviaion of exception 35 | -------------------------------------------------------------------------------- /doc/documents/img/dsp_figure_1.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_figure_1.1.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_figure_1.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_figure_1.2.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_figure_1.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_figure_1.3.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_figure_2.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_figure_2.1.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_figure_2.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_figure_2.2.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_2.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_2.1.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_2.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_2.2.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_2.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_2.3.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_2.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_2.4.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_3.1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_3.1.png -------------------------------------------------------------------------------- /doc/documents/img/dsp_icon_3.2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/dsp_icon_3.2.png -------------------------------------------------------------------------------- /doc/documents/img/lab10.2_figure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab10.2_figure1.png -------------------------------------------------------------------------------- /doc/documents/img/lab10.2_figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab10.2_figure2.png -------------------------------------------------------------------------------- /doc/documents/img/lab10.2_figure3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab10.2_figure3.png -------------------------------------------------------------------------------- /doc/documents/img/lab10.2_figure4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab10.2_figure4.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_builds_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_builds_1.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_builds_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_builds_2.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_builds_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_builds_3.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_emsk_connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_emsk_connections.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_smarthome_system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_smarthome_system.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_1.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_10.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_2.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_3.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_4.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_5.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_6.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_7.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_8.png -------------------------------------------------------------------------------- /doc/documents/img/lab11_steps_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab11_steps_9.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure1.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure10.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure11.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure12.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure13.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure14.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure15.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure16.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure17.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure18.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure2.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure3.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure4.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure5.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure6.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure7.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure8.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_figure9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_figure9.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon1.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon10.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon11.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon12.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon13.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon14.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon15.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon16.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon17.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon18.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon19.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon2.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon20.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon21.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon3.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon4.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon5.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon6.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon7.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon8.png -------------------------------------------------------------------------------- /doc/documents/img/lab1_icon9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab1_icon9.png -------------------------------------------------------------------------------- /doc/documents/img/lab3_debug_view_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab3_debug_view_1.png -------------------------------------------------------------------------------- /doc/documents/img/lab3_debug_view_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab3_debug_view_2.png -------------------------------------------------------------------------------- /doc/documents/img/lab3_program_flow_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab3_program_flow_chart.png -------------------------------------------------------------------------------- /doc/documents/img/lab3_register_TIMER_BUILD.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab3_register_TIMER_BUILD.png -------------------------------------------------------------------------------- /doc/documents/img/lab5_emsk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab5_emsk.png -------------------------------------------------------------------------------- /doc/documents/img/lab5_iotdk_pin_connect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab5_iotdk_pin_connect.png -------------------------------------------------------------------------------- /doc/documents/img/lab6_emsk_boot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_emsk_boot.png -------------------------------------------------------------------------------- /doc/documents/img/lab6_emsk_bootloader_onspiflash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_emsk_bootloader_onspiflash.jpg -------------------------------------------------------------------------------- /doc/documents/img/lab6_emsk_bootloader_program2spiflash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_emsk_bootloader_program2spiflash.jpg -------------------------------------------------------------------------------- /doc/documents/img/lab6_iotdk_bootloader_bootjson.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_iotdk_bootloader_bootjson.jpg -------------------------------------------------------------------------------- /doc/documents/img/lab6_iotdk_bootloader_onspiflash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_iotdk_bootloader_onspiflash.jpg -------------------------------------------------------------------------------- /doc/documents/img/lab6_iotdk_bootloader_program2spiflash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab6_iotdk_bootloader_program2spiflash.jpg -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure1.png -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure2.png -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure3.png -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure4.png -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure5.png -------------------------------------------------------------------------------- /doc/documents/img/lab7_figure6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab7_figure6.png -------------------------------------------------------------------------------- /doc/documents/img/lab8_figure1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab8_figure1.png -------------------------------------------------------------------------------- /doc/documents/img/lab8_figure2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab8_figure2.png -------------------------------------------------------------------------------- /doc/documents/img/lab8_figure3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab8_figure3.png -------------------------------------------------------------------------------- /doc/documents/img/lab9_program_flow_chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/lab9_program_flow_chart.png -------------------------------------------------------------------------------- /doc/documents/img/mwdt_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/mwdt_1.png -------------------------------------------------------------------------------- /doc/documents/img/mwdt_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/mwdt_2.png -------------------------------------------------------------------------------- /doc/documents/img/mwdt_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/mwdt_3.png -------------------------------------------------------------------------------- /doc/documents/img/mwdt_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/mwdt_4.png -------------------------------------------------------------------------------- /doc/documents/img/mwdt_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/foss-for-synopsys-dwc-arc-processors/arc_labs/b258966a018e282b061e0f7924917281e45706ea/doc/documents/img/mwdt_5.png -------------------------------------------------------------------------------- /doc/documents/index.rst: -------------------------------------------------------------------------------- 1 | .. embARC documentation master file, created by 2 | sphinx-quickstart on Tue Jan 09 16:40:16 2018. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to ARC labs handbook! 7 | ======================================================= 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Contents: 12 | 13 | introduction/introduction.rst 14 | getting_started/getting_started.rst 15 | labs/labs.rst 16 | appendix/appendix.rst 17 | 18 | 19 | 20 | 21 | Indices and tables 22 | ================== 23 | 24 | * :ref:`genindex` 25 | * :ref:`search` 26 | -------------------------------------------------------------------------------- /doc/documents/introduction/introduction.rst: -------------------------------------------------------------------------------- 1 | .. _introduction_arc_labs: 2 | 3 | Overview 4 | ======== 5 | 6 | Introduction 7 | ############ 8 | 9 | This is a handbook for ARC labs which is a part of ARC university courses. 10 | The handbook is written to help students who attend the ARC university course. 11 | Anyone interested in |arc| can also take this handbook as a quick start-up to get started in |arc| development. 12 | In this handbook, all the basic elements of ARC are described in the labs with a step-by-step approach. 13 | 14 | This handbook can be used as a Lab teaching material for ARC university courses at 15 | undergraduate or graduate level with majors in Computer Science, Computer 16 | Engineering, Electrical Engineering, or for professional engineers. 17 | 18 | This handbook includes a series of labs (more labs will be added in the future), which are roughly classified into 3 levels: 19 | 20 | * :ref:`Level 1: ARC basic ` 21 | 22 | The labs in this level cover the basic topics of |arc|. For example, the 23 | installation and usage of hardware and software tools, software or hardware 24 | development kits, the first hello world example, interrupt handling and internal timers of |arc|, and so on. 25 | 26 | * :ref:`Level 2: ARC advanced ` 27 | 28 | The labs in this level cover the advanced topics of |arc|. For example, 29 | Real-Time Operating System (RTOS), customized linkage, compiler optimization, 30 | basic applications, |arc| DSP feature, and so on. 31 | 32 | * :ref:`Level 3: ARC exploration ` 33 | 34 | The labs in this level cover some complex applications of |arc|. For example, 35 | Internet of Things (IoT) application, embedded machine learning, and so on. 36 | 37 | Most of the labs are based on the `embARC Open Software Platform (OSP) `__ which is an open 38 | software platform to facilitate the development of embedded systems based on 39 | |arc|. 40 | 41 | It is designed to provide a unified platform for |arc| users by defining 42 | consistent and simple software interfaces to the processor and peripherals 43 | together with ports of several well known Free and open-source software (FOSS) 44 | embedded software stacks to |arc|. 45 | 46 | For more details about |embarc|, please see its 47 | `online docs `__. 48 | 49 | Supported Hardware Platform 50 | ########################### 51 | 52 | The following |arc| based hardware platforms are supported in this handbook. 53 | 54 | * `ARC EM Starter Kit `_ 55 | * `ARC IoT Development Kit `_ 56 | 57 | You can click the above links to get the platform's data sheet and user 58 | manual as a reference. 59 | 60 | Reference 61 | ######### 62 | 63 | ====== ================ 64 | Item Name 65 | ====== ================ 66 | 1 ARC EM Databook 67 | 2 MetaWare docs 68 | 3 ARC EM Starter Kit User Guide 69 | 4 ARC GNU docs 70 | ====== ================ -------------------------------------------------------------------------------- /doc/documents/labs/labs.rst: -------------------------------------------------------------------------------- 1 | .. _labs: 2 | 3 | Hands-on labs 4 | ################# 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | level1.rst 10 | level2.rst 11 | level3.rst -------------------------------------------------------------------------------- /doc/documents/labs/level1.rst: -------------------------------------------------------------------------------- 1 | .. _level1_labs: 2 | 3 | Basic labs 4 | ############ 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | level1/lab1 11 | level1/lab2 12 | level1/lab5 13 | level1/lab3 14 | level1/lab4 15 | level1/lab6 -------------------------------------------------------------------------------- /doc/documents/labs/level1/lab3.rst: -------------------------------------------------------------------------------- 1 | .. _lab3: 2 | 3 | ARC features: AUX registers and timers 4 | ###################################################### 5 | 6 | Purpose 7 | ======= 8 | - To know the auxiliary registers and processor timers of |arc| 9 | - To learn how to program auxiliary registers to control the processor timers 10 | 11 | Requirements 12 | ============ 13 | 14 | The following hardware and tools are required: 15 | 16 | * PC host 17 | * |arcgnu| / |mwdt| 18 | * ARC board (|emsk| / |iotdk|) 19 | * ``embarc_osp/arc_labs/labs/lab_timer`` 20 | 21 | Content 22 | ======== 23 | 24 | - Through reading the corresponding Build Configuration Register (BCR) auxiliary registers of processor timers to get the configuration information 25 | - Through programming the auxiliary registers to initialize, start and stop the timer (here TIMER0 is used) 26 | - By reading the count value of processor timers, get the execution time of a code block 27 | 28 | Principles 29 | ========== 30 | 31 | Auxiliary Registers 32 | ------------------- 33 | 34 | The auxiliary register set contains status and control registers, which by default are 32 bits wide to implement the processor control, for example, interrupt and exception management and processor timers. These 35 | auxiliary registers occupy a separate 32-bit address space from the normal memory-access (that is load and 36 | store) instructions. Auxiliary registers accessed using distinct Load Register (LR), Store Register (SR), and 37 | Auxiliary EXchange (AEX) instructions. 38 | 39 | The auxiliary register address region 0x60 up to 0x7F and region 0xC0 up to 0xFF is reserved for the Build 40 | Configuration Registers (BCRs) that can be used by embedded software or host debug software to detect the 41 | configuration of the ARCv2-based hardware. The Build Configuration Registers contain the version of each 42 | ARCv2-based extension and also the build-specific configuration information. 43 | 44 | In |embarc|, ``arc_builtin.h`` provides API (**arc_aux_read** and **arc_aux_read**) to access the auxiliary registers. 45 | 46 | 47 | Processor Timers 48 | ---------------- 49 | 50 | The processor timers are two independent 32-bit timers and a 64-bit real-time 51 | counter (RTC). **Timer0** and **Timer1** are identical in operation. The only 52 | difference is that these timers are connected to different interrupts. The 53 | timers cannot be included in a configuration without interrupts. Each timer is 54 | optional and when present, it is connected to a fixed interrupt; interrupt 16 55 | for timer 0 and interrupt 17 for timer 1. 56 | 57 | The processor timers are connected to a system clock signal that operates even 58 | when the ARCv2-based processor is in the sleep state. The timers can be used 59 | to generate interrupt signals that wake the processor from the SLEEP state. The 60 | processor timers automatically reset and restart their operation after 61 | reaching the limit value. The processor timers can be programmed to count only 62 | the clock cycles when the processor is not halted. The processor timers can 63 | also be programmed to generate an interrupt or to generate a system Reset upon 64 | reaching the limit value. The 64-bit RTC does not generate any interrupts. 65 | This timer is used to count the clock cycles atomically. 66 | 67 | Through the BCR register *0x75*, you can get the configuration information of processor timers 68 | 69 | In |embarc|, ``arc/arc_timer.h`` provides API to operate the processor timers. 70 | 71 | Program flow chart 72 | ------------------ 73 | 74 | The code's flow is shown below: 75 | 76 | .. image:: /img/lab3_program_flow_chart.png 77 | :alt: program flow chart 78 | 79 | The code can be divided into 3 parts: 80 | 81 | * Part1 : read the BCR of internal timers to check the features 82 | * Part2 : promgram Timer0 by auxiliary registers with the |embarc| provided API 83 | * Part3 : read the counts to Timer 0 to measure a code block's execution time 84 | 85 | Steps 86 | ===== 87 | 88 | 1. Build and Run 89 | 90 | .. code-block:: console 91 | 92 | $ cd /arc_labs/labs/lab_timer 93 | # for emsk 94 | $ make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=gnu run 95 | # for iotdk 96 | $ make BOARD=iotdk TOOLCHAIN=gnu run 97 | 98 | 2. Output 99 | 100 | .. code-block:: console 101 | 102 | ----------------------------------------------------------- 103 | ____ _ ____ 104 | | _ \ _____ _____ _ __ ___ __| | __ ) _ _ 105 | | |_) / _ \ \ /\ / / _ \ '__/ _ \/ _` | _ \| | | | 106 | | __/ (_) \ V V / __/ | | __/ (_| | |_) | |_| | 107 | |_| \___/ \_/\_/ \___|_| \___|\__,_|____/ \__, | 108 | |___/ 109 | _ _ ____ ____ 110 | ___ _ __ ___ | |__ / \ | _ \ / ___| 111 | / _ \ '_ ` _ \| '_ \ / _ \ | |_) | | 112 | | __/ | | | | | |_) / ___ \| _ <| |___ 113 | \___|_| |_| |_|_.__/_/ \_\_| \_\\____| 114 | ------------------------------------------------------------ 115 | 116 | embARC Build Time: Aug 22 2018, 15:32:54 117 | Compiler Version: MetaWare, 4.2.1 Compatible Clang 4.0.1 (branches/release_40) 118 | Does this timer0 exist? YES 119 | timer0's operating mode:0x00000003 120 | timer0's limit value :0x00023280 121 | timer0's current cnt_number:0x0000c236 122 | 123 | Does this timer1 exist? YES 124 | timer1's operating mode:0x00000000 125 | timer1's limit value :0x00000000 126 | timer1's current cnt_number:0x00000000 127 | 128 | Does this RTC_timer exist? NO 129 | 130 | The start_cnt number is:2 131 | /******** TEST MODE START ********/ 132 | 133 | This is TEST CODE. 134 | 135 | This is TEST CODE. 136 | 137 | This is TEST CODE. 138 | 139 | /******** TEST MODE END ********/ 140 | The end_cnt number is:16785931 141 | The board cpu clock is:144000000 142 | 143 | Total time of TEST CODE BLOCK operation:116 144 | 145 | Exercises 146 | ========= 147 | 148 | 1. Try to program TIMER1 149 | 2. Try to create a clock with a tick of 1 second 150 | -------------------------------------------------------------------------------- /doc/documents/labs/level1/lab5.rst: -------------------------------------------------------------------------------- 1 | .. _lab5: 2 | 3 | How to use ARC board 4 | ####################### 5 | 6 | Purpose 7 | ======= 8 | - To get familiar with the usage of ARC board and on-board peripherals 9 | - To know how to program and debug the ARC board and on-board peripherals 10 | 11 | Requirements 12 | ============ 13 | 14 | The following hardware and tools are required: 15 | 16 | * PC host 17 | * |arcgnu| / |mwdt| 18 | * ARC board (|emsk| / |iotdk|) 19 | * ``embarc_osp/arc_labs/labs/lab5_emsk`` / ``embarc_osp/arc_labs/labs/lab5_iotdk`` 20 | 21 | Content 22 | ======== 23 | 24 | - A brief introduction of ARC board and on-board peripherals 25 | - Based on |embarc|, program the GPIO to control some on-board peripherals 26 | 27 | .. note:: 28 | About the detailed usage of |embarc|, see `How to use embARC OSP `__ 29 | 30 | Principles 31 | ========== 32 | 33 | |emsk| 34 | ******* 35 | 36 | About the brief introduction of |emsk|, see to `embARC OSP Documentation `__ 37 | 38 | There are LEDs, DIP switches, and buttons on |emsk|, this lab shows 39 | how to program the GPIO to control these on-board peripherals of |emsk|. 40 | The code for this lab is located in ``embarc_osp/arc_labs/labs/lab5_emsk``. In the code, the on-board buttons and DIP switches' values 41 | are read, and whether LEDs are on or off depend on the value of the buttons and DIP switches. 42 | 43 | 44 | 45 | |iotdk| 46 | ******* 47 | 48 | About the brief introduction of |iotdk|, see `embARC OSP Documentation `__ 49 | 50 | As there are no LED or other easy-to-use peripherals on |iotdk|, this lab shows how to control a LED through the arduino interface of |iotdk|. 51 | The code for this lab is located in ``embarc_osp/arc_labs/labs/lab5_iotdk``. In the code, the external connected LED blinks periodically. 52 | 53 | Steps 54 | ===== 55 | 56 | |emsk| 57 | ****** 58 | 59 | 1. Connect |emsk| to your computer, select **em7d** configuration and open UART terminal. 60 | 61 | 2. Compile and run the ``embarc_osp/arc_labs/lab5_emsk`` example with the following commands: 62 | 63 | .. code-block:: console 64 | 65 | cd /arc_labs/lab5_emsk 66 | make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=gnu run 67 | 68 | 3. Press the buttons (L or/and R) and toggle the DIP switches (3 or/and 4), then check the result in UART terminal, and watch the changes of on-board LEDs. 69 | 70 | |figure1| 71 | 72 | |iotdk| 73 | ******* 74 | 75 | |iotdk| has an arduino interface, here select arduino digital pinout **ARDUINO_PIN_0(iotdk gpio4b_2[0])** to control LED. 76 | 77 | 1. Find a LED, connect the LED anode pin to **ARDUINO_PIN_0**, connect the LED cathode pin to **GND** of |iotdk|. 78 | 79 | 2. Connect the USB cable to the USB data port of |iotdk| and the computer. 80 | 81 | 3. Compile and run the ``embarc_osp/arc_labs/lab5_iotdk`` example with the following commands: 82 | 83 | .. code-block:: console 84 | 85 | cd /arc_labs/lab5_iotdk 86 | make BOARD=iotdk TOOLCHAIN=gnu run 87 | 88 | 4. Watch the changes of external connected LED. 89 | 90 | |figure2| 91 | 92 | .. note:: 93 | The connection between LED and |iotdk| is just for test. 94 | A 1kΩ resistor should be added in series connection to limited the current and prevent damage to I/O pin. 95 | 96 | Exercises 97 | ========= 98 | 99 | Try to create you own application to control the peripherals of ARC board 100 | 101 | .. note:: 102 | The ARC |iotdk| is powered over USB. Note that the ARC |iotdk| needs to be powered by an external power adapter if additional devices are connected to the extension interfaces. External power supply must be 5V DC (A 12V power supply will most probably damage your board). 103 | 104 | .. |figure1| image:: /img/lab5_emsk.png 105 | :alt: lab5_emsk 106 | :width: 400 107 | 108 | 109 | .. |figure2| image:: /img/lab5_iotdk_pin_connect.png 110 | :alt: lab5_iotdk_pin_connect 111 | :width: 400 -------------------------------------------------------------------------------- /doc/documents/labs/level2.rst: -------------------------------------------------------------------------------- 1 | .. _level2_labs: 2 | 3 | Advanced labs 4 | ################## 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | level2/lab8 11 | level2/lab10 12 | level2/lab7 13 | level2/lab9 14 | level2/lab_dsp1 15 | level2/lab_dsp2 16 | level2/lab_dsp3 -------------------------------------------------------------------------------- /doc/documents/labs/level2/lab7.rst: -------------------------------------------------------------------------------- 1 | .. _lab7: 2 | 3 | BLE Communication 4 | ################### 5 | 6 | Purpose 7 | ======= 8 | - To get familiar with the wireless communication in IoT 9 | - To get familiar with the usage of RN4020 BLE module on |iotdk| 10 | - To learn the usage of APIs of RN4020 driver in |embarc| 11 | 12 | 13 | Requirements 14 | ============ 15 | The following hardware and tools are required: 16 | 17 | * PC host 18 | * A smartphone which supports BLE 19 | * ARC GNU toolchain/MetaWare Development Toolkit 20 | * ARC board (|iotdk|) 21 | * |embarc| package 22 | * ``embarc_osp/arc_labs/labs/lab6_ble_rn4020`` 23 | 24 | Content 25 | ======== 26 | The communication between smartphone and |iotdk| board with RN4020 BLE module. 27 | 28 | - Setup RN4020 BLE module by using API of RN4020 driver. 29 | - Connect smartphone and RN4020 by BLE, and check the data send by |iotdk| in smartphone. 30 | - Send data from smartphone to |iotdk| board, and print this data value in terminal. 31 | 32 | 33 | Principles 34 | ========== 35 | RN4020 BLE module is controlled by the user through input/output lines (that is physical device pins) and an UART interface. 36 | The UART Interface supports ASCII commands to control/configure the RN4020 modules for any specific requirement based on the application. 37 | 38 | 39 | Setup 40 | ----- 41 | Before connecting an RN4020 module to a smartphone device, you might need to set up the RN4020 module as follows. 42 | 43 | 1. Configure UART which is connected to RN4020 with these parameters: **Baud rate - 115200, Data bits - 8, Parity - None, Stop bits - 1** 44 | 45 | 2. Set the **WAKE_SW** pin high to enter command mode 46 | 47 | 3. Run the command **SF, 1** to reset to the factory default configuration 48 | 49 | 4. Run the command **SN, IoT DK** to set the device name to be "IoT DK" 50 | 51 | 5. Run the command **SS, C0000001** to enable support of the Device Information, Battery Service, and User-Defined Private Service 52 | 53 | 6. Run the command **SR, 00002000** to set the RN4020 module as a server 54 | 55 | 7. Run the command **PZ** to clear all settings of the private service and the private characteristics 56 | 57 | 8. Run the command **PS, 11223344556677889900AABBCCDDEEFF** to set the UUID of user-defined private service to be 0x11223344556677889900AABBCCDDEEFF 58 | 59 | 9. Run the command **PC, 010203040506070809000A0B0C0D0E0F, 18, 06** to add private characteristic 0x010203040506070809000A0B0C0D0E0F to current private service. The property of this characteristic is 0x18 (writable and could notify) and has a maximum data size of 6 bytes. 60 | 61 | 10. Run the command **R, 1** to reboot the RN4020 module and to make the new settings effective 62 | 63 | 11. Run the command **LS** to display the services 64 | 65 | The source code using the API of RN4020 driver in |embarc| as follows. 66 | 67 | .. code-block:: console 68 | 69 | rn4020_setup(rn4020_ble); 70 | rn4020_reset_to_factory(rn4020_ble); 71 | 72 | /* Set device Name */ 73 | rn4020_set_dev_name(rn4020_ble, "IoT DK"); 74 | 75 | /* Set device services */ 76 | rn4020_set_services(rn4020_ble, RN4020_SERVICE_DEVICE_INFORMATION | 77 | RN4020_SERVICE_BATTERY | 78 | RN4020_SERVICE_USER_DEFINED); 79 | 80 | rn4020_set_features(rn4020_ble, RN4020_FEATURE_SERVER_ONLY); 81 | rn4020_clear_private(rn4020_ble); 82 | 83 | /* Set private service UUID and private characteristic */ 84 | rn4020_set_prv_uuid(rn4020_ble, RN4020_PRV_SERV_HIGH_UUID, RN4020_PRV_SERV_LOW_UUID); 85 | rn4020_set_prv_char(rn4020_ble, RN4020_PRV_CHAR_HIGH_UUID, RN4020_PRV_CHAR_LOW_UUID, 0x18, 0x06, RN4020_PRIVATE_CHAR_SEC_NONE); 86 | 87 | /* Reboot RN4020 to make changes effective */ 88 | rn4020_reset(rn4020_ble); 89 | 90 | rn4020_refresh_handle_uuid_table(rn4020_ble); 91 | 92 | 93 | Advertise 94 | --------- 95 | 96 | Run the command **A** to start advertisement. 97 | The source code using the API of RN4020 driver in |embarc| as follows: 98 | 99 | .. code-block:: console 100 | 101 | rn4020_advertise(rn4020_ble); 102 | 103 | 104 | Send data 105 | --------- 106 | 107 | Run the command **SUW, 2A19, value** to set the level of Battery. 108 | The source code using the API of RN4020 driver in |embarc| as follows: 109 | 110 | .. code-block:: console 111 | 112 | while (1) { 113 | 114 | rn4020_battery_set_level(rn4020_ble, battery--); 115 | 116 | board_delay_ms(1000, 0); 117 | if (battery < 30) { 118 | battery = 100; 119 | } 120 | } 121 | 122 | .. note:: 123 | About detailed usage of RN4020 BLE module, see RN4020 Bluetooth Low Energy Module User's Guide. 124 | 125 | Steps 126 | ===== 127 | 128 | Run project 129 | ----------- 130 | 131 | Open the serial terminal emulator in computer (for example, Tera Term), set as **115200 baud, 8 bits data, 1 stop bit and no parity**, and connect to the |iotdk| board. 132 | 133 | Open ``cmd`` from the folder *embarc_osp/arc_labs/labs/lab6_ble_rn4020*, input the command as follows: 134 | 135 | .. code-block:: console 136 | 137 | make BOARD=iotdk TOOLCHAIN=gnu run 138 | 139 | Then the output is displayed in the serial terminal. 140 | |figure1| 141 | 142 | Connection 143 | ---------- 144 | 145 | Open the BLE browser APP in smartphone (for example, LightBlue in IOS), and scan for BLE peripherals, connect the "IoT DK" device. 146 | Then the output is displayed in the serial terminal. 147 | |figure2| 148 | 149 | And the device information in displayed BLE browser APP. 150 | 151 | |figure3| 152 | 153 | Communication 154 | ------------- 155 | Read the data of Battery services in BLE browser APP. Check whether the data decreases gradually. 156 | 157 | |figure4| 158 | 159 | Write data in BLE browser APP. Check the received data in PC serial terminal. 160 | 161 | |figure5| 162 | 163 | |figure6| 164 | 165 | Exercises 166 | ========= 167 | Try to use the received data in |iotdk| board, and do some control by using GPIO. (for example, LED on/off) 168 | 169 | .. |figure1| image:: /img/lab7_figure1.png 170 | :width: 550 171 | .. |figure2| image:: /img/lab7_figure2.png 172 | :width: 550 173 | .. |figure3| image:: /img/lab7_figure3.png 174 | :width: 300 175 | .. |figure4| image:: /img/lab7_figure4.png 176 | :width: 300 177 | .. |figure5| image:: /img/lab7_figure5.png 178 | :width: 300 179 | .. |figure6| image:: /img/lab7_figure6.png 180 | :width: 550 181 | -------------------------------------------------------------------------------- /doc/documents/labs/level2/lab8.rst: -------------------------------------------------------------------------------- 1 | .. _lab8: 2 | 3 | Memory map and linker 4 | ######################## 5 | Purpose 6 | ======= 7 | - To get familiar with memory layout in compilation process 8 | - To learn how to use linker 9 | 10 | Requirements 11 | ============ 12 | The following hardware and tools are required: 13 | 14 | * PC host 15 | * ARC GNU toolchain/MetaWare Development Toolkit 16 | * nSIM simulator 17 | * ``embarc_osp/arc_labs/labs/lab8_linker`` 18 | 19 | Content 20 | ======== 21 | - Customizing your program with **compiler pragmas**. 22 | - Using "pragma code" to specify a new name of section in which the code of function reside. 23 | - Mapping this code section into specified memory location with linker. 24 | - Checking the location of this code section after build process. 25 | 26 | Principles 27 | ========== 28 | By default, compiler-generated code is placed in the *.text* section. The default code section name can be overridden by using the *code pragma*. After compilation process, the linker automatically maps all input sections from object files to output sections in executable files. If you want to customize the mapping, you can change the default linker mapping by invoking a linker command file. 29 | 30 | Steps 31 | ===== 32 | 33 | Create a project and overriding code section name 34 | --------------------------------------------------- 35 | 36 | Open MetaWare IDE, create an empty C project called lab_linker and select ARC EM series processor. Import the main.c and link.cmd files from the *embarc_osp/arc_labs/labs/lab8_linker* directory into the project. 37 | 38 | Open main.c file in MetaWare IDE, use "pragma code" to change the section in which function ``modify`` reside from *.text* to a new name "*modify_seg*". 39 | 40 | .. code-block:: c 41 | 42 | #pragma Code ("modify_seg") 43 | void modify(int list[], int size) { 44 | int out, in, temp; 45 | 46 | for(out=0; out list[in]) { 49 | temp = list[in]; 50 | list[in] = list[out]; 51 | list[out] = temp; 52 | } 53 | } 54 | #pragma Code () 55 | 56 | Pragma code has two forms that must be used in pairs to bracket the affected function definitions: 57 | 58 | .. code-block:: c 59 | 60 | #pragma code(Section_name) 61 | /* ----- Affected function definitions go here ---- */ 62 | #pragma code() /* No parameters here */ 63 | 64 | Section_name is a constant string expression that denotes the name of the section. 65 | 66 | .. note:: 67 | About detailed usage of the compiler pragmas, see MetaWare C/C++ Programmer's Guide for the ccac Compiler. 68 | 69 | Edit the linker command file 70 | ---------------------------- 71 | 72 | Open link.cmd file, there are two parts, one is for memory blocks location, the other is for sections mapping. 73 | Add one new block named "*MyBlock*" in MEMORY, the start address is 0x00002000, and the size is 32KB. Add one new GROUP in SECTIONS, and mapping section "*modify_seg*" into *MyBlock*. 74 | 75 | .. code-block:: c 76 | 77 | MEMORY { 78 | // Note: overlap of code and data spaces is not recommended since it makes 79 | // Address validity checking impossible with the debugger and simulator 80 | MyBlock: ORIGIN = 0x00002000, LENGTH = 32K 81 | MEMORY_BLOCK1: ORIGIN = 0x0010000, LENGTH = 64K 82 | MEMORY_BLOCK2: ORIGIN = 0x0020000, LENGTH = 128K 83 | } 84 | 85 | SECTIONS { 86 | GROUP: { 87 | modify_seg: {} 88 | }>MyBlock 89 | ...... 90 | 91 | .. note:: 92 | About format and syntax of the linker command file, see MetaWare ELF Linker and Utilities User's Guide. 93 | 94 | Add the linker command file into the project 95 | -------------------------------------------- 96 | 97 | Right-click the current project lab_linker and select Properties. Click **C/C++ build** > **Settings** > **Tool Settings** to open the linker option settings page. 98 | 99 | |figure1| 100 | 101 | Select Command files to add linker.cmd file into this project. 102 | 103 | Check the result 104 | ---------------- 105 | 106 | In the linker option settings window, select Map listing to check Generate listing file(=.map) 107 | 108 | |figure2| 109 | 110 | Build the lab_linker project, then open the lab_linker.map file. 111 | 112 | |figure3| 113 | 114 | Search SECTIONS SUMMARY, then you can check the size and location of *modify_seg* section, it resides in *MyBlock*, similar to you setting in the linker command file. 115 | 116 | Exercises 117 | ========= 118 | 119 | Check the memory mapping info of *modify_seg* section by using elfdump tool. 120 | 121 | 122 | .. |figure1| image:: /img/lab8_figure1.png 123 | .. |figure2| image:: /img/lab8_figure2.png 124 | .. |figure3| image:: /img/lab8_figure3.png 125 | -------------------------------------------------------------------------------- /doc/documents/labs/level2/lab_dsp1.rst: -------------------------------------------------------------------------------- 1 | .. _lab_dsp1: 2 | 3 | ARC DSP: Compiler Optimizations 4 | ==================================== 5 | 6 | Purpose 7 | --------------------------- 8 | 9 | - To understand Metaware compiler DSP extension options and optimization level 10 | - To learn how to use Metaware compiler to optimize regular C code with DSP instructions 11 | 12 | Requirements 13 | ----------------------------- 14 | The following hardware and tools are required: 15 | 16 | * PC host 17 | * |mwdt| 18 | * ARC board (|emsk| / |iotdk|) 19 | * ``embarc_osp/arc_labs/labs/dsp_lab_compiler_opt`` 20 | 21 | Content 22 | ----------------------------- 23 | 24 | An example code below contains a function "test" which contains a 20 step for loop and a multiply accumulate operation done manually. 25 | 26 | .. code-block:: c 27 | 28 | #include 29 | 30 | short test(short *a, short *b) { 31 | int i; 32 | 33 | long acc = 0; 34 | for(i = 0; i < 10; i++) 35 | acc += ( ((long)(*a++)) * *b++) <<1 ; 36 | 37 | return (short) (acc); 38 | } 39 | 40 | short a[] = {1,2,3,4,5, 6,7,8,9,10}; 41 | short b[] = {11,12,13,14,15, 16,17,18,19,20}; 42 | 43 | int main(int argc, char *argv[]) { 44 | 45 | short c = test(a,b); 46 | 47 | printf("result=%d",c); 48 | 49 | return 0; 50 | } 51 | 52 | Use Metaware compiler to optimize the C code with and without DSP extension options, and analyze the assembly code. 53 | 54 | Principles 55 | ------------------------------------ 56 | 57 | This section describes compiler options in MetaWare used in this lab. 58 | 59 | To optimize code with DSP extensions, two sets of compiler options are used throughout the lab: DSP Extensions options and optimization level. 60 | 61 | DSP Extensions Options 62 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | 64 | Use |embarc| build system to compile the code. The details can be found in |embarc| document page. Here is the example command. You can pass extra compiler/liner options by ADT_COPT/ADT_LOPT. 65 | 66 | .. code-block:: console 67 | 68 | gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw ADT_COPT="-Hfxapi -Xdsp2" OLEVEL=O2 69 | 70 | Options that are used in the lab are: 71 | 72 | * ``-Xdsp[1/2]``: 73 | 74 | Enable DSP instructions 75 | 76 | * ``-Xdsp_complex, -Xdsp_divsqrt``: 77 | 78 | Enable complex arithmetic DSP, divide, and sqrt instructions 79 | 80 | * ``-Xdsp_ctrl[=up|convergent,noguard|guard, preshift|postshift]``: 81 | 82 | Fine-tune the compiler's assumptions about the rounding, guard-bit, and fractional product shift behavior 83 | 84 | * ``-Hdsplib``: Link in the DSP library 85 | 86 | For programming ARC fixed-point DSP in C and C++ 87 | 88 | Contains functions to carry out DSP algorithms such as filtering and transforms 89 | 90 | * ``-Hfxapi``: Use the Fixed Point API support library 91 | 92 | Used with ``-Xdsp``. Provides low level intrinsic support for ARC EM DSP instructions 93 | 94 | Programs written using this API execute natively on an ARC EM processor with DSP extensions and can also be emulated on x86 Windows hosts 95 | 96 | * ``-Xxy``: Specifies that XY memory is available 97 | 98 | Used with ``-Xdsp2``. Enables optimization for XY memory 99 | 100 | * ``-Xagu_small, -Xagu_medium, -Xagu_large``: 101 | 102 | Enables AGU, and specifies its size 103 | 104 | .. note:: 105 | 106 | Because ARC is configurable processor, different cores can contain different extensions on hardware level. Therefore, options set for compiler should match underlying hardware. On the other hand, if specific hardware feature is present in the core but compiler option is not set, it cannot be used effectively, if used at all. IOTDK Core default options are presented in tcf file. 107 | 108 | Optimization level 109 | ^^^^^^^^^^^^^^^^^^^^ 110 | 111 | MetaWare compiler has different optimization levels, which enables or disables various optimization techniques included in the compiler. You can pass the optimization option to gmake by "OLEVEL=O2". 112 | 113 | The lowest level is the default -O0, which does little optimization to the compiled assembly code, which can be used for debugging, because in un-optimized assembly code all source code commands have 1:1 representation. On the other hand, -O3 highest level optimization highly modifies output assembly code to make it smaller and fast, but debugging such a code is harder, because it is not close match with source code. Also, high level of optimization requires longer compilation time, which for large project can be significant, if many compilation iterations are to be made. 114 | 115 | Optimization for DSP extensions 116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 117 | 118 | A regular code without direct usage of DSP extensions can be optimized to use DSP extensions wherever applicable, which compiler can do automatically with DSP extension options corresponding to hardware are set and high-level of optimization is selected. 119 | 120 | Steps 121 | -------------------------- 122 | 123 | 1. Compiling with option -O0, DSP extensions will be specified in TCF file 124 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 125 | 126 | Below is the list of options used when launching gmake: 127 | 128 | ``gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw OLEVEL=O0`` 129 | 130 | You can use the following command to generate disassembly code, and check assembly code for function "test". 131 | 132 | ``elfdump -T -S /obj_iotdk_10/mw_arcem9d/dsp_lab1_mw_arcem9d.elf`` 133 | 134 | Notice assembly code in the disassembled output. See how many assembly instruction are used for each line. For example, for loop spends several instruction to calculate loop variable value and check whether to stop. 135 | 136 | |dsp_figure_1.1| 137 | 138 | 2. Compiling with DSP extensions, with -O2 139 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 140 | 141 | Compile with: 142 | 143 | ``gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw OLEVEL=O2`` 144 | 145 | Adding optimization level -O2, optimizes out many of the instructions: 146 | 147 | |dsp_figure_1.2| 148 | 149 | In this code it is easy to find zero-delay loop ("lp" command) which acts as for loop. Note that multiply-accumulate is done with separate "mpyw_s" and "add1_s" instructions. 150 | 151 | 3. Compiling with DSP extensions, with -O3 152 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 153 | 154 | Compile with: 155 | 156 | ``gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw OLEVEL=O3`` 157 | 158 | Adding -Xdsp1 (optimization level changed to -O3) helps compiler to optimize away "mpyw_s" and "add1_s" instructions and replace them with hardware dual-16bit SIMD multilication "vmpy2h". Notice the loop count is now 5. 159 | 160 | |dsp_figure_1.3| 161 | 162 | Exercises 163 | ----------------------------------------------- 164 | 165 | Remove "<<1" from test function and see changes in the output instructions. 166 | 167 | .. |dsp_figure_1.1| image:: /img/dsp_figure_1.1.png 168 | .. |dsp_figure_1.2| image:: /img/dsp_figure_1.2.png 169 | .. |dsp_figure_1.3| image:: /img/dsp_figure_1.3.png 170 | -------------------------------------------------------------------------------- /doc/documents/labs/level2/lab_dsp2.rst: -------------------------------------------------------------------------------- 1 | .. _lab_dsp2: 2 | 3 | ARC DSP: Using FXAPI 4 | ============================= 5 | 6 | Purpose 7 | ------------------------ 8 | - To understand what is ARC Fixed-point API (FXAPI) 9 | - To learn how to use FXAPI to optimize DSP programs 10 | 11 | Requirements 12 | ---------------------------- 13 | The following hardware and tools are required: 14 | 15 | * PC host 16 | * |mwdt| 17 | * ARC board (|emsk| / |iotdk|) 18 | * ``embarc_osp/arc_labs/labs/dsp_lab_fxapi`` 19 | 20 | Content 21 | -------------------------------- 22 | This lab uses complex number multiplication as an example where using just compiler optimization options cannot gain the same effect as calling DSP instructions manually through FXAPI. 23 | 24 | Principle 25 | -------------------------------- 26 | In this lab two implementations of complex multiplication are shown with and without FXAPI. 27 | 28 | Complex number multiplication 29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 30 | 31 | Multiplication of two complex numbers 32 | |dsp_icon_2.1| 33 | and 34 | |dsp_icon_2.2| 35 | 36 | Is done using formula: 37 | 38 | |dsp_icon_2.3| 39 | 40 | In this lab example multiplication and accumulation of two arrays of complex numbers are used as a way to compare performance of ARC DSP extensions when used effectively. 41 | 42 | The sum of element wise products of two arrays of complex numbers is calculated according to the following formula: 43 | 44 | |dsp_icon_2.4| 45 | 46 | where a and b are arrays of N complex numbers. 47 | 48 | Implementation without DSP 49 | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 50 | 51 | In order to calculate element wise products of two arrays of complex numbers, a struct can be defined that stores real and imaginary parts of the complex number. Therefore, the calculation process receives an array of structures and works on it. The code is shown below: 52 | 53 | .. code-block:: c 54 | 55 | typedef struct { short real; short imag; } complex_short; 56 | 57 | complex_short short_complex_array_mult (complex_short *a, complex_short *b, int size) { 58 | complex_short result = {0,0}; 59 | int acci=0; 60 | int accr=0; 61 | 62 | for (int i=0; i < size; i++) { 63 | accr += (int) ( a[i].real * b[i].real ); 64 | accr -= (int) ( a[i].imag * b[i].imag ); 65 | 66 | acci += (int) ( a[i].real * b[i].imag ); 67 | acci += (int) ( a[i].imag * b[i].real ); 68 | } 69 | 70 | result.real = (short) accr; 71 | result.imag = (short) acci; 72 | 73 | return result; 74 | } 75 | 76 | The example keeps real and imaginary values in variables of type "short", while multiplication results are kept in "int" integer to avoid truncation. Final result is casted to short to return complex number as a result. 77 | 78 | Implementation with FXAPI 79 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 80 | 81 | FXAPI makes it possible to directly access complex number instructions (like MAC) available in ARC DSP Extensions. This is done through complex number type cq15_t, and various fx_* functions. Here ``fx_v2a40_cmac_cq15`` FXAPI function is called which performs MAC of two cq15_t complex numbers. 82 | 83 | .. code-block:: c 84 | 85 | cq15_t fx_complex_array_mult(cq15_t *a, cq15_t *b, int size) { 86 | v2accum40_t acc = { 0, 0 }; 87 | 88 | for (int i=0; i < size; i++) { 89 | acc = fx_v2a40_cmac_cq15(acc, *a++, *b++); 90 | } 91 | 92 | return fx_cq15_cast_v2a40( acc ); 93 | } 94 | 95 | As with previous implementation ``q15_t`` is of similar size as ``short`` type, therefore, multiplication result needs larger storage. Here 40b vector accumulator is used directly to store intermediate results of MAC, and is casted to ``cq15_t`` on return. 96 | 97 | Using |iotdk| board for performance comparison 98 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 99 | 100 | To compare performance of these two functions a simple application is created that performs complex array multiplication using either of the implementations above. The program initializes two arrays of complex numbers with random values and calls functions above in a loop (1 000 000-10 000 000 times) to make calculation delay measurable in seconds. This is done eight times, and after each loop a LED on board turns-on. In the result, LED strip on board works as a "progress bar" showing the process of looped multiplications. 101 | 102 | The main performance check loop is shown in the following example. The outer loop runs 8 times (number of LEDs on LED strip), the inner loop makes "LOOPS/8" calls to complex multiplication function. LOOPS variable is configurable to change the total delay. 103 | 104 | Steps 105 | ------------ 106 | 107 | To test the following example, some modification of the code is required to have two loops with and without DSP. 108 | 109 | Firstly you must build DSP libraries for this particular configuration of IOTDK: 110 | 111 | ``buildlib my_dsp -tcf= -bd ../ -f`` 112 | 113 | |iotdk| tcf file can be found in ``embarc_osp/board/iotdk/configs/10/tcf/arcem9d.tcf`` 114 | 115 | Both examples are to be compiled with DSP extensions. 116 | 117 | 1. Run program without FXAPI 118 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 119 | 120 | Build with the command: 121 | 122 | ``gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw gui ADT_COPT="-Hdsplib" ADT_LOPT="-Hdsplib -Hlib=../my_dsp"`` 123 | 124 | With high optimization level functions using "short" type is compiled to use DSP MAC operation, enabling significant speedup. 125 | 126 | |dsp_figure_2.1| 127 | 128 | 2. Run program with FXAPI 129 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 130 | 131 | Rename main.c.fxapi to main.c, then execute the command: 132 | 133 | ``gmake BOARD=iotdk BD_VER=10 CUR_CORE=arcem9d TOOLCHAIN=mw gui ADT_COPT="-Hdsplib" ADT_LOPT="-Hdsplib -Hlib=../my_dsp"`` 134 | 135 | However, using FXAPI enables compiler to directly use complex MAC instruction "cmachfr". 136 | 137 | |dsp_figure_2.2| 138 | 139 | .. |dsp_icon_2.1| image:: /img/dsp_icon_2.1.png 140 | .. |dsp_icon_2.2| image:: /img/dsp_icon_2.2.png 141 | .. |dsp_icon_2.3| image:: /img/dsp_icon_2.3.png 142 | .. |dsp_icon_2.4| image:: /img/dsp_icon_2.4.png 143 | 144 | .. |dsp_figure_2.1| image:: /img/dsp_figure_2.1.png 145 | .. |dsp_figure_2.2| image:: /img/dsp_figure_2.2.png 146 | -------------------------------------------------------------------------------- /doc/documents/labs/level3.rst: -------------------------------------------------------------------------------- 1 | .. _level3_labs: 2 | 3 | Exploration 4 | ############### 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | :glob: 9 | 10 | level3/* -------------------------------------------------------------------------------- /labs/dsp_lab1_compiler_opt/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2017, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | /** 32 | * \defgroup EMBARC_APP_BAREMETAL_BLINKY embARC Blinky Example 33 | * \ingroup EMBARC_APPS_TOTAL 34 | * \ingroup EMBARC_APPS_BAREMETAL 35 | * \brief embARC example for toggle leds on board 36 | * 37 | * \details 38 | * ### Extra Required Tools 39 | * 40 | * ### Extra Required Peripherals 41 | * 42 | * ### Design Concept 43 | * This example is designed to test board without any extra peripheral 44 | * 45 | * ### Usage Manual 46 | * Toggle all leds on board in 1s period 47 | * 48 | * ### Extra Comments 49 | * 50 | */ 51 | 52 | /** 53 | * \file 54 | * \ingroup EMBARC_APP_BAREMETAL_BLINKY 55 | * \brief main source file for blinky example 56 | */ 57 | 58 | /** 59 | * \addtogroup EMBARC_APP_BAREMETAL_BLINKY 60 | * @{ 61 | */ 62 | /* embARC HAL */ 63 | #include "embARC.h" 64 | #include "embARC_debug.h" 65 | 66 | #define LED_TOGGLE_MASK BOARD_LED_MASK 67 | 68 | /** 69 | * \brief Test hardware board without any peripheral 70 | */ 71 | short test(short *a, short *b) { 72 | int i; 73 | 74 | long acc = 0; 75 | for(i = 0; i < 10; i++) 76 | acc += ( ((long)(*a++)) * *b++) <<1 ; 77 | 78 | return (short) (acc); 79 | } 80 | 81 | short a[] = {1,2,3,4,5, 6,7,8,9,10}; 82 | short b[] = {11,12,13,14,15, 16,17,18,19,20}; 83 | 84 | int main(void) 85 | { 86 | EMBARC_PRINTF("LAB 1\r\n"); 87 | 88 | short c = test(a,b); 89 | 90 | EMBARC_PRINTF("result=%d",c); 91 | 92 | return 0; 93 | } 94 | 95 | /** @} */ 96 | -------------------------------------------------------------------------------- /labs/dsp_lab1_compiler_opt/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= dsp_lab1 3 | 4 | # 5 | # root dir of embARC 6 | # 7 | EMBARC_ROOT = ../../.. 8 | 9 | MID_SEL = common 10 | 11 | # application source dirs 12 | APPL_CSRC_DIR = . 13 | APPL_ASMSRC_DIR = . 14 | 15 | # application include dirs 16 | APPL_INC_DIR = . 17 | 18 | # include current project makefile 19 | COMMON_COMPILE_PREREQUISITES += makefile 20 | 21 | ### Options above must be added before include options.mk ### 22 | # include key embARC build system makefile 23 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 24 | include $(EMBARC_ROOT)/options/options.mk 25 | -------------------------------------------------------------------------------- /labs/dsp_lab2_fxapi/main.c: -------------------------------------------------------------------------------- 1 | //#include 2 | #include "embARC.h" 3 | #include "embARC_debug.h" 4 | #include "fxarc.h" 5 | 6 | typedef struct { short real; short imag; } complex_short; 7 | 8 | cq15_t fx_complex_array_mult (cq15_t *a, cq15_t *b, int size); 9 | complex_short short_complex_array_mult (complex_short *a, complex_short *b, int size); 10 | 11 | #define LOOPS 10000000 12 | //__xy cq15_t cq15_a[20] = {{0x2000,10},{0x100,20},{4,30}}; 13 | //__xy cq15_t cq15_b[20] = {{0x2000,11},{0x100,21},{5,31}}; 14 | //__xy cq15_t res; 15 | 16 | volatile complex_short cq15_a[20] = {{0x2000,10},{0x100,20},{4,30}}; 17 | volatile complex_short cq15_b[20] = {{0x2000,11},{0x100,21},{5,31}}; 18 | volatile complex_short res; 19 | 20 | int main(int argc, char *argv[]) { 21 | unsigned int led_status = 0x40 ; 22 | 23 | 24 | 25 | EMBARC_PRINTF("LAB 2\r\n"); 26 | led_status = 0x7F; 27 | 28 | for (int i =0; i< 8; i++) { 29 | for (int j = 1; j < LOOPS/8; j++ ) { 30 | //res = fx_complex_array_mult(cq15_a, cq15_b, 20); 31 | res = short_complex_array_mult(cq15_a, cq15_b, 20); 32 | }; 33 | led_write(led_status, BOARD_LED_MASK); 34 | led_status = led_status >> 1; 35 | } 36 | // EMBARC_PRINTF("res.real=%d \r\n", res[0]); 37 | EMBARC_PRINTF("res.real=%d \r\n", res.real); 38 | return 0; 39 | } 40 | complex_short short_complex_array_mult (complex_short *a, complex_short *b, int size) { 41 | complex_short result = {0,0}; 42 | int acci=0; 43 | int accr=0; 44 | 45 | for (int i=0; i < size; i++) { 46 | accr += (int) ( a[i].real * b[i].real ); 47 | accr -= (int) ( a[i].imag * b[i].imag ); 48 | 49 | acci += (int) ( a[i].real * b[i].imag ); 50 | acci += (int) ( a[i].imag * b[i].real ); 51 | } 52 | 53 | result.real = (short) accr; 54 | result.imag = (short) acci; 55 | 56 | return result; 57 | } 58 | 59 | cq15_t fx_complex_array_mult(cq15_t *a, cq15_t *b, int size) { 60 | v2accum40_t acc = { 0, 0 }; 61 | 62 | for (int i=0; i < size; i++) { 63 | acc = fx_v2a40_cmac_cq15(acc, *a++, *b++); 64 | } 65 | 66 | return fx_cq15_cast_v2a40( acc ); 67 | } 68 | 69 | /** @} */ 70 | -------------------------------------------------------------------------------- /labs/dsp_lab2_fxapi/main.c.fxapi: -------------------------------------------------------------------------------- 1 | //#include 2 | #include "embARC.h" 3 | #include "embARC_debug.h" 4 | #include "fxarc.h" 5 | 6 | typedef struct { short real; short imag; } complex_short; 7 | 8 | cq15_t fx_complex_array_mult (cq15_t *a, cq15_t *b, int size); 9 | complex_short short_complex_array_mult (complex_short *a, complex_short *b, int size); 10 | 11 | #define LOOPS 10000000 12 | __xy cq15_t cq15_a[20] = {{0x2000,10},{0x100,20},{4,30}}; 13 | __xy cq15_t cq15_b[20] = {{0x2000,11},{0x100,21},{5,31}}; 14 | __xy cq15_t res; 15 | 16 | //volatile complex_short cq15_a[20] = {{0x2000,10},{0x100,20},{4,30}}; 17 | //volatile complex_short cq15_b[20] = {{0x2000,11},{0x100,21},{5,31}}; 18 | //volatile complex_short res; 19 | 20 | int main(int argc, char *argv[]) { 21 | unsigned int led_status = 0x40 ; 22 | 23 | 24 | 25 | EMBARC_PRINTF("LAB 2\r\n"); 26 | led_status = 0x7F; 27 | 28 | for (int i =0; i< 8; i++) { 29 | for (int j = 1; j < LOOPS/8; j++ ) { 30 | res = fx_complex_array_mult(cq15_a, cq15_b, 20); 31 | //res = short_complex_array_mult(cq15_a, cq15_b, 20); 32 | }; 33 | led_write(led_status, BOARD_LED_MASK); 34 | led_status = led_status >> 1; 35 | } 36 | EMBARC_PRINTF("res.real=%d \r\n", res[0]); 37 | // EMBARC_PRINTF("res.real=%d \r\n", res.real); 38 | return 0; 39 | } 40 | complex_short short_complex_array_mult (complex_short *a, complex_short *b, int size) { 41 | complex_short result = {0,0}; 42 | int acci=0; 43 | int accr=0; 44 | 45 | for (int i=0; i < size; i++) { 46 | accr += (int) ( a[i].real * b[i].real ); 47 | accr -= (int) ( a[i].imag * b[i].imag ); 48 | 49 | acci += (int) ( a[i].real * b[i].imag ); 50 | acci += (int) ( a[i].imag * b[i].real ); 51 | } 52 | 53 | result.real = (short) accr; 54 | result.imag = (short) acci; 55 | 56 | return result; 57 | } 58 | 59 | cq15_t fx_complex_array_mult(cq15_t *a, cq15_t *b, int size) { 60 | v2accum40_t acc = { 0, 0 }; 61 | 62 | for (int i=0; i < size; i++) { 63 | acc = fx_v2a40_cmac_cq15(acc, *a++, *b++); 64 | } 65 | 66 | return fx_cq15_cast_v2a40( acc ); 67 | } 68 | 69 | /** @} */ 70 | -------------------------------------------------------------------------------- /labs/dsp_lab2_fxapi/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= dsp_lab2 3 | 4 | # 5 | # root dir of embARC 6 | # 7 | EMBARC_ROOT = ../../.. 8 | 9 | MID_SEL = common 10 | 11 | # application source dirs 12 | APPL_CSRC_DIR = . 13 | APPL_ASMSRC_DIR = . 14 | 15 | # application include dirs 16 | APPL_INC_DIR = . 17 | 18 | # include current project makefile 19 | COMMON_COMPILE_PREREQUISITES += makefile 20 | 21 | ### Options above must be added before include options.mk ### 22 | # include key embARC build system makefile 23 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 24 | include $(EMBARC_ROOT)/options/options.mk 25 | -------------------------------------------------------------------------------- /labs/dsp_lab3_dsp_lib/dsp_matrix_mul.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************/ 2 | /*************************************************************************/ 3 | /** **/ 4 | /** Copyright (C) 1989-2015 Synopsys, Inc. **/ 5 | /** All Rights Reserved. **/ 6 | /** **/ 7 | /** SYNOPSYS CONFIDENTIAL **/ 8 | /** **/ 9 | /** This is an unpublished proprietary work of Synopsys, Inc., and is **/ 10 | /** fully protected under copyright and trade secret laws. You may not **/ 11 | /** view, use, disclose, copy, or distribute this file or any **/ 12 | /** information contained herein except pursuant to a valid written **/ 13 | /** license from Synopsys. **/ 14 | /** **/ 15 | /** For more information, contact **/ 16 | /** est-adm@synopsys.com or call (650) 584-1631 **/ 17 | /** **/ 18 | /*************************************************************************/ 19 | /*************************************************************************/ 20 | #include 21 | 22 | #include "starter.h" 23 | #include "board.h" 24 | 25 | /* 26 | * This program calculates dot product of 2 square matrices to measure 27 | * speed of operations with and without processor DSP extension. 28 | * 29 | * For the sake of speed test, matrix multiplication is done for number of times (LOOPs). 30 | * Total number of multiplications is divided into 8 parts. After each part of 31 | * multiplications is done, a led on the EMSK board is switched on. This 32 | * process is repeated 8 times until all leds are on. The led strip in this way 33 | * stands as a "progress bar" of operations. 34 | * 35 | * Matrix multiplication is done with naive O(n^3) algorithm. 36 | * Thus in total LOOP*(MATRIX_SIZE^3) multiplications are done. 37 | * 38 | * When program starts, two input matrices are initialized with random numbers 39 | * and then multiplied. 40 | * ------------------------------------------------------------------------ 41 | * 42 | * The program should be compiled in two variants: 43 | * - with -O2 and -Xdsp1 options 44 | * - with -O2 option only 45 | * 46 | * and compared in speed. 47 | * 48 | * 49 | * Note: The program was tested on EMSK 2.1 board, with EM5D configuration. 50 | * 51 | */ 52 | 53 | 54 | /* 55 | * Program configuration (constants) 56 | * 57 | * LOOP - Total number of multiplications 58 | * MATRIX_SIZE - Square matrix size 59 | * MAX_NUM - Max with value up to constant. 60 | * 61 | */ 62 | #define MATRIX_SIZE 20 63 | #define MAX_NUM 1000 64 | #define LOOPS 1000 65 | 66 | /* ********************************************* */ 67 | 68 | /* Matrix manipulation functions */ 69 | 70 | /* randomize matrix with values up to 'max_value */ 71 | void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) ; 72 | 73 | /* multiply two square matrices of same size*/ 74 | void mul_sq_mat(short x[][MATRIX_SIZE], short y[][MATRIX_SIZE], short z[][MATRIX_SIZE], int size) ; 75 | 76 | /* print square matrix through UART*/ 77 | void print_sq_mat(short x[][MATRIX_SIZE], int SIZE, DWCREG_PTR uart); 78 | 79 | /* ********************************************* */ 80 | 81 | int main(int argc, char *argv[]) { 82 | 83 | DWCREG_PTR pctr = (DWCREG_PTR) (DWC_GPIO_0 | PERIPHERAL_BASE); 84 | DWCREG_PTR uart = (DWCREG_PTR) (DWC_UART_CONSOLE | PERIPHERAL_BASE); 85 | 86 | gpio_init(pctr); 87 | uart_initDevice(uart, UART_CFG_BAUDRATE_115200, UART_CFG_DATA_8BITS, UART_CFG_1STOP, UART_CFG_PARITY_NONE); 88 | 89 | short a[MATRIX_SIZE][MATRIX_SIZE]; 90 | short b[MATRIX_SIZE][MATRIX_SIZE]; 91 | short c[MATRIX_SIZE][MATRIX_SIZE]; 92 | int n =MATRIX_SIZE; 93 | 94 | rand_sq_mat(a,n, MAX_NUM); 95 | rand_sq_mat(b,n, MAX_NUM); 96 | 97 | print_sq_mat(a,n,uart); 98 | print_sq_mat(b,n,uart); 99 | 100 | unsigned int led_status = 0x40 ; 101 | led_status = 0x7F; 102 | 103 | uart_print(uart, "*** Start ***\n\r"); 104 | 105 | for (int i =0; i< 8; i++) { 106 | gpio_set_leds(pctr, led_status); 107 | 108 | for (int j = 1; j < LOOPS/8; j++ ) { 109 | mul_sq_mat(a,b,c,n); 110 | }; 111 | 112 | 113 | led_status = led_status >> 1; 114 | } 115 | 116 | print_sq_mat(c,n,uart); 117 | gpio_set_leds(pctr, 0x01ff); 118 | 119 | uart_print(uart, "*** Exit ***\n\r"); 120 | 121 | return 0; 122 | } 123 | 124 | 125 | 126 | void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) { 127 | for (int i=0;i 4 | 5 | #define MATRIX_SIZE 20 6 | #define MAX_NUM 1000 7 | #define LOOPS 100000 8 | 9 | /* ********************************************* */ 10 | 11 | /* Matrix manipulation functions */ 12 | 13 | /* randomize matrix with values up to 'max_value */ 14 | void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) ; 15 | 16 | /* multiply two square matrices of same size*/ 17 | void mul_sq_mat(short x[][MATRIX_SIZE], short y[][MATRIX_SIZE], short z[][MATRIX_SIZE], int size) ; 18 | 19 | /* print square matrix through UART*/ 20 | void print_sq_mat(short x[][MATRIX_SIZE], int SIZE); 21 | 22 | /* ********************************************* */ 23 | 24 | int main(int argc, char *argv[]) { 25 | 26 | short a[MATRIX_SIZE][MATRIX_SIZE]; 27 | short b[MATRIX_SIZE][MATRIX_SIZE]; 28 | short c[MATRIX_SIZE][MATRIX_SIZE]; 29 | int n =MATRIX_SIZE; 30 | 31 | rand_sq_mat(a,n, MAX_NUM); 32 | rand_sq_mat(b,n, MAX_NUM); 33 | 34 | print_sq_mat(a,n); 35 | print_sq_mat(b,n); 36 | 37 | unsigned int led_status = 0x40 ; 38 | led_status = 0x7F; 39 | 40 | EMBARC_PRINTF("*** Start ***\n\r"); 41 | 42 | for (int i =0; i< 8; i++) { 43 | for (int j = 1; j < LOOPS/8; j++ ) { 44 | mul_sq_mat(a,b,c,n); 45 | }; 46 | led_write(led_status, BOARD_LED_MASK); 47 | led_status = led_status >> 1; 48 | } 49 | 50 | print_sq_mat(c,n); 51 | 52 | EMBARC_PRINTF("*** Exit ***\n\r"); 53 | 54 | return 0; 55 | } 56 | 57 | 58 | 59 | void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) { 60 | for (int i=0;i 4 | #include "dsplib.h" 5 | 6 | #define MATRIX_SIZE 20 7 | #define MAX_NUM 1000 8 | #define LOOPS 100000 9 | 10 | /* ********************************************* */ 11 | 12 | /* Matrix manipulation functions */ 13 | 14 | /* randomize matrix with values up to 'max_value */ 15 | //void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) ; 16 | 17 | /* multiply two square matrices of same size*/ 18 | void mul_sq_mat(short x[][MATRIX_SIZE], short y[][MATRIX_SIZE], short z[][MATRIX_SIZE], int size) ; 19 | 20 | /* print square matrix through UART*/ 21 | void print_sq_mat(short* x, int SIZE); 22 | 23 | /* ********************************************* */ 24 | __xy q15_t a[MATRIX_SIZE*MATRIX_SIZE]; 25 | __xy q15_t b[MATRIX_SIZE*MATRIX_SIZE]; 26 | __xy q15_t c[MATRIX_SIZE*MATRIX_SIZE]; 27 | 28 | int main(int argc, char *argv[]) { 29 | 30 | int n =MATRIX_SIZE; 31 | matrix_q15_t matA, matB, matC; 32 | 33 | //rand_sq_mat(a,n, MAX_NUM); 34 | //rand_sq_mat(b,n, MAX_NUM); 35 | for (int i =0; i< MATRIX_SIZE*MATRIX_SIZE; i++) { a[i]=16384; } 36 | for (int i =0; i< MATRIX_SIZE*MATRIX_SIZE; i++) { b[i]=16383; } 37 | 38 | 39 | print_sq_mat(a,n); 40 | print_sq_mat(b,n); 41 | 42 | dsp_mat_init_q15(&matA, MATRIX_SIZE, MATRIX_SIZE, a); 43 | dsp_mat_init_q15(&matB, MATRIX_SIZE, MATRIX_SIZE, b); 44 | dsp_mat_init_q15(&matC, MATRIX_SIZE, MATRIX_SIZE, c); 45 | dsp_status status; 46 | 47 | unsigned int led_status = 0x40 ; 48 | led_status = 0x7F; 49 | 50 | EMBARC_PRINTF("*** Start ***\n\r"); 51 | 52 | for (int i =0; i< 8; i++) { 53 | for (int j = 1; j < LOOPS/8; j++ ) { 54 | status = dsp_mat_mult_q15(&matA, &matB, &matC); 55 | }; 56 | led_write(led_status, BOARD_LED_MASK); 57 | led_status = led_status >> 1; 58 | } 59 | 60 | if ( status == DSP_ERR_OK ) EMBARC_PRINTF("done\n"); 61 | else EMBARC_PRINTF("something wrong"); 62 | print_sq_mat(c,n); 63 | 64 | EMBARC_PRINTF("*** Exit ***\n\r"); 65 | 66 | return 0; 67 | } 68 | 69 | 70 | 71 | //void rand_sq_mat(short x[][MATRIX_SIZE], int SIZE, int max_value) { 72 | // for (int i=0;i>!AND MODIFIED BY!<< the FreeRTOS exception. 26 | 27 | >>! NOTE: The modification to the GPL is included to allow you to distribute 28 | >>! a combined work that includes FreeRTOS without being obliged to provide 29 | >>! the source code for proprietary components outside of the FreeRTOS 30 | >>! kernel. 31 | 32 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 33 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 34 | FOR A PARTICULAR PURPOSE. Full license text is available from the following 35 | link: http://www.freertos.org/a00114.html 36 | 37 | 1 tab == 4 spaces! 38 | 39 | *************************************************************************** 40 | * * 41 | * Having a problem? Start by reading the FAQ "My application does * 42 | * not run, what could be wrong?" * 43 | * * 44 | * http://www.FreeRTOS.org/FAQHelp.html * 45 | * * 46 | *************************************************************************** 47 | 48 | http://www.FreeRTOS.org - Documentation, books, training, latest versions, 49 | license and Real Time Engineers Ltd. contact details. 50 | 51 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 52 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 53 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 54 | 55 | http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High 56 | Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS 57 | licenses offer ticketed support, indemnification and middleware. 58 | 59 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 60 | engineered and independently SIL3 certified version for use in safety and 61 | mission critical applications that require provable dependability. 62 | 63 | 1 tab == 4 spaces! 64 | */ 65 | 66 | #ifndef FREERTOS_CONFIG_H 67 | #define FREERTOS_CONFIG_H 68 | 69 | #include 70 | /*----------------------------------------------------------- 71 | * Application specific definitions. 72 | * 73 | * These definitions should be adjusted for your particular hardware and 74 | * application requirements. 75 | * 76 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 77 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 78 | * 79 | * See http://www.freertos.org/a00110.html. 80 | *----------------------------------------------------------*/ 81 | 82 | #define configUSE_PREEMPTION 1 83 | #define configUSE_IDLE_HOOK 0 84 | #define configUSE_TICK_HOOK 0 85 | #define configCPU_CLOCK_HZ ( ( unsigned long ) BOARD_CPU_CLOCK ) 86 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) 87 | #define configMAX_PRIORITIES ( 10 ) 88 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 104 ) 89 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16 * 1024 ) ) 90 | #define configMAX_TASK_NAME_LEN ( 10 ) 91 | #define configUSE_TRACE_FACILITY 0 92 | #define configUSE_16_BIT_TICKS 0 93 | #define configIDLE_SHOULD_YIELD 1 94 | #define configUSE_MUTEXES 1 95 | 96 | /* Co-routine definitions. */ 97 | #define configUSE_CO_ROUTINES 0 98 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 99 | 100 | 101 | /* Set the following definitions to 1 to include the API function, or zero 102 | to exclude the API function. */ 103 | 104 | #define INCLUDE_vTaskPrioritySet 1 105 | #define INCLUDE_uxTaskPriorityGet 1 106 | #define INCLUDE_vTaskDelete 1 107 | #define INCLUDE_vTaskCleanUpResources 0 108 | #define INCLUDE_vTaskSuspend 1 109 | #define INCLUDE_vTaskDelayUntil 1 110 | #define INCLUDE_vTaskDelay 1 111 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 112 | 113 | #endif /* FREERTOS_CONFIG_H */ -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/README.rst: -------------------------------------------------------------------------------- 1 | .. _example_esp8266_wifi: 2 | 3 | ESP8266 WiFi Module 4 | #################### 5 | 6 | Overview 7 | ******** 8 | 9 | This example is designed to show basic usage of ESP01/ESP01S esp8266 WiFi Module on embARC board. 10 | 11 | Detailed Description 12 | ==================== 13 | 14 | * Extra Required Peripherals 15 | ESP01/ESP01S WiFi Module 16 | 17 | * Design Concept 18 | Without downloading users' image, ESP01/ESP01S can be controlled using AT commands. 19 | This example is designed to show how to use AT commands to control the Wi-Fi module and exchange data. 20 | Besides, we use AT command to establish a TCP server and provide simple HTTP service just like our another example :ref:`example_net_httpserver` 21 | 22 | * Usage Manual 23 | - Connect ESP01/ESP01S module to your board, see :ref:`peripheral_preparation`. 24 | - Set up an AP, the default setting of this example is to connect a WIFI with SSID: `embARC`, pwd: `qazwsxedc`. 25 | - Build, download, run the example and get log from COM port console. 26 | - When you see a `while` is shown in log, meaning that the server is setup and waiting for input. Then open your web browser (Chrome, Firefox) and visit the ip address shown in the log. You will get a web page right away. 27 | 28 | Building and Running 29 | ******************** 30 | 31 | This example outputs to the console. It is supported by all platform. The commands to run this example are as follows: 32 | 33 | .. code-block:: console 34 | 35 | $ cd /example/freertos/esp8266_wifi 36 | $ make BOARD=emsk BD_VER=22 CUR_CORE=arcem7d TOOLCHAIN=gnu run 37 | 38 | 39 | Sample Output 40 | ============= 41 | 42 | .. code-block:: console 43 | 44 | ----------------------------------------------------------- 45 | ____ _ ____ 46 | | _ \ _____ _____ _ __ ___ __| | __ ) _ _ 47 | | |_) / _ \ \ /\ / / _ \ '__/ _ \/ _` | _ \| | | | 48 | | __/ (_) \ V V / __/ | | __/ (_| | |_) | |_| | 49 | |_| \___/ \_/\_/ \___|_| \___|\__,_|____/ \__, | 50 | |___/ 51 | _ _ ____ ____ 52 | ___ _ __ ___ | |__ / \ | _ \ / ___| 53 | / _ \ '_ ` _ \| '_ \ / _ \ | |_) | | 54 | | __/ | | | | | |_) / ___ \| _ <| |___ 55 | \___|_| |_| |_|_.__/_/ \_\_| \_\\____| 56 | ------------------------------------------------------------ 57 | 58 | embARC Build Time: Oct 17 2018, 15:25:42 59 | Compiler Version: Metaware, 4.2.1 Compatible Clang 4.0.1 (branches/release_40) 60 | =========================== Init ============================ 61 | [at_parser_init]56: obj->psio 0x800062c0 -> 0x80000f28 62 | [at_send_cmd]83: command is NULL, send AT test command 63 | [at_send_cmd]117: at_out: "AT 64 | " (4) 65 | [at_get_reply]137: "AT 66 | 67 | OK" (9) 68 | ============================ Set Mode ============================ 69 | [at_send_cmd]117: at_out: "AT+CWMODE_CUR? 70 | " (16) 71 | [at_get_reply]137: " 72 | AT+CWMODE_CUR? 73 | +CWMODE_CUR:1 74 | 75 | OK" (38) 76 | CWMODE_CUR = 1 77 | [at_send_cmd]117: at_out: "AT+CWMODE_CUR=3 78 | " (17) 79 | [at_get_reply]137: " 80 | AT+CWMODE_CUR=3 81 | 82 | OK" (24) 83 | ============================ Connect WiFi ============================ 84 | [at_send_cmd]117: at_out: "AT+CWLAP 85 | " (10) 86 | [at_get_reply]137: " 87 | AT+CWLAP 88 | +CWLAP:(3,"embARC",-61,"6a:ec:c5:cc:2f:3b",1,32767,0) 89 | +CWLAP:(5,"Synopsys",-91,"6c:f3:7f:a5:8a:e3",1,-49,0) 90 | +CWLAP:(0,"synopsys-guest",-81,"6c:f3:7f:a5:38:21",1,-47,0) 91 | +CWLAP:(5,"Synopsys",-81,"6c:f3:7f:a5:38:23",1,-47,0) 92 | +CWLAP:(3,"ClickShare-1871789077",-87,"28:24:ff:bf:2b:06",1,32767,0) 93 | +CWLAP:(0,"synopsys-guest",-91,"6c:f3:7f:a5:8a:e1",1,-47,0) 94 | +CWLAP:(5,"Synopsys",-86,"04:bd:88:5a:7c:42",6,-51,0) 95 | +CWLAP:(0,"synopsys-guest",-86,"04:bd:88:5a:7c:43",6,-51,0) 96 | +CWLAP:(0,"synopsys-guest",-73,"6c:f3:7f:a2:90:61",11,-54,0) 97 | +CWLAP:(5,"Synopsys",-71,"6c:f3:7f:a2:90:63",11,-56,0) 98 | +CWLAP:(3,"XKORAT - Mi",-71,"4c:49:e3:ba:95:80",11,-29,0) 99 | 100 | OK" (731) 101 | Searching for WIFI "embARC" ...... 102 | WIFI "embARC" found! Try to connect 103 | [at_send_cmd]117: at_out: "AT+CWMODE_CUR=1 104 | " (17) 105 | [at_get_reply]137: " 106 | AT+CWMODE_CUR=1 107 | 108 | OK" (24) 109 | [at_send_cmd]117: at_out: "AT+CWJAP_CUR="embARC","qazwsxedc" 110 | " (35) 111 | [at_get_reply]137: " 112 | AT+CWJAP_CUR="embARC","qazwsxedc" 113 | WIFI DISCONNECT 114 | WIFI CONNECTED 115 | WIFI GOT IP 116 | 117 | OK" (88) 118 | WIFI "embARC" connect succeed 119 | ============================ Connect Server ============================ 120 | [at_send_cmd]117: at_out: "AT+CIPMUX=1 121 | " (13) 122 | [at_get_reply]137: " 123 | AT+CIPMUX=1 124 | 125 | OK" (20) 126 | [at_send_cmd]117: at_out: "AT+CIPSERVER=1,80 127 | " (19) 128 | [at_get_reply]137: " 129 | AT+CIPSERVER=1,80 130 | no change 131 | 132 | OK" (37) 133 | ============================ Show IP ============================ 134 | [at_send_cmd]117: at_out: "AT+CIFSR 135 | " (10) 136 | [at_get_reply]137: " 137 | AT+CIFSR 138 | +CIFSR:STAIP,"192.168.137.96" 139 | +CIFSR:STAMAC,"5c:cf:7f:0c:27:d6" 140 | 141 | OK" (83) 142 | ============================ while ============================ 143 | ============================ send ============================ 144 | 145 | The message is: 146 | 0,CONNECT 147 | 1,CONNECT 148 | 149 | +IPD,0,383:GET / HTTP/1.1 150 | Host: 192.168.137.96 151 | Connection: keep-alive 152 | Upgrade-Insecure-Requests: 1 153 | User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 154 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 155 | Accept-Encoding: gzip, deflate 156 | Accept-Language: en-US,en;q=0.9 157 | 158 | 159 | Send Start 160 | [at_send_cmd]117: at_out: "AT+CIPSEND=0,44 161 | " (17) 162 | [at_get_reply]137: "AT+CIPSEND=0,44 163 | 164 | OK" (22) 165 | [at_get_reply]137: " 166 | > 167 | Recv 44 bytes 168 | 169 | SEND OK" (30) 170 | [at_send_cmd]117: at_out: "AT+CIPSEND=0,93 171 | " (17) 172 | [at_get_reply]137: " 173 | AT+CIPSEND=0,93 174 | 175 | OK" (24) 176 | [at_get_reply]137: " 177 | > 178 | Recv 93 bytes 179 | " (21) 180 | [at_send_cmd]117: at_out: "AT+CIPSEND=0,93 181 | " (17) 182 | [at_get_reply]137: "AT+CIPSEND=0,93 183 | busy s... 184 | " (29) 185 | [at_send_cmd]117: at_out: "AT+CIPCLOSE=0 186 | " (15) 187 | [at_get_reply]137: "AT+CIPCLOSE=0 188 | busy s... 189 | 190 | SEND OK" (36) 191 | Send Finish 192 | 193 | -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/at_parser.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC_error.h" 32 | #include "string.h" 33 | #include "board.h" 34 | #include "at_parser.h" 35 | //#include "embARC_error.h" 36 | 37 | #define DBG_MORE 38 | #include "embARC_debug.h" 39 | 40 | /* if \r\n is needed to be attached at the end of AT comand, define AT_ADD_POSTFIX 41 | * otherwise comment out this line 42 | */ 43 | #define AT_ADD_POSTFIX 44 | 45 | #define AT_PREFIX "AT" 46 | #define AT_POSTFIX "\r\n" 47 | 48 | #define AT_TIMENOW() OSP_GET_CUR_MS() 49 | 50 | #define AT_MAX_LEN 128 51 | #define AT_MAX_PARAMETER 8 52 | 53 | 54 | int32_t at_parser_init(AT_PARSER_DEF_PTR obj, uint32_t baudrate) 55 | { 56 | obj->psio = ez_sio_open(obj->uart_id, baudrate, AT_TX_BUFSIZE, AT_RX_BUFSIZE); 57 | dbg_printf(DBG_MORE_INFO, "[%s]%d: obj->psio 0x%x -> 0x%x\r\n", __FUNCTION__, __LINE__, obj->psio, *obj->psio); 58 | return (obj->psio != NULL) ? AT_OK : AT_ERROR; 59 | } 60 | 61 | void at_parser_deinit(AT_PARSER_DEF_PTR obj) 62 | { 63 | ez_sio_close(obj->psio); 64 | return; 65 | } 66 | 67 | int32_t at_read(AT_PARSER_DEF_PTR obj, char *buf, uint32_t cnt) 68 | { 69 | return ez_sio_read(obj->psio, buf, cnt); 70 | } 71 | 72 | int32_t at_write(AT_PARSER_DEF_PTR obj, char *buf, uint32_t cnt) 73 | { 74 | return ez_sio_write(obj->psio, buf, cnt); 75 | } 76 | 77 | /* 78 | * please use NULL as last parameter 79 | */ 80 | int32_t at_send_cmd(AT_PARSER_DEF_PTR obj, AT_MODE mode, AT_STRING command, ...) 81 | { 82 | va_list vl; 83 | char at_out[AT_MAX_LEN] = AT_PREFIX; 84 | char *str = command; 85 | 86 | if (str == NULL) { 87 | dbg_printf(DBG_MORE_INFO, "[%s]%d: command is NULL, send AT test command\r\n", __FUNCTION__, __LINE__); 88 | } else { 89 | strcat(at_out,"+"); 90 | strcat(at_out, command); 91 | 92 | switch (mode) { 93 | case AT_LIST: 94 | strcat(at_out, "=?"); 95 | break; 96 | 97 | case AT_READ: 98 | strcat(at_out, "?"); 99 | break; 100 | 101 | case AT_WRITE: 102 | strcat(at_out, "="); 103 | va_start(vl, command); 104 | 105 | for (int i = 0; i < AT_MAX_PARAMETER; i++) { 106 | str = va_arg(vl, AT_STRING); 107 | 108 | if (str == NULL) { 109 | break; 110 | } 111 | 112 | if (i != 0) { 113 | strcat(at_out, ","); 114 | } 115 | 116 | strcat(at_out, str); 117 | } 118 | 119 | va_end(vl); 120 | break; 121 | 122 | case AT_EXECUTE: 123 | default: 124 | break; 125 | } 126 | } 127 | 128 | #ifdef AT_ADD_POSTFIX 129 | strcat(at_out, AT_POSTFIX); 130 | #endif /*AT_ADD_POSTFIX*/ 131 | dbg_printf(DBG_LESS_INFO, "[%s]%d: at_out: \"%s\" (%d)\r\n", __FUNCTION__, __LINE__, at_out, strlen(at_out)); 132 | return at_write(obj, at_out, strlen(at_out)); 133 | } 134 | 135 | /* make sure the buf is large enough*/ 136 | int32_t at_get_reply(AT_PARSER_DEF_PTR obj, char *buf, uint32_t timeout) 137 | { 138 | uint32_t cur_ofs = 0; 139 | uint32_t read_cnt; 140 | uint32_t cur_time; 141 | cur_time = AT_TIMENOW(); 142 | 143 | do { 144 | read_cnt = at_read(obj, &buf[cur_ofs], 1); 145 | cur_ofs += read_cnt; 146 | buf[cur_ofs] = '\0'; 147 | 148 | if ((strstr(buf, AT_OK_STR)!= NULL) || (strstr(buf, AT_ERROR_STR)!= NULL)) { 149 | break; 150 | } 151 | } while ((AT_TIMENOW()-cur_time) < timeout); 152 | 153 | buf[cur_ofs] = '\0'; 154 | dbg_printf(DBG_LESS_INFO, "[%s]%d: \"%s\" (%d)\r\n", __FUNCTION__, __LINE__, buf, strlen(buf)); 155 | 156 | if (strstr(buf, AT_OK_STR)!= NULL) { 157 | return AT_OK; 158 | } 159 | 160 | return AT_ERROR; 161 | } 162 | 163 | int32_t at_test(AT_PARSER_DEF_PTR obj) 164 | { 165 | char rcv_buf[64]; 166 | at_send_cmd(obj, AT_LIST, NULL); 167 | return at_get_reply(obj, rcv_buf, AT_NORMAL_TIMEOUT); 168 | } 169 | 170 | -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/at_parser.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #ifndef _AT_PARSER_H_ 32 | #define _AT_PARSER_H_ 33 | 34 | #include "ez_sio.h" 35 | #include "embARC_error.h" 36 | 37 | #define AT_OK 0 38 | #define AT_ERROR -1 39 | #define AT_OK_STR "OK" 40 | #define AT_ERROR_STR "ERROR" 41 | 42 | #define AT_RX_BUFSIZE 512 43 | #define AT_TX_BUFSIZE 128 44 | 45 | #define AT_NORMAL_TIMEOUT 100 46 | #define AT_LONG_TIMEOUT 5000 47 | #define AT_EXTRA_TIMEOUT 20000 48 | 49 | typedef enum { 50 | AT_LIST, 51 | AT_READ, 52 | AT_WRITE, 53 | AT_EXECUTE 54 | } AT_MODE; 55 | 56 | typedef char *AT_STRING; 57 | 58 | /** AT_PARSER type */ 59 | typedef struct { 60 | uint32_t uart_id; 61 | EZ_SIO *psio; 62 | } AT_PARSER_DEF, *AT_PARSER_DEF_PTR; 63 | 64 | #define AT_PARSER_DEFINE(NAME, UART_ID) \ 65 | AT_PARSER_DEF __ ## NAME = { \ 66 | .uart_id = UART_ID, \ 67 | .psio = NULL, \ 68 | }; \ 69 | AT_PARSER_DEF_PTR NAME = &__ ## NAME 70 | 71 | int32_t at_parser_init(AT_PARSER_DEF_PTR obj, uint32_t baudrate); 72 | void at_parser_deinit(AT_PARSER_DEF_PTR obj); 73 | int32_t at_read(AT_PARSER_DEF_PTR obj, char *buf, uint32_t cnt); 74 | int32_t at_write(AT_PARSER_DEF_PTR obj, char *buf, uint32_t cnt); 75 | int32_t at_send_cmd(AT_PARSER_DEF_PTR obj, AT_MODE mode, AT_STRING command, ...); 76 | int32_t at_get_reply(AT_PARSER_DEF_PTR obj, char *buf, uint32_t timeout); 77 | 78 | int32_t at_test(AT_PARSER_DEF_PTR obj); 79 | 80 | #endif /*_AT_PARSER_H_*/ -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/esp8266.h: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #ifndef _ESP8266_H_ 32 | #define _ESP8266_H_ 33 | 34 | #include "at_parser.h" 35 | #include "board.h" 36 | 37 | 38 | /** uart id which HM-10 BLE uses */ 39 | #if defined(BOARD_EMSK) 40 | #define ESP8266_UART_ID DW_UART_0_ID 41 | #else 42 | #define ESP8266_UART_ID DFSS_UART_1_ID 43 | #endif 44 | 45 | typedef enum{ 46 | ESP8266_STA=1, 47 | ESP8266_AP, 48 | ESP8266_AP_STA 49 | }ESP8266_WIFI_MODE; 50 | 51 | typedef enum{ 52 | ESP8266_NORMALSEND=0, 53 | ESP8266_PASSTHR 54 | }ESP8266_TRANS_MODE; 55 | 56 | typedef struct{ 57 | AT_PARSER_DEF_PTR p_at; 58 | //add other members here if needed 59 | bool wifi_connected; 60 | ESP8266_TRANS_MODE trans_mode; 61 | }ESP8266_DEF, *ESP8266_DEF_PTR; 62 | 63 | #define ESP8266_DEFINE(NAME) \ 64 | ESP8266_DEF __ ## NAME = { \ 65 | .p_at = NULL, \ 66 | }; \ 67 | ESP8266_DEF_PTR NAME = &__ ## NAME 68 | 69 | int32_t esp8266_init(ESP8266_DEF_PTR obj, uint32_t baudrate); 70 | void esp8266_deinit(ESP8266_DEF_PTR obj); 71 | int32_t esp8266_test(ESP8266_DEF_PTR obj); 72 | 73 | int32_t esp8266_wifi_mode_get(ESP8266_DEF_PTR obj, bool flash); 74 | int32_t esp8266_wifi_mode_set(ESP8266_DEF_PTR obj, ESP8266_WIFI_MODE, bool flash); 75 | int32_t esp8266_wifi_scan(ESP8266_DEF_PTR obj, char * rcv_buf); 76 | int32_t esp8266_wifi_connect(ESP8266_DEF_PTR obj, AT_STRING ssid, AT_STRING pwd, bool flash); 77 | int32_t esp8266_wifi_disconnect(ESP8266_DEF_PTR obj); 78 | int32_t esp8266_address_get(ESP8266_DEF_PTR obj); 79 | int32_t esp8266_conn_status(ESP8266_DEF_PTR obj); 80 | 81 | int32_t esp8266_dns_lookup(ESP8266_DEF_PTR obj, char * domain_ip, AT_STRING domain_name); 82 | int32_t esp8266_tcp_connect(ESP8266_DEF_PTR obj, AT_STRING server_IP, uint32_t port); 83 | int32_t esp8266_tcp_server_open(ESP8266_DEF_PTR obj, uint32_t port); 84 | int32_t esp8266_tcp_server_close(ESP8266_DEF_PTR obj, uint32_t port); 85 | 86 | int32_t esp8266_transmission_mode(ESP8266_DEF_PTR obj, ESP8266_TRANS_MODE mode); 87 | int32_t esp8266_passthr_start(ESP8266_DEF_PTR obj); 88 | int32_t esp8266_passthr_end(ESP8266_DEF_PTR obj); 89 | int32_t esp8266_passthr_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt); 90 | uint32_t esp8266_normal_write(ESP8266_DEF_PTR obj, char *buf, uint32_t cnt); 91 | uint32_t esp8266_connect_write(ESP8266_DEF_PTR obj, char *buf, char* connect, uint32_t cnt); 92 | int32_t esp8266_read(ESP8266_DEF_PTR obj, char *buf, uint32_t timeout); 93 | uint32_t esp8266_nread(ESP8266_DEF_PTR obj, char *buf, uint32_t n); 94 | 95 | int32_t esp8266_CIPCLOSE(ESP8266_DEF_PTR obj, char * conn_buf); 96 | 97 | #endif -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | #include "embARC.h" 31 | #include "embARC_debug.h" 32 | 33 | #include "board.h" 34 | #include "esp8266.h" 35 | 36 | #include 37 | #include 38 | 39 | #define WIFI_SSID "\"embARC\"" 40 | #define WIFI_PWD "\"qazwsxedc\"" 41 | 42 | static char http_get[] = "GET /"; 43 | static char http_IDP[] = "+IPD,"; 44 | static char http_html_header[] = "HTTP/1.x 200 OK\r\nContent-type: text/html\r\n\r\n"; 45 | static char http_html_body_1[] = 46 | "ESP8266_AT_HttpServer

Welcome to this Website

"; 47 | static char http_html_body_2[] = 48 | "

This Website is used to test the AT command about HttpServer of ESP8266.

"; 49 | 50 | 51 | static char http_server_buf[1024]; 52 | 53 | int main(void) 54 | { 55 | char *conn_buf; 56 | 57 | //ESP8266 Init 58 | EMBARC_PRINTF("============================ Init ============================\n"); 59 | 60 | ESP8266_DEFINE(esp8266); 61 | esp8266_init(esp8266, UART_BAUDRATE_115200); 62 | at_test(esp8266->p_at); 63 | board_delay_ms(100, 1); 64 | 65 | //Set Mode 66 | EMBARC_PRINTF("============================ Set Mode ============================\n"); 67 | 68 | esp8266_wifi_mode_get(esp8266, false); 69 | board_delay_ms(100, 1); 70 | esp8266_wifi_mode_set(esp8266, 3, false); 71 | board_delay_ms(100, 1); 72 | 73 | //Connect WiFi 74 | EMBARC_PRINTF("============================ Connect WiFi ============================\n"); 75 | 76 | do { 77 | esp8266_wifi_scan(esp8266, http_server_buf); 78 | EMBARC_PRINTF("Searching for WIFI %s ......\n", WIFI_SSID); 79 | board_delay_ms(100, 1); 80 | } while (strstr(http_server_buf, WIFI_SSID)==NULL); 81 | 82 | EMBARC_PRINTF("WIFI %s found! Try to connect\n", WIFI_SSID); 83 | 84 | while (esp8266_wifi_connect(esp8266, WIFI_SSID, WIFI_PWD, false) != AT_OK) { 85 | EMBARC_PRINTF("WIFI %s connect failed\n", WIFI_SSID); 86 | board_delay_ms(100, 1); 87 | } 88 | 89 | EMBARC_PRINTF("WIFI %s connect succeed\n", WIFI_SSID); 90 | 91 | //Creat Server 92 | EMBARC_PRINTF("============================ Connect Server ============================\n"); 93 | 94 | esp8266_tcp_server_open(esp8266, 80); 95 | 96 | //Show IP 97 | EMBARC_PRINTF("============================ Show IP ============================\n"); 98 | 99 | esp8266_address_get(esp8266); 100 | board_delay_ms(1000, 1); 101 | 102 | while (1) { 103 | memset(http_server_buf, 0, sizeof(http_server_buf)); 104 | at_read(esp8266->p_at ,http_server_buf ,1000); 105 | board_delay_ms(200, 1); 106 | //EMBARC_PRINTF("Alive\n"); 107 | 108 | if (strstr(http_server_buf, http_get) != NULL) { 109 | EMBARC_PRINTF("============================ send ============================\n"); 110 | 111 | EMBARC_PRINTF("\nThe message is:\n%s\n", http_server_buf); 112 | 113 | conn_buf = strstr(http_server_buf, http_IDP) + 5; 114 | *(conn_buf+1) = 0; 115 | 116 | EMBARC_PRINTF("Send Start\n"); 117 | board_delay_ms(10, 1); 118 | 119 | esp8266_connect_write(esp8266, http_html_header, conn_buf, (sizeof(http_html_header)-1)); 120 | board_delay_ms(100, 1); 121 | 122 | esp8266_connect_write(esp8266, http_html_body_1, conn_buf, (sizeof(http_html_body_1)-1)); 123 | board_delay_ms(300, 1); 124 | 125 | esp8266_connect_write(esp8266, http_html_body_2, conn_buf, (sizeof(http_html_body_2)-1)); 126 | board_delay_ms(300, 1); 127 | 128 | esp8266_CIPCLOSE(esp8266, conn_buf); 129 | 130 | EMBARC_PRINTF("Send Finish\n"); 131 | } 132 | } 133 | 134 | return E_OK; 135 | } -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/esp8266_wifi/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= esp8266_http_server 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= emsk 12 | BD_VER ?= 22 13 | CUR_CORE ?= arcem7d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= gnu 24 | 25 | # 26 | # root dir of embARC 27 | # 28 | EMBARC_ROOT = ../../.. 29 | # Selected OS 30 | OS_SEL ?= freertos 31 | 32 | MID_SEL = common 33 | 34 | # application source dirs 35 | APPL_CSRC_DIR = . 36 | APPL_ASMSRC_DIR = . 37 | 38 | # application include dirs 39 | APPL_INC_DIR = . 40 | 41 | # include current project makefile 42 | COMMON_COMPILE_PREREQUISITES += makefile 43 | 44 | ### Options above must be added before include options.mk ### 45 | # include key embARC build system makefile 46 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 47 | include $(EMBARC_ROOT)/options/options.mk -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/pmwifi/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | *************************************************************************** 8 | * * 9 | * FreeRTOS provides completely free yet professionally developed, * 10 | * robust, strictly quality controlled, supported, and cross * 11 | * platform software that has become a de facto standard. * 12 | * * 13 | * Help yourself get started quickly and support the FreeRTOS * 14 | * project by purchasing a FreeRTOS tutorial book, reference * 15 | * manual, or both from: http://www.FreeRTOS.org/Documentation * 16 | * * 17 | * Thank you! * 18 | * * 19 | *************************************************************************** 20 | 21 | This file is part of the FreeRTOS distribution. 22 | 23 | FreeRTOS is free software; you can redistribute it and/or modify it under 24 | the terms of the GNU General Public License (version 2) as published by the 25 | Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. 26 | 27 | >>! NOTE: The modification to the GPL is included to allow you to distribute 28 | >>! a combined work that includes FreeRTOS without being obliged to provide 29 | >>! the source code for proprietary components outside of the FreeRTOS 30 | >>! kernel. 31 | 32 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 33 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 34 | FOR A PARTICULAR PURPOSE. Full license text is available from the following 35 | link: http://www.freertos.org/a00114.html 36 | 37 | 1 tab == 4 spaces! 38 | 39 | *************************************************************************** 40 | * * 41 | * Having a problem? Start by reading the FAQ "My application does * 42 | * not run, what could be wrong?" * 43 | * * 44 | * http://www.FreeRTOS.org/FAQHelp.html * 45 | * * 46 | *************************************************************************** 47 | 48 | http://www.FreeRTOS.org - Documentation, books, training, latest versions, 49 | license and Real Time Engineers Ltd. contact details. 50 | 51 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 52 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 53 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 54 | 55 | http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High 56 | Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS 57 | licenses offer ticketed support, indemnification and middleware. 58 | 59 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 60 | engineered and independently SIL3 certified version for use in safety and 61 | mission critical applications that require provable dependability. 62 | 63 | 1 tab == 4 spaces! 64 | */ 65 | 66 | #ifndef FREERTOS_CONFIG_H 67 | #define FREERTOS_CONFIG_H 68 | 69 | #include 70 | /*----------------------------------------------------------- 71 | * Application specific definitions. 72 | * 73 | * These definitions should be adjusted for your particular hardware and 74 | * application requirements. 75 | * 76 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 77 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 78 | * 79 | * See http://www.freertos.org/a00110.html. 80 | *----------------------------------------------------------*/ 81 | 82 | #define configUSE_PREEMPTION 1 83 | #define configUSE_IDLE_HOOK 0 84 | #define configUSE_TICK_HOOK 0 85 | #define configCPU_CLOCK_HZ ( ( unsigned long ) BOARD_CPU_CLOCK ) 86 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) 87 | #define configMAX_PRIORITIES ( 4 ) 88 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 104 ) 89 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 18 * 1024 ) ) 90 | #define configMAX_TASK_NAME_LEN ( 10 ) 91 | #define configUSE_TRACE_FACILITY 0 92 | #define configUSE_16_BIT_TICKS 0 93 | #define configIDLE_SHOULD_YIELD 1 94 | #define configUSE_MUTEXES 1 95 | 96 | /* Co-routine definitions. */ 97 | #define configUSE_CO_ROUTINES 0 98 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 99 | 100 | 101 | /* Set the following definitions to 1 to include the API function, or zero 102 | to exclude the API function. */ 103 | 104 | #define INCLUDE_vTaskPrioritySet 1 105 | #define INCLUDE_uxTaskPriorityGet 1 106 | #define INCLUDE_vTaskDelete 1 107 | #define INCLUDE_vTaskCleanUpResources 0 108 | #define INCLUDE_vTaskSuspend 1 109 | #define INCLUDE_vTaskDelayUntil 1 110 | #define INCLUDE_vTaskDelay 1 111 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 112 | 113 | #endif /* FREERTOS_CONFIG_H */ -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/pmwifi/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #include "board.h" 35 | #include "device/ip_hal/dev_iic.h" 36 | #include "tcn75.h" 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/arch.h" 40 | #include "lwip/api.h" 41 | #include "httpserver-netconn.h" 42 | 43 | #include 44 | #include 45 | 46 | #ifndef HTTPD_DEBUG 47 | #define HTTPD_DEBUG LWIP_DBG_OFF 48 | #endif 49 | 50 | #define TEMP_I2C_ID DW_IIC_0_ID 51 | 52 | char *gcvt(double number, size_t ndigits, char *buf); 53 | static void task_send(void *par); 54 | static void task_temp(void *par); 55 | static void http_server_netconn_serve(struct netconn *conn); 56 | 57 | #define TSK_PRIOR_SEND (configMAX_PRIORITIES-2) 58 | #define TSK_PRIOR_TEMP (configMAX_PRIORITIES-1) 59 | 60 | // Queues 61 | static QueueHandle_t dtq1_id; 62 | 63 | // Task IDs 64 | static TaskHandle_t task_send_handle = NULL; 65 | static TaskHandle_t task_temp_handle = NULL; 66 | 67 | static char *http_index_number; 68 | static char http_index_html[] = "Temperature Monitor

Welcome to our Temperature Monitor

Now the temperature is ????? *C.

"; 69 | static const char http_html_hdr[] = "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"; 70 | static const char http_index_html_1[] = "Temperature Monitor

Welcome to our Temperature Monitor

Now the temperature is "; 71 | static const char http_index_html_2[] = " *C.

"; 72 | 73 | 74 | /** 75 | * \brief call FreeRTOS API, create and start tasks 76 | */ 77 | int main(void) 78 | { 79 | 80 | vTaskSuspendAll(); 81 | 82 | // Create Tasks 83 | //####Insert code here### 84 | 85 | // Create Queues 86 | //####Insert code here### 87 | 88 | xTaskResumeAll(); 89 | 90 | vTaskSuspend(NULL); 91 | 92 | return 0; 93 | } 94 | 95 | 96 | static void task_send(void *par) 97 | { 98 | float temp_val = 0.0; 99 | struct netconn *conn, *newconn; 100 | err_t err; 101 | 102 | /* Create a new TCP connection handle */ 103 | /* Bind to port 80 (HTTP) with default IP address */ 104 | conn = netconn_new(NETCONN_TCP); 105 | netconn_bind(conn, IP_ADDR_ANY, 80); 106 | 107 | /* Put the connection into LISTEN state */ 108 | netconn_listen(conn); 109 | 110 | do 111 | { 112 | err = netconn_accept(conn, &newconn); 113 | 114 | if (err == ERR_OK) 115 | { 116 | xQueuePeek(dtq1_id, (void *)(&temp_val), portMAX_DELAY); 117 | board_delay_ms(1,1); 118 | http_index_number = gcvt((double)(temp_val), 3, http_index_number); 119 | 120 | http_server_netconn_serve(newconn); 121 | netconn_delete(newconn); 122 | } 123 | 124 | } 125 | while(err == ERR_OK); 126 | 127 | LWIP_DEBUGF(HTTPD_DEBUG,("http_server_netconn_thread: netconn_accept received error %d, shutting down",err)); 128 | 129 | netconn_close(conn); 130 | netconn_delete(conn); 131 | } 132 | 133 | 134 | static void task_temp(void *par) 135 | { 136 | float temp_val = 0.0; 137 | 138 | static portTickType xLastWakeTime; 139 | const portTickType xFrequency = pdMS_TO_TICKS(1000); 140 | 141 | // 使用当前时间初始化变量xLastWakeTime ,注意这和vTaskDelay()函数不同 142 | xLastWakeTime = xTaskGetTickCount(); 143 | 144 | //初始化TCN75 145 | //####Insert code here### 146 | 147 | while (1) 148 | { 149 | /* 调用系统延时函数,周期性阻塞1000ms */ 150 | vTaskDelayUntil( &xLastWakeTime,xFrequency ); 151 | 152 | //读取TCN75 153 | //####Insert code here### 154 | 155 | xQueueReset(dtq1_id); 156 | board_delay_ms(1, 1); 157 | xQueueSend(dtq1_id, (void *)(&temp_val), portMAX_DELAY); 158 | } 159 | } 160 | 161 | 162 | /** Serve one HTTP connection accepted in the http thread */ 163 | static void http_server_netconn_serve(struct netconn *conn) 164 | { 165 | struct netbuf *inbuf; 166 | char *buf; 167 | u16_t buflen; 168 | err_t err; 169 | 170 | /* Read the data from the port, blocking if nothing yet there. 171 | We assume the request (the part we care about) is in one netbuf */ 172 | err = netconn_recv(conn, &inbuf); 173 | 174 | if(err == ERR_OK) 175 | { 176 | netbuf_data(inbuf, (void**)&buf, &buflen); 177 | 178 | /* Is this an HTTP GET command? (only check the first 5 chars, since 179 | there are other formats for GET, and we're keeping it very simple )*/ 180 | if(buflen>=5 && buf[0]=='G' && buf[1]=='E' && buf[2]=='T' && buf[3]==' ' && buf[4]=='/' ) 181 | { 182 | memset(http_index_html, 0, sizeof(http_index_html)-1); 183 | 184 | strcat (http_index_html, http_index_html_1); 185 | strcat (http_index_html, http_index_number); 186 | strcat (http_index_html, http_index_html_2); 187 | 188 | /* Send the HTML header 189 | * subtract 1 from the size, since we dont send the \0 in the string 190 | * NETCONN_NOCOPY: our data is const static, so no need to copy it */ 191 | netconn_write(conn, http_html_hdr, sizeof(http_html_hdr)-1, NETCONN_NOCOPY); 192 | 193 | /* Send our HTML page */ 194 | netconn_write(conn, http_index_html, sizeof(http_index_html)-1, NETCONN_NOCOPY); 195 | 196 | } 197 | } 198 | /* Close the connection (server closes in HTTP) */ 199 | netconn_close(conn); 200 | /* Delete the buffer (netconn_recv gives us ownership, 201 | so we have to make sure to deallocate the buffer) */ 202 | netbuf_delete(inbuf); 203 | } 204 | -------------------------------------------------------------------------------- /labs/lab10_temp_monitor/pmwifi/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab_10_wifi 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= emsk 12 | BD_VER ?= 11 13 | CUR_CORE ?= arcem6 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= gnu 24 | 25 | 26 | EXT_DEV_LIST += wifi/mrf24g sensor/temperature/tcn75 27 | 28 | STACKSZ = 4096 29 | 30 | # 31 | # root dir of embARC 32 | # 33 | EMBARC_ROOT = ../../../.. 34 | 35 | # Selected OS 36 | OS_SEL ?= freertos 37 | # Select Middleware Packages 38 | MID_SEL = common lwip lwip-contrib 39 | LWIP_CONTRIB_APPS ?= httpserver 40 | 41 | # application source dirs 42 | APPL_CSRC_DIR = . 43 | APPL_ASMSRC_DIR = . 44 | 45 | # application include dirs 46 | APPL_INC_DIR = . 47 | 48 | # include current project makefile 49 | COMMON_COMPILE_PREREQUISITES += makefile 50 | 51 | ### Options above must be added before include options.mk ### 52 | # include key embARC build system makefile 53 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 54 | include $(EMBARC_ROOT)/options/options.mk 55 | -------------------------------------------------------------------------------- /labs/lab1_core_test/CoreTest.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #ifdef _DEBUG 32 | #include "stdio.h" 33 | #endif 34 | 35 | #define POINTX {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 36 | #define POINTY {2, 4, 6, 8, 10, 12, 14, 16, 18, 20} 37 | #define POINTS 10 38 | 39 | #define GetError(x, y, Px, Py) \ 40 | ( (x-Px)*(x-Px) + (y-Py)*(y-Py) ) 41 | 42 | int main(int argc, char* argv[]) { 43 | int pPointX[] = POINTX; 44 | int pPointY[] = POINTY; 45 | 46 | int x, y; 47 | int index, error, minindex, minerror; 48 | 49 | x = 4; 50 | y = 5; 51 | 52 | minerror = GetError(x, y, pPointX[0], pPointY[0]); 53 | minindex = 0; 54 | 55 | for(index = 1; index < POINTS; index++) { 56 | error = GetError(x, y, pPointX[index], pPointY[index]); 57 | 58 | if (error < minerror) { 59 | minerror = error; 60 | minindex = index; 61 | } 62 | } 63 | 64 | #ifdef _DEBUG 65 | printf("minindex = %d, minerror = %d.\n", minindex, minerror); 66 | printf("The point is (%d, %d).\n", pPointX[minindex], pPointY[minindex]); 67 | getchar(); 68 | #endif 69 | 70 | return 0; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /labs/lab3_timer/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab3_timer 3 | 4 | ## 5 | # Current Board And Core 6 | ## 7 | BOARD ?= iotdk 8 | BD_VER ?= 10 9 | CUR_CORE ?= arcem9d 10 | 11 | 12 | ## 13 | # Set toolchain 14 | ## 15 | TOOLCHAIN ?= gnu 16 | 17 | # 18 | # root dir of embARC 19 | # 20 | EMBARC_ROOT = ../../.. 21 | 22 | MID_SEL = common 23 | 24 | # application source dirs 25 | APPL_CSRC_DIR = . 26 | APPL_ASMSRC_DIR = . 27 | 28 | # application include dirs 29 | APPL_INC_DIR = . 30 | 31 | # include current project makefile 32 | COMMON_COMPILE_PREREQUISITES += makefile 33 | 34 | ### Options above must be added before include options.mk ### 35 | # include key embARC build system makefile 36 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 37 | include $(EMBARC_ROOT)/options/options.mk 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /labs/lab3_timer/timer.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #include "arc/arc_timer.h" 35 | #include "arc/arc.h" 36 | #include "arc/arc_builtin.h" 37 | 38 | #define BOARD_CPU_CLOCK CLK_CPU 39 | #define MAX_COUNT 0x0fffffff 40 | /** main entry for testing arc timer**/ 41 | int main(void) 42 | { 43 | 44 | /*Check the timer configuration information through the Timer BCR register.*/ 45 | uint32_t bcr = arc_aux_read(AUX_BCR_TIMERS); 46 | int timer0_flag = (bcr >> 8) & 1; 47 | int timer1_flag = (bcr >> 9) & 1; 48 | int RTC_flag = (bcr >> 10) & 1; 49 | if (timer0_flag) { 50 | EMBARC_PRINTF("Does this timer0 exist? YES\r\n"); 51 | /*Read auxiliary register configuration information*/ 52 | EMBARC_PRINTF("timer0's operating mode:0x%08x\r\n",arc_aux_read(AUX_TIMER0_CTRL)); 53 | EMBARC_PRINTF("timer0's limit value :0x%08x\r\n",arc_aux_read(AUX_TIMER0_LIMIT)); 54 | EMBARC_PRINTF("timer0's current cnt_number:0x%08x\r\n",arc_aux_read(AUX_TIMER0_CNT)); 55 | } else { 56 | EMBARC_PRINTF("\r\nDoes this timer0 exist? NO\r\n"); 57 | } 58 | 59 | if (timer1_flag) { 60 | EMBARC_PRINTF("\r\nDoes this timer1 exist? YES\r\n"); 61 | /*Read auxiliary register configuration information*/ 62 | EMBARC_PRINTF("timer1's operating mode:0x%08x\r\n",arc_aux_read(AUX_TIMER1_CTRL)); 63 | EMBARC_PRINTF("timer1's limit value :0x%08x\r\n",arc_aux_read(AUX_TIMER1_LIMIT)); 64 | EMBARC_PRINTF("timer1's current cnt_number:0x%08x\r\n",arc_aux_read(AUX_TIMER1_CNT)); 65 | } else { 66 | EMBARC_PRINTF("\r\nDoes this timer1 exist? NO\r\n"); 67 | } 68 | 69 | if (RTC_flag) { 70 | EMBARC_PRINTF("\r\nDoes this RTC_timer exist? YES\r\n"); 71 | /*Read auxiliary register configuration information*/ 72 | EMBARC_PRINTF("RTC_timer's operating mode:0x%08x\r\n",arc_aux_read(AUX_RTC_CTRL)); 73 | EMBARC_PRINTF("timer1's current tick:0x%08x\r\n",arc_aux_read(AUX_RTC_LOW)); 74 | } else { 75 | EMBARC_PRINTF("\r\nDoes this RTC_timer exist? NO\r\n"); 76 | } 77 | 78 | /*Configure the timer through auxiliary registers*/ 79 | if (timer0_flag) { 80 | /* Stop it first since it might be enabled before */ 81 | arc_aux_write(AUX_TIMER0_CTRL, 0); 82 | arc_aux_write(AUX_TIMER0_LIMIT,0); 83 | arc_aux_write(AUX_TIMER0_CNT, 0); 84 | /*This is a example about timer0's timer function.*/ 85 | uint32_t mode = TIMER_CTRL_NH;/*Timing without triggering interruption.*/ 86 | uint32_t val = MAX_COUNT; 87 | arc_aux_write(AUX_TIMER0_CNT, 0); 88 | arc_aux_write(AUX_TIMER0_LIMIT, val); 89 | /*start the specific timer*/ 90 | arc_aux_write(AUX_TIMER0_CTRL, mode); 91 | uint32_t start_cnt = arc_aux_read(AUX_TIMER0_CNT); 92 | EMBARC_PRINTF("\r\nThe start_cnt number is:%d",start_cnt); 93 | 94 | EMBARC_PRINTF("\r\n/******** TEST MODE START ********/\r\n"); 95 | EMBARC_PRINTF("\r\nThis is TEST CODE.\r\n"); 96 | EMBARC_PRINTF("\r\nThis is TEST CODE.\r\n"); 97 | EMBARC_PRINTF("\r\nThis is TEST CODE.\r\n"); 98 | board_delay_ms(100, 1); 99 | EMBARC_PRINTF("\r\n/******** TEST MODE END ********/\r\n"); 100 | 101 | uint32_t end_cnt = arc_aux_read(AUX_TIMER0_CNT); 102 | EMBARC_PRINTF("The end_cnt number is:%d\r\n", end_cnt); 103 | uint32_t time = (end_cnt-start_cnt)/(BOARD_CPU_CLOCK/1000); 104 | EMBARC_PRINTF("\r\nTotal time of TEST CODE BLOCK operation:%d\r\n",time); 105 | } else { 106 | EMBARC_PRINTF("timer 0 is not present\r\n"); 107 | } 108 | 109 | return E_SYS; 110 | } 111 | -------------------------------------------------------------------------------- /labs/lab4_interrupt/part1/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2017, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | 32 | /* embARC HAL */ 33 | #include "embARC.h" 34 | #include "embARC_debug.h" 35 | 36 | #define COUNT BOARD_CPU_CLOCK/1000 37 | 38 | volatile static int t0 = 0; 39 | volatile static int second = 1; 40 | 41 | /** arc timer 0 interrupt routine */ 42 | static void timer0_isr(void *ptr) 43 | { 44 | arc_timer_int_clear(TIMER_0); 45 | t0++; 46 | } 47 | 48 | /** arc timer 0 interrupt delay */ 49 | void timer0_delay_ms(int ms) 50 | { 51 | t0 = 0; 52 | while(t0 < ms); 53 | } 54 | 55 | /** main entry for testing arc fiq interrupt */ 56 | int main(void) 57 | { 58 | int_disable(INTNO_TIMER0); 59 | arc_timer_stop(TIMER_0); 60 | 61 | int_handler_install(INTNO_TIMER0, timer0_isr); 62 | int_pri_set(INTNO_TIMER0, INT_PRI_MIN); 63 | 64 | EMBARC_PRINTF("\r\nThis is a example about timer interrupt.\r\n"); 65 | 66 | int_enable(INTNO_TIMER0); 67 | arc_timer_start(TIMER_0, TIMER_CTRL_IE | TIMER_CTRL_NH, COUNT); 68 | 69 | while(1) 70 | { 71 | timer0_delay_ms(1000); 72 | EMBARC_PRINTF("\r\n %ds.\r\n",second); 73 | second ++; 74 | } 75 | return E_SYS; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /labs/lab4_interrupt/part1/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab4_interrupt 3 | 4 | ## 5 | # Current Board And Core 6 | ## 7 | BOARD ?= emsk 8 | BD_VER ?= 22 9 | CUR_CORE ?= arcem7d 10 | 11 | ## 12 | # Set toolchain 13 | ## 14 | TOOLCHAIN ?= gnu 15 | 16 | # 17 | # root dir of embARC 18 | # 19 | EMBARC_ROOT = ../../../.. 20 | 21 | MID_SEL = common 22 | 23 | # application source dirs 24 | APPL_CSRC_DIR = . 25 | APPL_ASMSRC_DIR = . 26 | 27 | # application include dirs 28 | APPL_INC_DIR = . 29 | 30 | # include current project makefile 31 | COMMON_COMPILE_PREREQUISITES += makefile 32 | 33 | ### Options above must be added before include options.mk ### 34 | # include key embARC build system makefile 35 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 36 | include $(EMBARC_ROOT)/options/options.mk 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /labs/lab4_interrupt/part2/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | /* embARC HAL */ 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #define MAX_COUNT 0xfffff 35 | 36 | volatile static uint8_t timer_flag = 0; 37 | volatile static uint8_t hits = 0; 38 | 39 | volatile static uint8_t nesting_flag = 1; 40 | 41 | /** arc timer 0 interrupt routine */ 42 | static void timer0_isr(void *ptr) 43 | { 44 | arc_timer_int_clear(TIMER_0); 45 | 46 | timer_flag = 0; 47 | 48 | board_delay_ms(10, 1); 49 | 50 | if(timer_flag) { 51 | EMBARC_PRINTF("Interrupt nesting!\r\n"); 52 | } else { 53 | EMBARC_PRINTF("Interrupt\r\n"); 54 | } 55 | 56 | hits++; 57 | } 58 | 59 | /** arc timer 1 interrupt routine */ 60 | static void timer1_isr(void *ptr) 61 | { 62 | arc_timer_int_clear(TIMER_1); 63 | 64 | timer_flag = 1; 65 | } 66 | 67 | /** main entry for testing arc fiq interrupt */ 68 | int main(void) 69 | { 70 | arc_timer_stop(TIMER_0); 71 | arc_timer_stop(TIMER_1); 72 | 73 | int_disable(INTNO_TIMER0); 74 | int_disable(INTNO_TIMER1); 75 | 76 | int_handler_install(INTNO_TIMER0, timer0_isr); 77 | int_pri_set(INTNO_TIMER0, INT_PRI_MAX); 78 | 79 | int_handler_install(INTNO_TIMER1, timer1_isr); 80 | int_pri_set(INTNO_TIMER1, INT_PRI_MIN); 81 | 82 | EMBARC_PRINTF("\r\nThe test will start in 1s.\r\n"); 83 | EMBARC_PRINTF("\r\n/******** TEST MODE START ********/\r\n\r\n"); 84 | 85 | int_enable(INTNO_TIMER0); 86 | int_enable(INTNO_TIMER1); 87 | 88 | arc_timer_start(TIMER_0, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT); 89 | arc_timer_start(TIMER_1, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT/100); 90 | 91 | while(1) 92 | { 93 | if((hits >= 5) && (nesting_flag == 1)) { 94 | arc_timer_stop(TIMER_0); 95 | arc_timer_stop(TIMER_1); 96 | 97 | int_disable(INTNO_TIMER0); 98 | int_disable(INTNO_TIMER1); 99 | 100 | int_pri_set(INTNO_TIMER0, INT_PRI_MIN); 101 | int_pri_set(INTNO_TIMER1, INT_PRI_MAX); 102 | 103 | nesting_flag = 0; 104 | 105 | int_enable(INTNO_TIMER0); 106 | int_enable(INTNO_TIMER1); 107 | 108 | arc_timer_start(TIMER_0, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT); 109 | arc_timer_start(TIMER_1, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT/10); 110 | } else if((hits >= 10) && (nesting_flag == 0)) { 111 | arc_timer_stop(TIMER_0); 112 | arc_timer_stop(TIMER_1); 113 | 114 | int_disable(INTNO_TIMER0); 115 | int_disable(INTNO_TIMER1); 116 | 117 | int_pri_set(INTNO_TIMER0, INT_PRI_MAX); 118 | int_pri_set(INTNO_TIMER1, INT_PRI_MIN); 119 | 120 | hits = 0; 121 | nesting_flag = 1; 122 | 123 | int_enable(INTNO_TIMER0); 124 | int_enable(INTNO_TIMER1); 125 | 126 | arc_timer_start(TIMER_0, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT); 127 | arc_timer_start(TIMER_1, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT/100); 128 | } 129 | } 130 | return E_SYS; 131 | } 132 | -------------------------------------------------------------------------------- /labs/lab4_interrupt/part2/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab4_interrupt 3 | 4 | ## 5 | # Current Board And Core 6 | ## 7 | BOARD ?= emsk 8 | BD_VER ?= 22 9 | CUR_CORE ?= arcem7d 10 | 11 | ## 12 | # Set toolchain 13 | ## 14 | TOOLCHAIN ?= gnu 15 | 16 | # 17 | # root dir of embARC 18 | # 19 | EMBARC_ROOT = ../../../.. 20 | 21 | MID_SEL = common 22 | 23 | # application source dirs 24 | APPL_CSRC_DIR = . 25 | APPL_ASMSRC_DIR = . 26 | 27 | # application include dirs 28 | APPL_INC_DIR = . 29 | 30 | # include current project makefile 31 | COMMON_COMPILE_PREREQUISITES += makefile 32 | 33 | ### Options above must be added before include options.mk ### 34 | # include key embARC build system makefile 35 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 36 | include $(EMBARC_ROOT)/options/options.mk 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /labs/lab5_emsk/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | /* embARC HAL */ 32 | #include "embARC.h" 33 | #include "embARC_debug.h" 34 | 35 | #define LED_MASK BOARD_LED_MASK 36 | #define BTN_MASK BOARD_BTN_MASK 37 | #define SWT_MASk BOARD_SWT_MASK 38 | 39 | 40 | /** 41 | * \brief Test hardware board without any peripheral 42 | */ 43 | int main(void) 44 | { 45 | uint16_t led_val = 0x0000; 46 | uint16_t btn_val = 0x0000; 47 | uint16_t swt_val = 0x0000; 48 | uint16_t pri_cnt = 0x0000; 49 | 50 | while (1) 51 | { 52 | led_val = 0x0000; 53 | btn_val = button_read(BOARD_BTN_MASK); 54 | swt_val = switch_read(BOARD_SWT_MASK); 55 | 56 | led_val = (btn_val<<4) + swt_val; 57 | 58 | led_write(led_val, BOARD_LED_MASK); 59 | 60 | board_delay_ms(10, 1); 61 | 62 | if(pri_cnt >= 100) 63 | { 64 | pri_cnt = 0; 65 | EMBARC_PRINTF("\r\nThe Button is 0x%x\r\n",btn_val); 66 | EMBARC_PRINTF("The Switch is 0x%x\r\n",swt_val); 67 | } 68 | else 69 | { 70 | pri_cnt ++; 71 | } 72 | } 73 | 74 | return E_SYS; 75 | } 76 | 77 | /** @} */ -------------------------------------------------------------------------------- /labs/lab5_emsk/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab5_emsk 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= emsk 12 | BD_VER ?= 22 13 | CUR_CORE ?= arcem7d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= gnu 24 | 25 | 26 | # 27 | # root dir of embARC 28 | # 29 | EMBARC_ROOT = ../../.. 30 | 31 | MID_SEL = 32 | 33 | # application source dirs 34 | APPL_CSRC_DIR = . 35 | APPL_ASMSRC_DIR = . 36 | 37 | # application include dirs 38 | APPL_INC_DIR = . 39 | 40 | # include current project makefile 41 | COMMON_COMPILE_PREREQUISITES += makefile 42 | 43 | ### Options above must be added before include options.mk ### 44 | # include key embARC build system makefile 45 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 46 | include $(EMBARC_ROOT)/options/options.mk -------------------------------------------------------------------------------- /labs/lab5_iotdk/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | /* embARC HAL */ 32 | #include "embARC.h" 33 | #include "embARC_debug.h" 34 | 35 | #define IOTDK_LED_ID DFSS_GPIO_4B2_ID 36 | #define IOTDK_LED_PIN 0 37 | 38 | 39 | /** 40 | * \brief Test hardware board without any peripheral 41 | */ 42 | int main(void) 43 | { 44 | DEV_GPIO_PTR gpio_led; 45 | 46 | io_arduino_config(ARDUINO_PIN_0, ARDUINO_GPIO, IO_PINMUX_ENABLE); 47 | 48 | gpio_led = gpio_get_dev(IOTDK_LED_ID); 49 | if (gpio_led->gpio_open((1 << IOTDK_LED_PIN)) == E_OPNED) 50 | { 51 | gpio_led->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, 52 | (void *)(1 << IOTDK_LED_PIN)); 53 | } 54 | 55 | while (1) 56 | { 57 | gpio_led->gpio_write(1, 1 << IOTDK_LED_PIN); 58 | board_delay_ms(10, 1); 59 | gpio_led->gpio_write(0, 1 << IOTDK_LED_PIN); 60 | board_delay_ms(190, 1); 61 | } 62 | 63 | return E_SYS; 64 | } 65 | 66 | /** @} */ -------------------------------------------------------------------------------- /labs/lab5_iotdk/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab5_iotdk 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= iotdk 12 | BD_VER ?= 10 13 | CUR_CORE ?= arcem9d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= gnu 24 | 25 | 26 | # 27 | # root dir of embARC 28 | # 29 | EMBARC_ROOT = ../../.. 30 | 31 | MID_SEL = 32 | 33 | # application source dirs 34 | APPL_CSRC_DIR = . 35 | APPL_ASMSRC_DIR = . 36 | 37 | # application include dirs 38 | APPL_INC_DIR = . 39 | 40 | # include current project makefile 41 | COMMON_COMPILE_PREREQUISITES += makefile 42 | 43 | ### Options above must be added before include options.mk ### 44 | # include key embARC build system makefile 45 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 46 | include $(EMBARC_ROOT)/options/options.mk 47 | -------------------------------------------------------------------------------- /labs/lab6_ble_rn4020/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #include "board.h" 35 | #include "device/ip_hal/dev_uart.h" 36 | #include "rn4020.h" 37 | 38 | #define RN4020_PRV_SERV_HIGH_UUID 0x1122334455667788 39 | #define RN4020_PRV_SERV_LOW_UUID 0x9900AABBCCDDEEFF 40 | #define RN4020_PRV_CHAR_HIGH_UUID 0x0102030405060708 41 | #define RN4020_PRV_CHAR_LOW_UUID 0x09000A0B0C0D0E0F 42 | 43 | int32_t rn4020_set_prv_uuid(RN4020_DEF_PTR rn4020, uint64_t high_uuid, uint64_t low_uuid) 44 | { 45 | uint8_t i; 46 | uint8_t uuid_data[16]; 47 | 48 | for(i = 0; i < 16; i++) 49 | { 50 | if(i < 8) uuid_data[i] = (high_uuid >> ((7-i) << 3)) & 0xff; 51 | else uuid_data[i] = (low_uuid >> ((15-i) << 3)) & 0xff; 52 | } 53 | 54 | return rn4020_add_prv_service(rn4020, uuid_data); 55 | 56 | } 57 | 58 | int32_t rn4020_set_prv_char(RN4020_DEF_PTR rn4020, uint64_t high_uuid, uint64_t low_uuid, 59 | uint8_t property, uint8_t size, uint8_t security) 60 | { 61 | uint8_t i; 62 | uint8_t uuid_data[16]; 63 | 64 | for(i = 0; i < 16; i++) 65 | { 66 | if(i < 8) uuid_data[i] = (high_uuid >> ((7-i) << 3)) & 0xff; 67 | else uuid_data[i] = (low_uuid >> ((15-i) << 3)) & 0xff; 68 | } 69 | 70 | return rn4020_add_prv_char(rn4020, uuid_data, property, size, security); 71 | 72 | } 73 | 74 | int main(void) 75 | { 76 | 77 | uint32_t battery = 100; 78 | 79 | RN4020_DEFINE(rn4020_ble, DFSS_UART_3_ID, DFSS_GPIO_4B0_ID, 2, DFSS_GPIO_4B0_ID, 1, DFSS_GPIO_4B0_ID, 3); 80 | 81 | EMBARC_PRINTF("rn4020 test application\r\n"); 82 | 83 | rn4020_setup(rn4020_ble); 84 | rn4020_reset_to_factory(rn4020_ble); 85 | 86 | /* Set device Name */ 87 | rn4020_set_dev_name(rn4020_ble, "IoT DK"); 88 | 89 | /* Set device services */ 90 | rn4020_set_services(rn4020_ble, RN4020_SERVICE_DEVICE_INFORMATION | 91 | RN4020_SERVICE_BATTERY | 92 | RN4020_SERVICE_USER_DEFINED); 93 | 94 | rn4020_set_features(rn4020_ble, RN4020_FEATURE_SERVER_ONLY); 95 | rn4020_clear_private(rn4020_ble); 96 | 97 | /* Set private service UUID and private characteristic */ 98 | rn4020_set_prv_uuid(rn4020_ble, RN4020_PRV_SERV_HIGH_UUID, RN4020_PRV_SERV_LOW_UUID); 99 | rn4020_set_prv_char(rn4020_ble, RN4020_PRV_CHAR_HIGH_UUID, RN4020_PRV_CHAR_LOW_UUID, 0x18, 0x06, RN4020_PRIVATE_CHAR_SEC_NONE); 100 | 101 | /* Reboot RN4020 to make changes effective */ 102 | rn4020_reset(rn4020_ble); 103 | 104 | rn4020_refresh_handle_uuid_table(rn4020_ble); 105 | 106 | rn4020_advertise(rn4020_ble); 107 | 108 | 109 | while (1) { 110 | 111 | rn4020_battery_set_level(rn4020_ble, battery--); 112 | 113 | board_delay_ms(1000, 0); 114 | if (battery < 30) { 115 | battery = 100; 116 | } 117 | } 118 | 119 | return E_SYS; 120 | } 121 | 122 | -------------------------------------------------------------------------------- /labs/lab6_ble_rn4020/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= Ble_Rn4020_Test 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= iotdk 12 | BD_VER ?= 10 13 | CUR_CORE ?= arcem9d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= mw 24 | #TOOLCHAIN ?= gnu 25 | 26 | EXT_DEV_LIST += ble/rn4020 27 | # 28 | # root dir of embARC 29 | # 30 | EMBARC_ROOT = ../../.. 31 | 32 | MID_SEL = common 33 | 34 | # application source dirs 35 | APPL_CSRC_DIR = . 36 | APPL_ASMSRC_DIR = . 37 | 38 | # application include dirs 39 | APPL_INC_DIR = . 40 | 41 | # include current project makefile 42 | COMMON_COMPILE_PREREQUISITES += makefile 43 | 44 | ### Options above must be added before include options.mk ### 45 | # include key embARC build system makefile 46 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 47 | include $(EMBARC_ROOT)/options/options.mk -------------------------------------------------------------------------------- /labs/lab7_ble_hm10/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #include "board.h" 35 | #include "device/ip_hal/dev_uart.h" 36 | #include "hm1x.h" 37 | 38 | #define MAX_COUNT 0xfffff 39 | 40 | uint8_t isr_flag = 0; 41 | 42 | void init_ble_hm_10(HM1X_DEF_PTR obj, uint32_t baudrate, uint32_t mode, uint32_t type, uint32_t role) 43 | { 44 | EMBARC_PRINTF("Init HM1X with baudrate %dbps\r\n", baudrate); 45 | hm1x_init(obj, baudrate); 46 | 47 | hm1x_flush(obj); 48 | 49 | while (hm1x_test_command(obj)) { 50 | EMBARC_PRINTF("test command Failed\r\n"); 51 | } 52 | EMBARC_PRINTF("test command Successfully\r\n"); 53 | 54 | while (hm1x_restart(obj)) { 55 | EMBARC_PRINTF("Restart Failed\r\n"); 56 | } 57 | EMBARC_PRINTF("Restart Successfully\r\n"); 58 | 59 | while (hm1x_set_mode(obj, mode)) { 60 | EMBARC_PRINTF("SET MODE Failed\r\n"); 61 | } 62 | EMBARC_PRINTF("SET MODE to %d\r\n", mode); 63 | 64 | while(hm1x_set_type(obj, type)) { 65 | EMBARC_PRINTF("SET TYPE Failed\r\n"); 66 | } 67 | EMBARC_PRINTF("SET TYPE to %d\r\n", type); 68 | 69 | while(hm1x_set_role(obj, role)) { 70 | EMBARC_PRINTF("SET ROLE Failed\r\n"); 71 | } 72 | EMBARC_PRINTF("SET ROLE to %d\r\n", role); 73 | } 74 | 75 | static void timer0_isr(void *ptr) 76 | { 77 | static uint32_t led_val = 1; 78 | arc_timer_int_clear(TIMER_0); 79 | 80 | if (isr_flag == 1) { 81 | if(led_val >= 0x0100) { 82 | led_val = 0x0001; 83 | } else { 84 | led_val <<= 1; 85 | } 86 | 87 | led_write(led_val, BOARD_LED_MASK); 88 | } 89 | } 90 | 91 | void init_run_timer(void) 92 | { 93 | int_disable(INTNO_TIMER0); 94 | arc_timer_stop(TIMER_0); 95 | 96 | int_handler_install(INTNO_TIMER0, timer0_isr); 97 | int_pri_set(INTNO_TIMER0, INT_PRI_MIN); 98 | 99 | int_enable(INTNO_TIMER0); 100 | arc_timer_start(0, TIMER_CTRL_IE | TIMER_CTRL_NH, MAX_COUNT); 101 | } 102 | 103 | uint8_t compare_chars(uint8_t* buf, uint8_t* cmd, uint8_t num) 104 | { 105 | uint8_t i = 0; 106 | uint8_t cnt = 0; 107 | 108 | for (i = 0; i < num; ++i) { 109 | if(buf[i] == cmd[i]) { 110 | cnt++; 111 | } 112 | } 113 | 114 | if(cnt == num) { 115 | return 1; 116 | } else { 117 | return 0; 118 | } 119 | } 120 | 121 | void LED_ALL_FUN(void) 122 | { 123 | isr_flag = 0; 124 | 125 | led_write(BOARD_LED_MASK, BOARD_LED_MASK); 126 | } 127 | 128 | void LED_OFF_FUN(void) 129 | { 130 | isr_flag = 0; 131 | 132 | led_write(~BOARD_LED_MASK, BOARD_LED_MASK); 133 | } 134 | 135 | void LED_WRI_FUN(uint8_t* num_buf, uint8_t* num_cmd) 136 | { 137 | uint8_t i = 0; 138 | uint8_t k = 0; 139 | uint32_t led_val = 0; 140 | 141 | isr_flag = 0; 142 | 143 | for(k = 0; k < 3; ++k) 144 | { 145 | for (i = 0; i < 16; ++i) 146 | { 147 | if(num_buf[k] == num_cmd[i]) 148 | { 149 | led_val += i; 150 | } 151 | } 152 | led_val <<= 4; 153 | } 154 | led_val >>= 4; 155 | led_write(led_val, BOARD_LED_MASK); 156 | } 157 | 158 | void LED_RUN_FUN(void) 159 | { 160 | isr_flag = 1; 161 | } 162 | 163 | void LED_RED_FUN(void) 164 | { 165 | uint32_t led_val = 0; 166 | 167 | led_val = led_read(BOARD_LED_MASK); 168 | EMBARC_PRINTF("The Led is 0x0%x\r\n",led_val); 169 | } 170 | 171 | int main(void) 172 | { 173 | uint8_t rcv_buf[20]; 174 | int32_t rcv_cnt = 0; 175 | 176 | uint8_t cmd_buf[20]; 177 | int32_t cmd_cnt = 0; 178 | 179 | uint8_t rcv_flag = 0; 180 | uint8_t pre_flag = 0; 181 | 182 | uint8_t LED_ALL_CMD[6] = {'L','E','D','A','L','L'}; 183 | uint8_t LED_OFF_CMD[6] = {'L','E','D','O','F','F'}; 184 | uint8_t LED_WRI_CMD[6] = {'L','E','D','W','R','I'}; 185 | uint8_t LED_RUN_CMD[6] = {'L','E','D','R','U','N'}; 186 | uint8_t LED_RED_CMD[6] = {'L','E','D','R','E','D'}; 187 | 188 | uint8_t Num_CMD[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; 189 | 190 | uint8_t LED_ALL_FLAG = 0; 191 | uint8_t LED_OFF_FLAG = 0; 192 | uint8_t LED_WRI_FLAG = 0; 193 | uint8_t LED_RUN_FLAG = 0; 194 | uint8_t LED_RED_FLAG = 0; 195 | 196 | HM1X_DEFINE(hm1x, HM_1X_UART_ID); 197 | init_ble_hm_10(hm1x, UART_BAUDRATE_9600, BLE_HM1X_MODE_0, BLE_HM1X_TYPE_0, BLE_HM1X_SLAVE_ROLE); 198 | init_run_Timer(); 199 | 200 | EMBARC_PRINTF("\r\n/*****Enter THE TEST MODE*****/\r\n"); 201 | 202 | while (1) 203 | { 204 | LED_ALL_FLAG = 0; 205 | LED_OFF_FLAG = 0; 206 | LED_WRI_FLAG = 0; 207 | LED_RUN_FLAG = 0; 208 | LED_RED_FLAG = 0; 209 | 210 | rcv_cnt = hm1x_read(hm1x, rcv_buf, sizeof(rcv_buf)); 211 | rcv_buf[rcv_cnt] = '\0'; 212 | 213 | if (rcv_cnt) { 214 | rcv_flag = 1; 215 | } else { 216 | rcv_flag = 0; 217 | } 218 | 219 | if(rcv_flag) { 220 | for (int i = 0; i < rcv_cnt; ++i) { 221 | cmd_buf[cmd_cnt + i] = rcv_buf[i]; 222 | } 223 | cmd_cnt += rcv_cnt; 224 | //EMBARC_PRINTF("The count is %d\r\n", cmd_cnt); 225 | } 226 | 227 | if((rcv_flag == 0) && (pre_flag == 1)) { 228 | if(cmd_cnt == 6) { 229 | LED_ALL_FLAG = compare_chars(cmd_buf, LED_ALL_CMD, 6); 230 | LED_OFF_FLAG = compare_chars(cmd_buf, LED_OFF_CMD, 6); 231 | LED_RUN_FLAG = compare_chars(cmd_buf, LED_RUN_CMD, 6); 232 | LED_RED_FLAG = compare_chars(cmd_buf, LED_RED_CMD, 6); 233 | } else if(cmd_cnt == 9) { 234 | LED_WRI_FLAG = compare_chars(cmd_buf, LED_WRI_CMD, 6); 235 | } 236 | else { 237 | EMBARC_PRINTF("\r\nThe command is wrong. The count is %d\r\n", cmd_cnt); 238 | } 239 | 240 | cmd_buf[cmd_cnt] = '\r'; 241 | cmd_buf[cmd_cnt+1] = '\n'; 242 | cmd_buf[cmd_cnt+2] = '\0'; 243 | hm1x_write(hm1x, cmd_buf, cmd_cnt+2); 244 | 245 | cmd_cnt = 0; 246 | } 247 | 248 | pre_flag = rcv_flag; 249 | board_delay_ms(10, 1); 250 | 251 | if(LED_ALL_FLAG) { 252 | EMBARC_PRINTF("\r\nLED_ALL_FUN\r\n"); 253 | LED_ALL_FUN(); 254 | } else if (LED_OFF_FLAG) { 255 | EMBARC_PRINTF("\r\nLED_OFF_FUN\r\n"); 256 | LED_OFF_FUN(); 257 | } 258 | else if (LED_WRI_FLAG) { 259 | EMBARC_PRINTF("\r\nLED_WRI_FUN\r\n"); 260 | LED_WRI_FUN(cmd_buf+6, Num_CMD); 261 | } 262 | else if (LED_RUN_FLAG) { 263 | EMBARC_PRINTF("\r\nLED_RUN_FUN\r\n"); 264 | LED_RUN_FUN(); 265 | } else if (LED_RED_FLAG) { 266 | EMBARC_PRINTF("\r\nLED_RED_FUN\r\n"); 267 | LED_RED_FUN(); 268 | } 269 | 270 | } 271 | return E_SYS; 272 | } 273 | 274 | -------------------------------------------------------------------------------- /labs/lab7_ble_hm10/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= Ble_Test 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= emsk 12 | BD_VER ?= 22 13 | CUR_CORE ?= arcem7d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= mw 24 | #TOOLCHAIN ?= gnu 25 | 26 | EXT_DEV_LIST += ble/hm1x 27 | # 28 | # root dir of embARC 29 | # 30 | EMBARC_ROOT = ../../.. 31 | 32 | MID_SEL = common 33 | 34 | # application source dirs 35 | APPL_CSRC_DIR = . 36 | APPL_ASMSRC_DIR = . 37 | 38 | # application include dirs 39 | APPL_INC_DIR = . 40 | 41 | # include current project makefile 42 | COMMON_COMPILE_PREREQUISITES += makefile 43 | 44 | ### Options above must be added before include options.mk ### 45 | # include key embARC build system makefile 46 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 47 | include $(EMBARC_ROOT)/options/options.mk -------------------------------------------------------------------------------- /labs/lab7_ble_rn4020/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | 31 | #include "embARC.h" 32 | #include "embARC_debug.h" 33 | 34 | #include "board.h" 35 | #include "device/ip_hal/dev_uart.h" 36 | #include "rn4020.h" 37 | 38 | #define RN4020_PRV_SERV_HIGH_UUID 0x1122334455667788 39 | #define RN4020_PRV_SERV_LOW_UUID 0x9900AABBCCDDEEFF 40 | #define RN4020_PRV_CHAR_HIGH_UUID 0x0102030405060708 41 | #define RN4020_PRV_CHAR_LOW_UUID 0x09000A0B0C0D0E0F 42 | 43 | int32_t rn4020_set_prv_uuid(RN4020_DEF_PTR rn4020, uint64_t high_uuid, uint64_t low_uuid) 44 | { 45 | uint8_t i; 46 | uint8_t uuid_data[16]; 47 | 48 | for(i = 0; i < 16; i++) 49 | { 50 | if(i < 8) uuid_data[i] = (high_uuid >> ((7-i) << 3)) & 0xff; 51 | else uuid_data[i] = (low_uuid >> ((15-i) << 3)) & 0xff; 52 | } 53 | 54 | return rn4020_add_prv_service(rn4020, uuid_data); 55 | 56 | } 57 | 58 | int32_t rn4020_set_prv_char(RN4020_DEF_PTR rn4020, uint64_t high_uuid, uint64_t low_uuid, 59 | uint8_t property, uint8_t size, uint8_t security) 60 | { 61 | uint8_t i; 62 | uint8_t uuid_data[16]; 63 | 64 | for(i = 0; i < 16; i++) 65 | { 66 | if(i < 8) uuid_data[i] = (high_uuid >> ((7-i) << 3)) & 0xff; 67 | else uuid_data[i] = (low_uuid >> ((15-i) << 3)) & 0xff; 68 | } 69 | 70 | return rn4020_add_prv_char(rn4020, uuid_data, property, size, security); 71 | 72 | } 73 | 74 | int main(void) 75 | { 76 | 77 | uint32_t battery = 100; 78 | 79 | RN4020_DEFINE(rn4020_ble, DFSS_UART_3_ID, DFSS_GPIO_4B0_ID, 2, DFSS_GPIO_4B0_ID, 1, DFSS_GPIO_4B0_ID, 3); 80 | 81 | EMBARC_PRINTF("rn4020 test application\r\n"); 82 | 83 | rn4020_setup(rn4020_ble); 84 | rn4020_reset_to_factory(rn4020_ble); 85 | 86 | /* Set device Name */ 87 | rn4020_set_dev_name(rn4020_ble, "IoT DK"); 88 | 89 | /* Set device services */ 90 | rn4020_set_services(rn4020_ble, RN4020_SERVICE_DEVICE_INFORMATION | 91 | RN4020_SERVICE_BATTERY | 92 | RN4020_SERVICE_USER_DEFINED); 93 | 94 | rn4020_set_features(rn4020_ble, RN4020_FEATURE_SERVER_ONLY); 95 | rn4020_clear_private(rn4020_ble); 96 | 97 | /* Set private service UUID and private characteristic */ 98 | rn4020_set_prv_uuid(rn4020_ble, RN4020_PRV_SERV_HIGH_UUID, RN4020_PRV_SERV_LOW_UUID); 99 | rn4020_set_prv_char(rn4020_ble, RN4020_PRV_CHAR_HIGH_UUID, RN4020_PRV_CHAR_LOW_UUID, 0x18, 0x06, RN4020_PRIVATE_CHAR_SEC_NONE); 100 | 101 | /* Reboot RN4020 to make changes effective */ 102 | rn4020_reset(rn4020_ble); 103 | 104 | rn4020_refresh_handle_uuid_table(rn4020_ble); 105 | 106 | rn4020_advertise(rn4020_ble); 107 | 108 | 109 | while (1) { 110 | 111 | rn4020_battery_set_level(rn4020_ble, battery--); 112 | 113 | board_delay_ms(1000, 0); 114 | if (battery < 30) { 115 | battery = 100; 116 | } 117 | } 118 | 119 | return E_SYS; 120 | } 121 | 122 | -------------------------------------------------------------------------------- /labs/lab7_ble_rn4020/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= Ble_Rn4020_Test 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= iotdk 12 | BD_VER ?= 10 13 | CUR_CORE ?= arcem9d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= mw 24 | #TOOLCHAIN ?= gnu 25 | 26 | EXT_DEV_LIST += ble/rn4020 27 | # 28 | # root dir of embARC 29 | # 30 | EMBARC_ROOT = ../../.. 31 | 32 | MID_SEL = common 33 | 34 | # application source dirs 35 | APPL_CSRC_DIR = . 36 | APPL_ASMSRC_DIR = . 37 | 38 | # application include dirs 39 | APPL_INC_DIR = . 40 | 41 | # include current project makefile 42 | COMMON_COMPILE_PREREQUISITES += makefile 43 | 44 | ### Options above must be added before include options.mk ### 45 | # include key embARC build system makefile 46 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 47 | include $(EMBARC_ROOT)/options/options.mk -------------------------------------------------------------------------------- /labs/lab8_linker/link.cmd: -------------------------------------------------------------------------------- 1 | 2 | MEMORY { 3 | // Note: overlap of code and data spaces is not recommended since it makes 4 | // Address validity checking impossible with the debugger and simulator 5 | MyBlock: ORIGIN = 0x00002000, LENGTH = 32K 6 | MEMORY_BLOCK1: ORIGIN = 0x0010000, LENGTH = 64K 7 | MEMORY_BLOCK2: ORIGIN = 0x0020000, LENGTH = 128K 8 | } 9 | 10 | SECTIONS { 11 | GROUP: { 12 | modify_seg: {} 13 | }>MyBlock 14 | 15 | GROUP: { 16 | * (TEXT): {} 17 | }>MEMORY_BLOCK1 18 | 19 | GROUP: { 20 | .sdata?: {} 21 | .sbss?: { * {.sbss} } 22 | _SDA_BASE_=SIZEOF(.sdata)+SIZEOF(.sbss)<= 255?ADDR(.sdata):ADDR(.sdata)+256; 23 | * (LIT): {} 24 | *(DATA): {} 25 | *(BSS): {} 26 | .stack SIZE(DEFINED _STACKSIZE?_STACKSIZE:65536): {} 27 | .heap? SIZE(DEFINED _HEAPSIZE?_HEAPSIZE:0): {} 28 | }> MEMORY_BLOCK2 29 | } 30 | -------------------------------------------------------------------------------- /labs/lab8_linker/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | #pragma Code ("modify_seg") 31 | 32 | void modify(int list[], int size) 33 | { 34 | int out, in, temp; 35 | 36 | for(out=0; out list[in]) { 39 | temp = list[in]; 40 | list[in] = list[out]; 41 | list[out] = temp; 42 | } 43 | } 44 | #pragma Code () 45 | 46 | 47 | 48 | int data[] = {4, 8, 2, 6, 7, 8, 10, 5}; 49 | 50 | void main (void) { 51 | int nItems = sizeof(data) / sizeof(int); 52 | 53 | modify(data, nItems); 54 | } 55 | -------------------------------------------------------------------------------- /labs/lab9_freertos/FreeRTOSConfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd. 3 | All rights reserved 4 | 5 | VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 6 | 7 | *************************************************************************** 8 | * * 9 | * FreeRTOS provides completely free yet professionally developed, * 10 | * robust, strictly quality controlled, supported, and cross * 11 | * platform software that has become a de facto standard. * 12 | * * 13 | * Help yourself get started quickly and support the FreeRTOS * 14 | * project by purchasing a FreeRTOS tutorial book, reference * 15 | * manual, or both from: http://www.FreeRTOS.org/Documentation * 16 | * * 17 | * Thank you! * 18 | * * 19 | *************************************************************************** 20 | 21 | This file is part of the FreeRTOS distribution. 22 | 23 | FreeRTOS is free software; you can redistribute it and/or modify it under 24 | the terms of the GNU General Public License (version 2) as published by the 25 | Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. 26 | 27 | >>! NOTE: The modification to the GPL is included to allow you to distribute 28 | >>! a combined work that includes FreeRTOS without being obliged to provide 29 | >>! the source code for proprietary components outside of the FreeRTOS 30 | >>! kernel. 31 | 32 | FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY 33 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 34 | FOR A PARTICULAR PURPOSE. Full license text is available from the following 35 | link: http://www.freertos.org/a00114.html 36 | 37 | 1 tab == 4 spaces! 38 | 39 | *************************************************************************** 40 | * * 41 | * Having a problem? Start by reading the FAQ "My application does * 42 | * not run, what could be wrong?" * 43 | * * 44 | * http://www.FreeRTOS.org/FAQHelp.html * 45 | * * 46 | *************************************************************************** 47 | 48 | http://www.FreeRTOS.org - Documentation, books, training, latest versions, 49 | license and Real Time Engineers Ltd. contact details. 50 | 51 | http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, 52 | including FreeRTOS+Trace - an indispensable productivity tool, a DOS 53 | compatible FAT file system, and our tiny thread aware UDP/IP stack. 54 | 55 | http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High 56 | Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS 57 | licenses offer ticketed support, indemnification and middleware. 58 | 59 | http://www.SafeRTOS.com - High Integrity Systems also provide a safety 60 | engineered and independently SIL3 certified version for use in safety and 61 | mission critical applications that require provable dependability. 62 | 63 | 1 tab == 4 spaces! 64 | */ 65 | 66 | #ifndef FREERTOS_CONFIG_H 67 | #define FREERTOS_CONFIG_H 68 | 69 | #include 70 | /*----------------------------------------------------------- 71 | * Application specific definitions. 72 | * 73 | * These definitions should be adjusted for your particular hardware and 74 | * application requirements. 75 | * 76 | * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE 77 | * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. 78 | * 79 | * See http://www.freertos.org/a00110.html. 80 | *----------------------------------------------------------*/ 81 | 82 | #define configUSE_PREEMPTION 1 83 | #define configUSE_IDLE_HOOK 0 84 | #define configUSE_TICK_HOOK 0 85 | #define configCPU_CLOCK_HZ ( ( unsigned long ) BOARD_CPU_CLOCK ) 86 | #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) 87 | #define configMAX_PRIORITIES ( 4 ) 88 | #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 104 ) 89 | #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 18 * 1024 ) ) 90 | #define configMAX_TASK_NAME_LEN ( 10 ) 91 | #define configUSE_TRACE_FACILITY 0 92 | #define configUSE_16_BIT_TICKS 0 93 | #define configIDLE_SHOULD_YIELD 1 94 | #define configUSE_MUTEXES 1 95 | 96 | /* Co-routine definitions. */ 97 | #define configUSE_CO_ROUTINES 0 98 | #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) 99 | 100 | 101 | /* Set the following definitions to 1 to include the API function, or zero 102 | to exclude the API function. */ 103 | 104 | #define INCLUDE_vTaskPrioritySet 1 105 | #define INCLUDE_uxTaskPriorityGet 1 106 | #define INCLUDE_vTaskDelete 1 107 | #define INCLUDE_vTaskCleanUpResources 0 108 | #define INCLUDE_vTaskSuspend 1 109 | #define INCLUDE_vTaskDelayUntil 1 110 | #define INCLUDE_vTaskDelay 1 111 | #define INCLUDE_xTaskGetCurrentTaskHandle 1 112 | 113 | #endif /* FREERTOS_CONFIG_H */ -------------------------------------------------------------------------------- /labs/lab9_freertos/main.c: -------------------------------------------------------------------------------- 1 | /* ------------------------------------------ 2 | * Copyright (c) 2018, Synopsys, Inc. All rights reserved. 3 | 4 | * Redistribution and use in source and binary forms, with or without modification, 5 | * are permitted provided that the following conditions are met: 6 | 7 | * 1) Redistributions of source code must retain the above copyright notice, this 8 | * list of conditions and the following disclaimer. 9 | 10 | * 2) Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation and/or 12 | * other materials provided with the distribution. 13 | 14 | * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may 15 | * be used to endorse or promote products derived from this software without 16 | * specific prior written permission. 17 | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | * 29 | --------------------------------------------- */ 30 | #include "embARC.h" 31 | #include "embARC_debug.h" 32 | #include "os_hal_inc.h" 33 | #include 34 | 35 | static void task1(void *par); 36 | static void task2(void *par); 37 | static void task3(void *par); 38 | 39 | #define TSK_PRIOR_1 (configMAX_PRIORITIES-1) 40 | #define TSK_PRIOR_2 (configMAX_PRIORITIES-2) 41 | #define TSK_PRIOR_3 (configMAX_PRIORITIES-3) 42 | 43 | // Semaphores 44 | static SemaphoreHandle_t sem1_id; 45 | 46 | // Queues 47 | static QueueHandle_t dtq1_id; 48 | 49 | // Task IDs 50 | static TaskHandle_t task1_handle = NULL; 51 | static TaskHandle_t task2_handle = NULL; 52 | static TaskHandle_t task3_handle = NULL; 53 | 54 | /** 55 | * \brief call FreeRTOS API, create and start tasks 56 | */ 57 | int main(void) 58 | { 59 | 60 | vTaskSuspendAll(); 61 | 62 | // Create Tasks 63 | if (xTaskCreate(task1, "task1", 128, (void *)1, TSK_PRIOR_1, &task1_handle) 64 | != pdPASS) { /*!< FreeRTOS xTaskCreate() API function */ 65 | EMBARC_PRINTF("Create task1 Failed\r\n"); 66 | return -1; 67 | } else { 68 | EMBARC_PRINTF("Create task1 Successfully\r\n"); 69 | } 70 | 71 | if (xTaskCreate(task2, "task2", 128, (void *)2, TSK_PRIOR_2, &task2_handle) 72 | != pdPASS) { /*!< FreeRTOS xTaskCreate() API function */ 73 | EMBARC_PRINTF("Create task2 Failed\r\n"); 74 | return -1; 75 | } else { 76 | EMBARC_PRINTF("Create task2 Successfully\r\n"); 77 | } 78 | 79 | if (xTaskCreate(task3, "task3", 128, (void *)3, TSK_PRIOR_3, &task3_handle) 80 | != pdPASS) { /*!< FreeRTOS xTaskCreate() API function */ 81 | EMBARC_PRINTF("Create task3 Failed\r\n"); 82 | return -1; 83 | } else { 84 | EMBARC_PRINTF("Create task3 Successfully\r\n"); 85 | } 86 | 87 | // Create Semaphores 88 | sem1_id = xSemaphoreCreateBinary(); 89 | xSemaphoreGive(sem1_id); 90 | 91 | // Create Queues 92 | dtq1_id = xQueueCreate(8, sizeof(uint32_t)); 93 | 94 | xTaskResumeAll(); 95 | 96 | vTaskSuspend(NULL); 97 | 98 | return 0; 99 | } 100 | 101 | static void task1(void *par) 102 | { 103 | uint32_t led_val = 0; 104 | 105 | static portTickType xLastWakeTime; 106 | const portTickType xFrequency = pdMS_TO_TICKS(10); 107 | 108 | xLastWakeTime = xTaskGetTickCount(); 109 | 110 | while (1) { 111 | /* delay 10ms */ 112 | vTaskDelayUntil( &xLastWakeTime,xFrequency ); 113 | 114 | xQueuePeek(dtq1_id, (void *)(&led_val), portMAX_DELAY); 115 | 116 | if (led_val >= 0x0100) { 117 | xSemaphoreGive(sem1_id); 118 | } 119 | } 120 | } 121 | 122 | static void task2(void *par) 123 | { 124 | uint32_t led_val = 0x0001; 125 | 126 | static portTickType xLastWakeTime; 127 | const portTickType xFrequency = pdMS_TO_TICKS(100); 128 | 129 | xLastWakeTime = xTaskGetTickCount(); 130 | 131 | while (1) { 132 | /* delay 100ms */ 133 | vTaskDelayUntil( &xLastWakeTime,xFrequency ); 134 | 135 | xQueueSend(dtq1_id, (void *)(&led_val), portMAX_DELAY); 136 | led_val <<= 1; 137 | 138 | if (sem1_id != NULL) { 139 | /* if semapohre is invalid, wait 10 more ticks */ 140 | if( xSemaphoreTake( sem1_id, ( TickType_t ) 10 ) == pdTRUE ) 141 | { 142 | xQueueReset(dtq1_id); 143 | led_val = 0x0001; 144 | } 145 | } 146 | } 147 | } 148 | 149 | static void task3(void *par) 150 | { 151 | uint32_t led_val = 0; 152 | 153 | static portTickType xLastWakeTime; 154 | const portTickType xFrequency = pdMS_TO_TICKS(200); 155 | 156 | xLastWakeTime = xTaskGetTickCount(); 157 | 158 | while (1) { 159 | /* delay 200ms */ 160 | vTaskDelayUntil( &xLastWakeTime,xFrequency ); 161 | 162 | xQueueReceive(dtq1_id, (void *)(&led_val), portMAX_DELAY); 163 | 164 | led_write(led_val, BOARD_LED_MASK); 165 | 166 | EMBARC_PRINTF("\r\n The led_val is 0x%x \r\n",led_val); 167 | } 168 | 169 | } 170 | -------------------------------------------------------------------------------- /labs/lab9_freertos/makefile: -------------------------------------------------------------------------------- 1 | # Application name 2 | APPL ?= lab9_freertos 3 | 4 | # Optimization Level 5 | # Please Refer to toolchain_xxx.mk for this option 6 | OLEVEL ?= O2 7 | 8 | ## 9 | # Current Board And Core 10 | ## 11 | BOARD ?= emsk 12 | BD_VER ?= 22 13 | CUR_CORE ?= arcem7d 14 | 15 | ## 16 | # select debugging jtag 17 | ## 18 | JTAG ?= usb 19 | 20 | ## 21 | # Set toolchain 22 | ## 23 | TOOLCHAIN ?= gnu 24 | 25 | 26 | # Selected OS 27 | OS_SEL ?= freertos 28 | 29 | # 30 | # root dir of embARC 31 | # 32 | EMBARC_ROOT = ../../.. 33 | 34 | MID_SEL = common 35 | 36 | # application source dirs 37 | APPL_CSRC_DIR = . 38 | APPL_ASMSRC_DIR = . 39 | 40 | # application include dirs 41 | APPL_INC_DIR = . 42 | 43 | # include current project makefile 44 | COMMON_COMPILE_PREREQUISITES += makefile 45 | 46 | ### Options above must be added before include options.mk ### 47 | # include key embARC build system makefile 48 | override EMBARC_ROOT := $(strip $(subst \,/,$(EMBARC_ROOT))) 49 | include $(EMBARC_ROOT)/options/options.mk 50 | -------------------------------------------------------------------------------- /labs/testcase.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # This file contails the supported tests and the test scenario for each test 3 | # Each tests block can define the follwing key/value 4 | # tags: 5 | # a set of string tags. Usually pertains to features and peripherals that 6 | # platform support. Command line invocations of this script can filter the 7 | # set of tests to run based on tag 8 | # skip: 9 | # skip test unconditionally 10 | # build_only: 11 | # if true, don't try to run the test 12 | # platform_allow: 13 | # set of platforms that this test should only be run for 14 | # platform_exclude: 15 | # set of platforms that this test should not be run for 16 | # core_exlude: 17 | # set of cores that this test should not be run for, the 18 | # core should format as __ 19 | # extra_args: 20 | # extra arguments to pass to Make when building or running the test 21 | # ignore_overflowed_error: 22 | # if true, test result will be marked as skipped when test fails 23 | # because of overflow 24 | # 25 | testcases: 26 | arc_labs.labs.lab1_core_test: 27 | build_only: false 28 | arc_labs.labs.dsp_lab1_compiler_opt: 29 | build_only: false 30 | platform_exclude: emsk 31 | arc_labs.labs.dsp_lab2_fxapi: 32 | tags: dsp 33 | build_only: false 34 | platform_exclude: emsk 35 | arc_labs.labs.dsp_lab3_dsp_lib: 36 | tags: dsp 37 | build_only: false 38 | platform_exclude: emsk 39 | arc_labs.labs.lab3_timer: 40 | tags: timer 41 | build_only: false 42 | arc_labs.labs.lab4_interrupt.part1: 43 | tags: timer 44 | build_only: false 45 | arc_labs.labs.lab4_interrupt.part2: 46 | tags: timer 47 | build_only: false 48 | arc_labs.labs.lab5_emsk: 49 | build_only: false 50 | platform_allow: 51 | emsk: 23 52 | arc_labs.labs.lab5_iotdk: 53 | build_only: false 54 | platform_allow: 55 | iotdk: 10 56 | arc_labs.labs.lab6_ble_rn4020: 57 | tags: uart 58 | build_only: false 59 | platform_exclude: nsim 60 | arc_labs.labs.lab7_ble_rn4020: 61 | tags: uart 62 | build_only: false 63 | platform_exclude: nsim 64 | arc_labs.labs.lab8_linker: 65 | build_only: false 66 | arc_labs.labs.lab9_freertos: 67 | ignore_overflowed_error: true 68 | build_only: false 69 | platform_exclude: nsim 70 | arc_labs.labs.lab10_temp_monitor.esp8266_wifi: 71 | tags: uart 72 | ignore_overflowed_error: true 73 | build_only: false 74 | platform_exclude: nsim 75 | arc_labs.labs.lab10_temp_monitor.pmwifi: 76 | tags: uart 77 | ignore_overflowed_error: true 78 | build_only: false 79 | platform_exclude: nsim 80 | --------------------------------------------------------------------------------