diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..42489d46 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Configuration to handle line endings for working with Windows and Unix +# Reference: +# https://help.github.com/articles/dealing-with-line-endings/ +# https://git-scm.com/docs/gitattributes#_checking_out_and_checking_in + +* text=auto + +*.c text +*.cpp text +*.h text +*.hpp text +*.ino text +*.py text + + +*.sh text eol=lf +*.bat text eol=crlf \ No newline at end of file diff --git a/.github/workflows/hil-unity-checks.yml b/.github/workflows/hil-unity-checks.yml index 08d5407f..3e1aa01b 100644 --- a/.github/workflows/hil-unity-checks.yml +++ b/.github/workflows/hil-unity-checks.yml @@ -7,6 +7,9 @@ on: env: TEST_VERSION: 1.0.0 +permissions: + contents: write + # This template runes multiple workflows jobs: @@ -27,6 +30,9 @@ jobs: # checkout the latest github action code - name: Checkout actions uses: actions/checkout@v4 + with: + token: ${{ secrets.UNITY_TOKEN }} + submodules: recursive # checkout the latest arduino-cli compiler - name: Setup Arduino CLI @@ -51,7 +57,7 @@ jobs: ./py_checkusb.py --switch repo --namelist $REPO --onoff on # set the hil-unity-checks - hil=$(./py_checkusb.py --readyaml $GITHUB_WORKSPACE/tests/unity/hil-unity-checklist.yaml --json) + hil=$(./py_checkusb.py --readyaml $GITHUB_WORKSPACE/tests/hil-unity-checklist.yaml --json) echo "hil=${hil}" >> $GITHUB_OUTPUT # fetch unity libraries @@ -97,6 +103,9 @@ jobs: # checkout the latest github action code - name: Checkout actions uses: actions/checkout@v4 + with: + token: ${{ secrets.UNITY_TOKEN }} + submodules: recursive # setup environment - name: Environment @@ -168,11 +177,11 @@ jobs: # loop over all tests for one example and compile7flash the devices readarray -t TESTS < <(echo $lib | jq ".\"${LIB}\".\"${EXAMPLE}\"[]" -r --compact-output) for ((idx=0; idx<${#TESTS[@]}; ++idx)); do - cd $GITHUB_WORKSPACE/tests/unity/ + cd $GITHUB_WORKSPACE/tests/arduino-core-tests/ echo "==============================================================================================================" - echo "Run on index $idx for TEST: ${TESTS[idx]} under EXAMPLE: ${EXAMPLE} and LIB: ${LIB}" + echo "Run on index $idx for TEST: ${TESTS[idx]} under EXAMPLE: ${EXAMPLE} and LIB: ${LIB} on port: ${PORTS[idx]}" echo "==============================================================================================================" - make FQBN=${{ env.fqbn }} PORT=${PORTS[idx]} UNITY_PATH=/opt/runner_support/Unity_github ${TESTS[idx]} + make FQBN=${{ env.fqbn }} PORT=${PORTS[idx]} UNITY_PATH=/opt/Unity ${TESTS[idx]} mkdir -p ~/artefact/${LIB}/${EXAMPLE}/${TESTS[idx]}/ mv ./build/build/* ~/artefact/${LIB}/${EXAMPLE}/${TESTS[idx]}/. echo "==============================================================================================================" diff --git a/.gitignore b/.gitignore index 2571dc16..7ed65407 100644 --- a/.gitignore +++ b/.gitignore @@ -1,19 +1,21 @@ -.history -.vscode - -# build folder -pkg_build -build - -# python -**/__pycache__/ -venv/ - -# code-check reports -clang-tidy-report.txt - -scan-build-reports/ - -cppcheck_reports/ -cppcheck.checkers -err.xml \ No newline at end of file +# vscode +.history +.vscode +.editorconfig + +# build folder +pkg_build +build + +# python +**/__pycache__/ +venv/ + +# code-check reports +clang-tidy-report.txt + +scan-build-reports/ + +cppcheck_reports/ +cppcheck.checkers +err.xml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..743eb3c3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "arduino-core-tests"] + path = tests/arduino-core-tests + url = https://github.com/Infineon/arduino-core-tests.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7168fee0..909dd62f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,47 +1,55 @@ -# Contributing to XMC for Arduino -First important point: **All Contributions** are welcomed :open_hands:. - -Please contribute and raise issues via the [github repository](https://github.com/Infineon/XMC-for-Arduino/tree/master) - -### Overview for Contributors - -- Start your contribution by creating a [fork](https://github.com/Infineon/XMC-for-Arduino/fork) of this repository -- It's recommended to create a separate branch for your contribution in your fork -- Once your contribution is ready & tested, please create a [Pull Request](https://github.com/Infineon/XMC-for-Arduino/compare) to the master branch -- Once we merged your changes to the master branch, they are automatically included in the next release - -### Testing in Arduino IDE (on Windows) -Clone the repository in Arduino folder: -- Open Arduino and install any version of this project as described [here](https://xmc-arduino.readthedocs.io/en/latest/installation-instructions.html). -- Open the installation location in your Arduino program folder, e.g. -`C:\Users\\AppData\Local\Arduino15\packages\Infineon\hardware\xmc` -- Open git bash, type command: -`git clone ` - -This allows quick testing of local changes during development. - -[!TIP] -If you encounter strange behavior with Arduino IDE during development, try cleaning up the cache: -* Windows: `C:\User\"username"\AppData\Roaming\arduino-ide` -* Linux: `~/.config/arduino-ide` -* macOS: `~/Library/Application Support/arduino-ide/` - -### Automated Build Checks - -Currently a Github workflow is used for automatic compilation checking and releasing. Workflows are defined [here](https://github.com/Infineon/XMC-for-Arduino/tree/master/.github/workflows). -Before opening a Pull Request for your contribution, please add a git tag in the format `Vx.y.z` (e.g. V3.3.0) to trigger the release process in your fork and pass the compilation tests. - -### Creating and Maintaining Third Party Libraries -#### Basics -The Arduino IDE allows for external libraries to be added to support specific devices and functions which are not part of the core setup. For details on creating libraries see the -[Arduino library specifications](https://arduino.github.io/arduino-cli/library-specification/). If you add additional libraries to this project, make sure to [document them](https://xmc-arduino.readthedocs.io/en/latest/builtin-libraries.html) accordingly. - -#### XMC-for-Arduino Configuration -To ensure that a library specific to one architecture or board type is only compiled when a supporting board is set up, this specification includes a setting for *architecture* in the *library.properties* file. - -When creating or maintaining third party or external libraries for XMC-for-Arduino please use this setting: -~~~ -architecture=xmc -~~~ - -If your library also supports other boards and architectures, add those in as well. \ No newline at end of file +# Contributing to XMC for Arduino +First important point: **All Contributions** are welcomed :open_hands:. + +Please contribute and raise issues via the [github repository](https://github.com/Infineon/XMC-for-Arduino/tree/master) + +## Overview for Contributors + +- Start your contribution by creating a [fork](https://github.com/Infineon/XMC-for-Arduino/fork) of this repository +- It's recommended to create a separate branch for your contribution in your fork +- Once your contribution is ready & tested, please create a [Pull Request](https://github.com/Infineon/XMC-for-Arduino/compare) to the master branch +- Once we merged your changes to the master branch, they are automatically included in the next release + +## Install the BSP under development (on Windows) +Clone the repository in Arduino folder: +- Open Arduino and install any version of this project as described [here](https://xmc-arduino.readthedocs.io/en/latest/installation-instructions.html). +- Open the installation location in your Arduino program folder, e.g. +`C:\Users\\AppData\Local\Arduino15\packages\Infineon\hardware\xmc` +- Open git bash, type command: +`git clone ` + +This allows quick testing of local changes during development. + +[!TIP] +If you encounter strange behavior with Arduino IDE during development, try cleaning up the cache: +* Windows: `C:\User\"username"\AppData\Roaming\arduino-ide` +* Linux: `~/.config/arduino-ide` +* macOS: `~/Library/Application Support/arduino-ide/` + +## Automated Build Checks + +Currently a Github workflow is used for automatic compilation checking and releasing. Workflows are defined [here](https://github.com/Infineon/XMC-for-Arduino/tree/master/.github/workflows). +Before opening a Pull Request for your contribution, please add a git tag in the format `Vx.y.z` (e.g. V3.3.0) to trigger the release process in your fork and pass the compilation tests. + +## Creating and Maintaining Third Party Libraries +### Basics +The Arduino IDE allows for external libraries to be added to support specific devices and functions which are not part of the core setup. For details on creating libraries see the +[Arduino library specifications](https://arduino.github.io/arduino-cli/library-specification/). If you add additional libraries to this project, make sure to [document them](https://xmc-arduino.readthedocs.io/en/latest/builtin-libraries.html) accordingly. + +### XMC-for-Arduino Configuration +To ensure that a library specific to one architecture or board type is only compiled when a supporting board is set up, this specification includes a setting for *architecture* in the *library.properties* file. + +When creating or maintaining third party or external libraries for XMC-for-Arduino please use this setting: +~~~ +architecture=xmc +~~~ + +If your library also supports other boards and architectures, add those in as well. + +## Validation test +To test the XMC4arduino, we used unity to test some of the features of the arduino core/builtin library. +Tests are located in tests\unity and included as submodule in this project. Run `git submodule update --init --recursive` to update them. If you are nor familiar with submodules, check out: https://git-scm.com/book/en/v2/Git-Tools-Submodules + +## Code checks (WIP) +Refer to libraries\CAN\Makefile.codecheck +* Regarding formatting, we currently use [pre-commit](https://pre-commit.com/) to automatically run clang-formatting to format all c/c++ code. Please install this python package, and follow the quick start (the pre-commit configuration file is already there). You should be able to format your code automatically on git commit! \ No newline at end of file diff --git a/README.md b/README.md index c34830a9..9748f32f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![Compilation Status](https://github.com/Infineon/XMC-for-Arduino/actions/workflows/compile-platform-examples.yml/badge.svg) [![Documentation Status](https://readthedocs.org/projects/xmc-arduino/badge/?version=latest)](https://xmc-arduino.readthedocs.io/en/latest/?badge=latest) +[![Hil unity library checks](https://github.com/Infineon/XMC-for-Arduino/actions/workflows/hil-unity-checks.yml/badge.svg)](https://github.com/Infineon/XMC-for-Arduino/actions/workflows/hil-unity-checks.yml) This project integrates Infineon's 32-bit XMC™ Industrial Arm® Cortex®-M Microcontroller into the [Arduino](https://www.arduino.cc/en/Guide/Introduction) ecosystem. diff --git a/cores/HardwareSerial.cpp b/cores/HardwareSerial.cpp index 91b350bf..685f0558 100644 --- a/cores/HardwareSerial.cpp +++ b/cores/HardwareSerial.cpp @@ -161,23 +161,33 @@ size_t HardwareSerial::write(const uint8_t uc_data) { XMC_USIC_CH_TBUF_STATUS_BUSY) || (_tx_buffer->_iTail != _tx_buffer->_iHead)) #endif -{ - // If busy we buffer - int nextWrite = _tx_buffer->_iHead + 1; - if( nextWrite >= SERIAL_BUFFER_SIZE ) - nextWrite = 0; - - //This should always be false but in case transmission is completed before buffer, we need to reenable IRQ - if( XMC_USIC_CH_GetTransmitBufferStatus( _XMC_UART_config->channel ) != XMC_USIC_CH_TBUF_STATUS_BUSY ) { - XMC_UART_CH_EnableEvent( _XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER ); - XMC_UART_CH_Transmit( _XMC_UART_config->channel, _tx_buffer->_aucBuffer[ _tx_buffer->_iTail ] ); - _tx_buffer->_iTail++; - if(_tx_buffer->_iTail >= SERIAL_BUFFER_SIZE) - _tx_buffer->_iTail = _tx_buffer->_iTail - SERIAL_BUFFER_SIZE; // If iTail is larger than Serial Buffer Size calculate the correct index value - } - - while( _tx_buffer->_iTail == nextWrite ) - ; // Spin locks if we're about to overwrite the buffer. This continues once the data is sent + { + // If busy we buffer + int nextWrite = _tx_buffer->_iHead + 1; + if (nextWrite >= SERIAL_BUFFER_SIZE) + nextWrite = 0; + + // This should always be false but in case transmission is completed before buffer, we need + // to reenable IRQ + if (XMC_USIC_CH_GetTransmitBufferStatus(_XMC_UART_config->channel) != + XMC_USIC_CH_TBUF_STATUS_BUSY) { + XMC_UART_CH_EnableEvent(_XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER); + XMC_UART_CH_Transmit(_XMC_UART_config->channel, + _tx_buffer->_aucBuffer[_tx_buffer->_iTail]); + _tx_buffer->_iTail++; + if (_tx_buffer->_iTail >= SERIAL_BUFFER_SIZE) + _tx_buffer->_iTail %= SERIAL_BUFFER_SIZE; // If iTail is larger than Serial Buffer + // Size calculate the correct index value + } + + unsigned long startTime = millis(); + while (_tx_buffer->_iTail == nextWrite) { + if (millis() - startTime > 1000) { + return 0; // Spin locks if we're about to overwrite the buffer. This continues once + // the data is + // sent + } + } _tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc_data; _tx_buffer->_iHead = nextWrite; @@ -210,22 +220,20 @@ void HardwareSerial::IrqHandler(void) { XMC_UART_CH_ClearStatusFlag(_XMC_UART_config->channel, XMC_UART_CH_STATUS_FLAG_TRANSMIT_BUFFER_INDICATION); - if( _tx_buffer->_iTail != _tx_buffer->_iHead ) - { - XMC_UART_CH_Transmit( _XMC_UART_config->channel, - _tx_buffer->_aucBuffer[ _tx_buffer->_iTail ] ); - _tx_buffer->_iTail++; - if( _tx_buffer->_iTail >= SERIAL_BUFFER_SIZE ) - _tx_buffer->_iTail = 0; + if (_tx_buffer->_iTail != _tx_buffer->_iHead) { + XMC_UART_CH_Transmit(_XMC_UART_config->channel, + _tx_buffer->_aucBuffer[_tx_buffer->_iTail]); + _tx_buffer->_iTail++; + if (_tx_buffer->_iTail >= SERIAL_BUFFER_SIZE) + _tx_buffer->_iTail %= SERIAL_BUFFER_SIZE; // If iTail is larger than Serial Buffer + // Size calculate the correct index value + } else { + // Mask off transmit interrupt so we don't get it any more + XMC_UART_CH_DisableEvent(_XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER); } - else { - // Mask off transmit interrupt so we don't get it any more - XMC_UART_CH_DisableEvent( _XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER ); - } } } //**************************************************************************** // END OF FILE -//**************************************************************************** - +//**************************************************************************** \ No newline at end of file diff --git a/tests/Makefile.test b/tests/Makefile.test new file mode 100644 index 00000000..794242ca --- /dev/null +++ b/tests/Makefile.test @@ -0,0 +1,23 @@ +### Build commands +### ! Please note that you need to change the port and path of Unity as appropriate ! + +### Unit tests + +##CAN + +# 1 board, no wire +make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM42 UNITY_PATH=\Unity test_can_single monitor + +# 2 boards +make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM42 UNITY_PATH=\Unity test_can_connected2_node2 monitor +make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM41 UNITY_PATH=\Unity test_can_connected2_node1 monitor + + +## IIC + +# 1 board "talking to itself", wire needed +make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM28 UNITY_PATH=\Unity test_wire_connected1_pingpong monitor + +# 2 boards +make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM85 test_wire_connected2_masterpingpong monitor +make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM28 UNITY_ \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index ffeba949..55821fd4 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,63 +1,28 @@ -# Test Environment - -## Develop on Windows -Clone the repository in arduino folder: -- Open Arduino and install any Infineon XMC library (e.g. 2.2.0) -- Open the library location in Arduino program folder -`C:\Users\"USERNAME"\AppData\Local\Arduino15\packages\Infineon\hardware\xmc` -- Open git bash, type command: -`git clone "HTTP_SSH_REPOSITORY" "LIBRARY_VERSION (e.g. 2.2.0)"` - -This is a workaround for current local compilation/testing. - -## Test on WSL -To be able to use some tools (make, clang, gcc...) easier on Linux, WSL is needed. -Since now we still compile the code with arduino-cli.exe on windows, in order to useLinux commands/ build tools, a symbolic link is created to eunsure the changes are immediately reflected in the other. -In WSL, you can create a symbolic link pointing to your windows project folder: -`ln -s /mnt/c/Users//AppData/Local/Arduino15/packages/Infineon/hardware/xmc /home//project` - -## (legacy) Manual tests -located in `tests/manual`. The application level `.ino` files for testing purposes. - -## Example and Unity tests - -Currently, we are using Unity as the testing framework. You can find more information about Unity at [Unity](https://www.throwtheswitch.org/unity). - -### Pre-conditions - -- **Arduino CLI** - Download `arduino-cli.exe` for Windows from [here](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip) or refer to the [official installation guide](https://arduino.github.io/arduino-cli/1.0/installation/#download). - -- **Unity** - Install Unity from [Throw The Switch](https://www.throwtheswitch.org/unity) or clone the repository from GitHub. - -### Folder stucture -``` -│ Makefile -│ Makefile.test -│ -└───src - │ Test_common_includes.h - │ Test_main.ino - │ unity_config.h - │ unity_ifx.h - │ - ├───corelibs - │ ├───CAN - │ │ - │ ├───Wire - │ │ - │ └───... - │ - └───utils - unity_ifx.cpp - Utilities.cpp - Utilities.hpp -``` - -### Running test -To run the tests, use the commands example in `Makefile.test`. -For more details or to add new tests, please refer to the `Makefile`. - -# Code checks (WIP) -Refer to libraries\CAN\Makefile.codecheck \ No newline at end of file +# Test Environment + +## Develop on Windows +Clone the repository in arduino folder: +- Open Arduino and install any Infineon XMC library (e.g. 2.2.0) +- Open the library location in Arduino program folder +`C:\Users\"USERNAME"\AppData\Local\Arduino15\packages\Infineon\hardware\xmc` +- Open git bash, type command: +`git clone "HTTP_SSH_REPOSITORY" "LIBRARY_VERSION (e.g. 2.2.0)"` + +This is a workaround for current local compilation/testing. + +## Test on WSL +To be able to use some tools (make, clang, gcc...) easier on Linux, WSL is needed. +Since now we still compile the code with arduino-cli.exe on windows, in order to useLinux commands/ build tools, a symbolic link is created to eunsure the changes are immediately reflected in the other. +In WSL, you can create a symbolic link pointing to your windows project folder: +`ln -s /mnt/c/Users//AppData/Local/Arduino15/packages/Infineon/hardware/xmc /home//project` + +## (legacy) Manual tests +located in `tests/manual`. The application level `.ino` files for testing purposes. + +## Unity tests + +Currently, we are using Unity as the testing framework. You can find more information about Unity at [Unity](https://www.throwtheswitch.org/unity). +Please refer to `unity\README.md` for more details. + +To run the tests, use the commands example in `Makefile.test`. + diff --git a/tests/arduino-core-tests b/tests/arduino-core-tests new file mode 160000 index 00000000..6f62097d --- /dev/null +++ b/tests/arduino-core-tests @@ -0,0 +1 @@ +Subproject commit 6f62097d72522b52848e3f24d01220afcbfae1cc diff --git a/tests/hil-unity-checklist.yaml b/tests/hil-unity-checklist.yaml new file mode 100644 index 00000000..1e60176d --- /dev/null +++ b/tests/hil-unity-checklist.yaml @@ -0,0 +1,35 @@ +Infineon.xmc.XMC4700_Relax_Kit: + CAN: + 1: + - "test_can_connected2_node2" + - "test_can_connected2_node1" + 2: + - "test_can_single" + + Wire: + 1: + - "test_wire_connected2_slavepingpong" + - "test_wire_connected2_masterpingpong" + 2: + - "test_wire_connected1_pingpong" + + +Infineon.xmc.XMC1400_XMC2GO: + CAN: + 1: + - "test_can_connected2_node2" + - "test_can_connected2_node1" + 2: + - "test_can_single" + + Wire: + 1: + - "test_wire_connected2_slavepingpong" + - "test_wire_connected2_masterpingpong" + + +Infineon.xmc.XMC1100_XMC2GO: + Wire: + 1: + - "test_wire_connected2_slavepingpong" + - "test_wire_connected2_masterpingpong" diff --git a/tests/unity/Makefile b/tests/unity/Makefile deleted file mode 100644 index d19bc7f6..00000000 --- a/tests/unity/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -FQBN ?= -PORT ?= -TESTS ?= -UNITY_PATH ?= -BAUD_RATE ?= 115200 - -$(info FQBN : $(FQBN)) -$(info PORT : $(PORT)) -$(info UNITY_PATH : $(UNITY_PATH)) -$(info BAUD_RATE : $(BAUD_RATE)) - - -TESTS_CONNECTED=-DTEST_CAN_CONNECTED -TESTS_NOT_CONNECTED=-DTEST_CAN - -CAN: TESTS=-DTEST_CAN -CAN_connected: TESTS=-DTEST_CAN -DTEST_CAN_CONNECTED -CAN_connected_node1: TESTS=-DTEST_CAN_CONNECTED_NODE1 -CAN_connected_node2: TESTS=-DTEST_CAN_CONNECTED_NODE2 -CAN_connected CAN CAN_connected_node1 CAN_connected_node2: unity_corelibs_can flash - -test_all: TESTS=$(TESTS_CONNECTED) $(TESTS_NOT_CONNECTED) -test_connected: TESTS=$(TESTS_CONNECTED) -test: TESTS=$(TESTS_NOT_CONNECTED) - -test_all \ -test_connected \ -test: unity_corelibs flash - - -EXAMPLES= CANReceiver CANReceiverCallback CANSender CANLoopBack - -clean: - -rm -rf build/* - -arduino: clean - mkdir -p build -# copy library files (not needed for bundled libraries) -# cp -r src/* build -# find src -name '*.[hc]*' -a \( \! -name '*mtb*' \) -print -exec cp {} build \; -.PHONY: CANReceiver CANReceiverCallback CANSender CANLoopBack -CANReceiver: arduino - cp examples/CANReceiver/CANReceiver.ino build/build.ino - -CANReceiverCallback: arduino - cp examples/CANReceiverCallback/CANReceiverCallback.ino build/build.ino - -CANSender: arduino - cp examples/CANSender/CANSender.ino build/build.ino - -CANLoopBack: arduino - cp examples/CANLoopBack/CANLoopBack.ino build/build.ino - - -# install Unity from https://www.throwtheswitch.org/unity or git -unity_corelibs: arduino -ifeq ($(UNITY_PATH),) - $(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !") -else - find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \; - find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \; - cp src/corelibs/Test_main.ino build/build.ino -endif - -unity_corelibs_can: arduino -ifeq ($(UNITY_PATH),) - $(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !") -else - find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \; - find src/corelibs/CAN -name '*.[hc]*' -exec \cp {} build \; - find src/utils -name '*.[hc]*' -exec \cp {} build \; - find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \; - cp src/Test_main.ino build/build.ino -endif - - - -# For WSL and Windows : -# download arduino-cli.exe from : https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip -compile: -ifeq ($(FQBN),) - $(error "Must set variable FQBN in order to be able to compile Arduino sketches !") -else -# CAUTION : only use '=' when assigning values to vars, not '+=' - arduino-cli.exe compile \ - --clean \ - --log \ - --warnings all \ - --fqbn $(FQBN) \ - --build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \ - --build-property compiler.cpp.extra_flags="$(TESTS)" \ - --export-binaries \ - build -endif - - -compileLTO: -ifeq ($(FQBN),) - $(error "Must set variable FQBN in order to be able to compile Arduino sketches !") -else -# compiler.c.extra_flags : switch to -std=c23 whenever XMCLib is conforming; currently neither c99 nor c11 work ! -# CAUTION : only use '=' when assigning values to vars, not '+=' - arduino-cli.exe compile \ - --clean \ - --log \ - --warnings all \ - --fqbn $(FQBN) \ - --build-property compiler.c.extra_flags="\"-DUNITY_INCLUDE_CONFIG_H=1\" -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c20 " \ - --build-property compiler.cpp.extra_flags="$(TESTS) -DNDEBUG -flto -fno-fat-lto-objects -Wextra -Wall -Wfloat-equal -Wconversion -Wredundant-decls -Wswitch-default -Wdouble-promotion -Wpedantic -Wunreachable-code -fanalyzer -std=c++20 " \ - --build-property compiler.ar.cmd=arm-none-eabi-gcc-ar \ - --build-property compiler.libraries.ldflags=-lstdc++ \ - --build-property compiler.arm.cmsis.path="-isystem{compiler.xmclib_include.path}/XMCLib/inc -isystem{compiler.dsp_include.path} -isystem{compiler.nn_include.path} -isystem{compiler.cmsis_include.path} -isystem{compiler.xmclib_include.path}/LIBS -isystem{build.variant.path} -isystem{build.variant.config_path}" \ - --build-property compiler.usb.path="-isystem{runtime.platform.path}/cores/usblib -isystem{runtime.platform.path}/cores/usblib/Common -isystem{runtime.platform.path}/cores/usblib/Class -isystem{runtime.platform.path}/cores/usblib/Class/Common -isystem{runtime.platform.path}/cores/usblib/Class/Device -isystem{runtime.platform.path}/cores/usblib/Core -isystem{runtime.platform.path}/cores/usblib/Core/XMC4000" \ - --export-binaries \ - build -endif - - -upload: compile -ifeq ($(PORT),) - $(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !") -endif -ifeq ($(FQBN),) - $(error "Must set variable FQBN in order to be able to flash Arduino sketches !") -else - arduino-cli.exe upload \ - -p $(PORT) \ - --fqbn $(FQBN) \ - --verbose \ - build -endif - - -flash: compile upload - - -monitor: -ifeq ($(PORT),) - $(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !") -endif -ifeq ($(FQBN),) - $(error "Must set variable FQBN in order to be able to flash Arduino sketches !") -else - arduino-cli.exe monitor \ - -c baudrate=$(BAUD_RATE) \ - -p $(PORT) \ - --fqbn $(FQBN) -endif - diff --git a/tests/unity/Makefile.test b/tests/unity/Makefile.test deleted file mode 100644 index 46957b00..00000000 --- a/tests/unity/Makefile.test +++ /dev/null @@ -1,36 +0,0 @@ -### Build commands -### ! Please note that you need to change the port and path of Unity as appropriate ! - -### Example program - -## XMC4700_Relax_Kit -make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM20 CANReceiver flash monitor # CAN Receive has some problem for XMC4700. - -make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM20 CANReceiverCallback flash monitor # CAN Receive has some problem for XMC4700. - -make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM24 CANSender flash monitor - -make FQBN=Infineon:xmc:XMC4700_Relax_Kit PORT=COM24 CANLoopBack flash monitor - -## XMC1400_XMC2GO -make FQBN=Infineon:xmc:XMC1400_XMC2GO BAUD_RATE=9600 PORT=COM41 CANReceiver flash monitor - -make FQBN=Infineon:xmc:XMC1400_XMC2GO BAUD_RATE=9600 PORT=COM41 CANReceiverCallback flash monitor - -make FQBN=Infineon:xmc:XMC1400_XMC2GO BAUD_RATE=9600 PORT=COM42 CANSender flash monitor - -make FQBN=Infineon:xmc:XMC1400_XMC2GO BAUD_RATE=9600 PORT=COM42 CANLoopBack flash monitor - - -### Unit tests - -# 2 boards - - -make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM42 UNITY_PATH=/home/Unity CAN_connected_node2 monitor - -make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM41 UNITY_PATH=/home/Unity CAN_connected_node1 monitor - -# 1 board -make FQBN=Infineon:xmc:XMC1400_XMC2GO PORT=COM42 UNITY_PATH=/home/Unity CAN monitor - diff --git a/tests/unity/hil-unity-checklist.yaml b/tests/unity/hil-unity-checklist.yaml deleted file mode 100644 index ebda5015..00000000 --- a/tests/unity/hil-unity-checklist.yaml +++ /dev/null @@ -1,29 +0,0 @@ -Infineon.xmc.XMC4700_Relax_Kit: - CAN: - 1: - - "CAN_connected_node1" - - "CAN_connected_node2" - 2: - - CAN - - Wire: - 1: - - "I2C" - 2: - - "I2C" - - -Infineon.xmc.XMC1400_XMC2GO: - CAN: - 1: - - "CAN_connected_node1" - - "CAN_connected_node2" - 2: - - CAN - -Infineon.xmc.XMC1100_XMC2GO: - Wire: - 1: - - "I2C" - 2: - - "I2C" diff --git a/tests/unity/src/Test_common_includes.h b/tests/unity/src/Test_common_includes.h deleted file mode 100644 index 3ce04054..00000000 --- a/tests/unity/src/Test_common_includes.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef TEST_COMMON_INCLUDES_H -#define TEST_COMMON_INCLUDES_H - -// std includes -#include - -// project c includes - -// test includes - -// Unity c includes -#include "unity.h" -#include "unity_fixture.h" - -// IFX Unity addons -#include "unity_ifx.h" - -// Arduino includes -#include -#if defined(TEST_CAN) || defined(TEST_CAN_CONNECTED_NODE1) || defined(TEST_CAN_CONNECTED_NODE2) - #include -#endif - -#if defined(TEST_IIC_PINGPONG_CONNECTED) || defined(TEST_IIC_PINGPONG_2BOARDS_MASTER_CONNECTED) || \ - defined(TEST_IIC_PINGPONG_2BOARDS_SLAVE_CONNECTED) - #include -#endif - -// project cpp includes -#include "Utilities.hpp" - -#endif // TEST_COMMON_INCLUDES_H diff --git a/tests/unity/src/Test_main.ino b/tests/unity/src/Test_main.ino deleted file mode 100644 index 106d1151..00000000 --- a/tests/unity/src/Test_main.ino +++ /dev/null @@ -1,80 +0,0 @@ -// test includes -#include "Test_common_includes.h" - - -/*** - * Uses flags / defines to determine which groups of tests should be added to this test such that multiple tests CAN be executed in a single run. - * Use the '--build-property option of the 'arduino_compile' target to add the flags by defining the respective targets in the makefile. - * makefile : --build-property "compiler.cpp.extra_flags=\"-D=1\"" build -*/ -void RunAllTests(void) -{ - - - -// CAN standalone -#ifdef TEST_CAN - - RUN_TEST_GROUP(CAN); - -#endif - -// CAN with 2 boards connections -#ifdef TEST_CAN_CONNECTED_NODE1 - - RUN_TEST_GROUP(CAN_connected_node1); - -#endif - -// CAN with 2 boards connections -#ifdef TEST_CAN_CONNECTED_NODE2 - - RUN_TEST_GROUP(CAN_connected_node2); - -#endif - - -// IIC with connections -#ifdef TEST_IIC_PINGPONG_CONNECTED - - RUN_TEST_GROUP(IIC_pingPong_connected); - -#endif - - -// IIC with connections -#ifdef TEST_IIC_PINGPONG_2BOARDS_MASTER_CONNECTED - - RUN_TEST_GROUP(IIC_pingPong2BoardsMaster_connected); - -#endif - - -// IIC with connections -#ifdef TEST_IIC_PINGPONG_2BOARDS_SLAVE_CONNECTED - - RUN_TEST_GROUP(IIC_pingPong2BoardsSlave_connected); - -#endif - -} - - -// -void setup() { - Serial.begin(115200); - - Serial.println("setup done."); -} - - -// -void loop() { - Serial.println("\n"); - - const int argc = 2; - const char *argv[argc] = { "", "-v" }; - - (void) UnityMain(argc, argv, RunAllTests); - delay(3000); -} \ No newline at end of file diff --git a/tests/unity/src/corelibs/CAN/Test_CAN.cpp b/tests/unity/src/corelibs/CAN/Test_CAN.cpp deleted file mode 100644 index 8982b12d..00000000 --- a/tests/unity/src/corelibs/CAN/Test_CAN.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT - -// variables - -// Method invoked by Unity before a test suite is run -void CAN_suiteSetUp() {} - -// Method invoked by Unity after a test suite is run -void CAN_suiteTearDown() {} - -// variables used in the tests below that have to be accessed in the setup and tear down methods -extern CANXMC CAN; - -// test includes that may require dut - -// define test group name -TEST_GROUP(CAN); -TEST_GROUP(CAN_internal); - -// Setup method called before every individual test defined for this test group -static TEST_SETUP(CAN_internal) {} - -// Tear down method called before every individual test defined for this test group -static TEST_TEAR_DOWN(CAN_internal) {} - -// Functionality not - yet - supported -TEST_IFX(CAN_internal, checkUnsupportedFunctionality) { - TEST_ASSERT_FALSE(CAN.observe()); - // TEST_ASSERT_TRUE(CAN.packetRtr() ); Remote frame not tested -} - -TEST_IFX(CAN_internal, checkSupportedFunctionality) { - /*TODO: How to test this? - TEST_ASSERT_TRUE(CAN.begin() ); - // TEST_ASSERT_TRUE(CAN.end() ); - // TEST_ASSERT_TRUE(CAN.endPacket() ); // need to configure - // TEST_ASSERT_TRUE(CAN.parsePacket() ); // return value - // TEST_ASSERT_TRUE(CAN.onReceive(0) ); // void - TEST_ASSERT_TRUE(CAN.filter(0x12, 0x7FF) ); - TEST_ASSERT_TRUE(CAN.filterExtended(0x12345678, 0x1FFFFFFF) ); - - TEST_ASSERT_TRUE(CAN.loopback() ); - - // TEST_ASSERT_TRUE(CAN.setIdentifier(0x123) ); // need to be deleted in the future - TEST_ASSERT_TRUE(CAN.beginPacket(0x12, 8, false) ); - TEST_ASSERT_TRUE(CAN.beginExtendedPacket(0xFFF, 8, false) ); - - TEST_ASSERT_TRUE(CAN.available() ); - TEST_ASSERT_TRUE(CAN.read() ); - TEST_ASSERT_TRUE(CAN.peek() ); - // TEST_ASSERT_TRUE(CAN.flush() ); // void - TEST_ASSERT_TRUE(CAN.write(0x12) ); - TEST_ASSERT_TRUE(CAN.write((uint8_t*)0x12, 1) ); - - TEST_ASSERT_TRUE(CAN.sleep() ); - - // TEST_ASSERT_TRUE(CAN.onInterrupt() ); // void - // TEST_ASSERT_TRUE(CAN.packetDlc() ); - // TEST_ASSERT_TRUE(CAN.packetExtended() ); - // TEST_ASSERT_TRUE(CAN.packetId() ); - */ -} - -// Test case for CAN_msg_tx initialization -void test_CAN_msg_tx_initialization(void) { - // Get the Tx message object - XMC_CAN_MO_t *txMessage = CAN.getTxMessage(); - - // Verify that the Tx message object is correctly initialized - TEST_ASSERT_NOT_NULL(txMessage); - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_FRAME_TYPE_STANDARD_11BITS, - txMessage->can_id_mode); // Standard 11-bit identifier - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_ARBITRATION_MODE_ORDER_BASED_PRIO_1, txMessage->can_priority); - TEST_ASSERT_EQUAL_UINT32(0x1FFFFFFFU, txMessage->can_id_mask); - TEST_ASSERT_EQUAL_UINT32(0U, txMessage->can_ide_mask); // send both standard and extended frames - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_MO_TYPE_TRANSMSGOBJ, txMessage->can_mo_type); -} - -// Test case for CAN_msg_rx initialization -void test_CAN_msg_rx_initialization(void) { - // Get the Rx message object - XMC_CAN_MO_t *rxMessage = CAN.getRxMessage(); - - // Verify that the Rx message object is correctly initialized - TEST_ASSERT_NOT_NULL(rxMessage); - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_FRAME_TYPE_STANDARD_11BITS, - rxMessage->can_id_mode); // Standard 11-bit identifier - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_ARBITRATION_MODE_ORDER_BASED_PRIO_1, rxMessage->can_priority); - TEST_ASSERT_EQUAL_UINT32(0x000, rxMessage->can_id_mask); - TEST_ASSERT_EQUAL_UINT32(0U, - rxMessage->can_ide_mask); // receive both standard and extended frames - TEST_ASSERT_EQUAL_UINT32(XMC_CAN_MO_TYPE_RECMSGOBJ, rxMessage->can_mo_type); -} - -// Test case for CAN begin function with different baud rates -void test_CAN_initialization_with_baudrate_125k(void) { - int result = CAN.begin(125000); - TEST_ASSERT_EQUAL(1, result); -} - -void test_CAN_initialization_with_baudrate_250k(void) { - int result = CAN.begin(250000); - TEST_ASSERT_EQUAL(1, result); -} - -void test_CAN_initialization_with_baudrate_500k(void) { - int result = CAN.begin(500000); - TEST_ASSERT_EQUAL(1, result); -} - -void test_CAN_initialization_with_baudrate_1M(void) { - int result = CAN.begin(1000000); - TEST_ASSERT_EQUAL(1, result); -} - -void test_CAN_beginPacket(void) { - int result = CAN.beginPacket(0x123); // Assuming 0x123 is the identifier - TEST_ASSERT_EQUAL(1, result); -} - -void test_CAN_write(void) { - uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; - size_t result = CAN.write(data, sizeof(data)); - TEST_ASSERT_EQUAL(sizeof(data), result); -} - -void test_CAN_endPacket(void) { - int result = CAN.endPacket(); - TEST_ASSERT_EQUAL(1, result); -} - -// Bundle all tests to be executed for this test group -static TEST_GROUP_RUNNER(CAN_internal) { - RUN_TEST_CASE(CAN_internal, checkUnsupportedFunctionality); - RUN_TEST_CASE(CAN_internal, checkSupportedFunctionality); - RUN_TEST(test_CAN_msg_tx_initialization); - RUN_TEST(test_CAN_msg_rx_initialization); - RUN_TEST(test_CAN_initialization_with_baudrate_125k); - RUN_TEST(test_CAN_initialization_with_baudrate_250k); - RUN_TEST(test_CAN_initialization_with_baudrate_1M); - RUN_TEST(test_CAN_initialization_with_baudrate_500k); - RUN_TEST(test_CAN_beginPacket); - RUN_TEST(test_CAN_write); - RUN_TEST(test_CAN_endPacket); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(CAN) { - CAN_suiteSetUp(); - - RUN_TEST_GROUP(CAN_internal); - - CAN_suiteTearDown(); -} diff --git a/tests/unity/src/corelibs/CAN/Test_CAN_connected_node1.cpp b/tests/unity/src/corelibs/CAN/Test_CAN_connected_node1.cpp deleted file mode 100644 index e9c6d453..00000000 --- a/tests/unity/src/corelibs/CAN/Test_CAN_connected_node1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT -#define CAN_ID_1 0x123 -#define CAN_ID_2 0x321 - -// variables - -const static uint8_t node1Increment = 10; -const static uint8_t node2Increment = 1; -const static uint8_t canDataLengthMax = 8; - -static uint8_t node1Data[canDataLengthMax]; -static uint8_t receivedData[canDataLengthMax]; -static uint8_t canDataLength = canDataLengthMax; - -volatile bool newDataReceivedNode1 = false; - -// test feature includes requiring the above defined variables -extern CANXMC CAN; - -void receiveEventNode1(int packetSize) { - uint8_t count = 0; - while (CAN.available() && count < 8) { - receivedData[count++] = CAN.read(); - } - newDataReceivedNode1 = true; -} - -// Method invoked before a test suite is run. -void CAN_connected_node1_suiteSetup() { - CAN.begin(); - CAN.filter(CAN_ID_2, 0x7FF); // Set filter to receive messages with CAN_ID_2 - CAN.onReceive(receiveEventNode1); -} - -// Method invoked after a test suite is run. -void CAN_connected_node1_suiteTearDown() { CAN.end(); } - -// define test group name -TEST_GROUP(CAN_connected_node1); -TEST_GROUP(CAN_connected_node1Internal); - -// Setup method called by Unity before every individual test defined for this test group. -static TEST_SETUP(CAN_connected_node1Internal) { - memset(node1Data, 0, sizeof(node1Data)); - memset(receivedData, 0, sizeof(receivedData)); -} - -// Tear down method called by Unity after every individual test defined for this test group. -static TEST_TEAR_DOWN(CAN_connected_node1Internal) {} - -void testSendReceive(uint8_t dataLength, uint8_t iterations) { - canDataLength = dataLength; - - for (uint8_t loop = 0; loop < iterations; ++loop) { - TEST_ASSERT_TRUE(CAN.beginPacket(CAN_ID_1)); - TEST_ASSERT_EQUAL_UINT8(canDataLength, CAN.write(node1Data, canDataLength)); - TEST_ASSERT_EQUAL(1, CAN.endPacket()); - - while (!newDataReceivedNode1) { - } - - if (newDataReceivedNode1) { - for (uint8_t i = 0; i < canDataLength; ++i) { - TEST_ASSERT_EQUAL_UINT8(node1Data[i] + node2Increment, receivedData[i]); - } - newDataReceivedNode1 = false; - -#ifdef TRACE_OUTPUT - printArray("\nSent Data", node1Data, canDataLength); - printArray("Received Data", receivedData, canDataLength); -#endif - for (uint8_t i = 0; i < canDataLength; ++i) { - node1Data[i] = receivedData[i] + node1Increment; - } - } - } -} - -TEST_IFX(CAN_connected_node1Internal, checkPingPong) { testSendReceive(3, 5); } - -static TEST_GROUP_RUNNER(CAN_connected_node1Internal) { - RUN_TEST_CASE(CAN_connected_node1Internal, checkPingPong); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(CAN_connected_node1) { - CAN_connected_node1_suiteSetup(); - - RUN_TEST_GROUP(CAN_connected_node1Internal); - - CAN_connected_node1_suiteTearDown(); -} diff --git a/tests/unity/src/corelibs/CAN/Test_CAN_connected_node2.cpp b/tests/unity/src/corelibs/CAN/Test_CAN_connected_node2.cpp deleted file mode 100644 index 15fd0095..00000000 --- a/tests/unity/src/corelibs/CAN/Test_CAN_connected_node2.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT -#define CAN_ID_1 0x123 -#define CAN_ID_2 0x321 - -// variables - -const static uint8_t node1Increment = 10; -const static uint8_t node2Increment = 1; -const static uint8_t canDataLengthMax = 8; - -static uint8_t canDataLength = canDataLengthMax; -static uint8_t node2Data[canDataLengthMax] = {0}; -static uint8_t receivedData[canDataLengthMax] = {0}; - -volatile bool newDataReceivedNode2 = false; - -// test feature includes requiring the above defined variables - -extern CANXMC CAN; - -void receiveEventNode2(int packetSize) { - uint8_t count = 0; - while (CAN.available()) { - receivedData[count++] = CAN.read(); - } - newDataReceivedNode2 = true; - canDataLength = packetSize; -} - -// Method invoked before a test suite is run. -void CAN_connected_node2_suiteSetup() { - CAN.begin(); - CAN.filter(CAN_ID_1, 0x7FF); // Set filter to receive messages with CAN_ID_1 - CAN.onReceive(receiveEventNode2); -} - -// Method invoked after a test suite is run. -void CAN_connected_node2_suiteTearDown() { CAN.end(); } - -// define test group name -TEST_GROUP(CAN_connected_node2); -TEST_GROUP(CAN_connected_node2Internal); - -void processReceivedMessagesNode2() { - if (newDataReceivedNode2) { - // Process the received data - for (uint8_t i = 0; i < canDataLength; ++i) { - node2Data[i] = receivedData[i] + node2Increment; - } - - // Send processed data back to Node1 - TEST_ASSERT_TRUE(CAN.beginPacket(CAN_ID_2)); - for (uint8_t i = 0; i < canDataLength; ++i) { - TEST_ASSERT_EQUAL(1, CAN.write(node2Data[i])); - } - TEST_ASSERT_EQUAL(1, CAN.endPacket()); - - // Clear flag - newDataReceivedNode2 = false; - -#ifdef TRACE_OUTPUT - printArray("\nReceived Data", receivedData, canDataLength); - printArray("Sent Data", node2Data, canDataLength); -#endif - } -} - -// Setup method called by Unity before every individual test defined for this test group. -static TEST_SETUP(CAN_connected_node2Internal) {} - -// Tear down method called by Unity after every individual test defined for this test group. -static TEST_TEAR_DOWN(CAN_connected_node2Internal) {} - -TEST_IFX(CAN_connected_node2Internal, checkPingPong) { processReceivedMessagesNode2(); } - -static TEST_GROUP_RUNNER(CAN_connected_node2Internal) { - RUN_TEST_CASE(CAN_connected_node2Internal, checkPingPong); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(CAN_connected_node2) { - CAN_connected_node2_suiteSetup(); - - RUN_TEST_GROUP(CAN_connected_node2Internal); - - CAN_connected_node2_suiteTearDown(); -} diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.cpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.cpp deleted file mode 100644 index 3801991e..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT - -// variables -const static uint8_t slaveAddress = 8U; -const static uint8_t slaveIncrement = 10U; -const static uint8_t masterIncrement = 1U; - -const static uint8_t globalQuantityMax = 20U; - -static uint8_t globalQuantity = 8U; - -static uint8_t masterData[globalQuantityMax] = {0}; - -static TwoWire *master = nullptr; - -// test feature includes requiring the above defined variables -#include "Test_IIC_pingPong2BoardsMaster_connected.hpp" - -// Method invoked before a test suite is run. -static void IIC_pingPong2BoardsMaster_connected_suiteSetup() { - master = &Wire; - - master->begin(); -} - -// Method invoked after a test suite is run. -static void IIC_pingPong2BoardsMaster_connected_suiteTearDown() { master->end(); } diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.hpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.hpp deleted file mode 100644 index 2f49d0e1..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsMaster_connected.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -static void IIC_pingPong2BoardsMaster_connected_suiteSetup(void); -static void IIC_pingPong2BoardsMaster_connected_suiteTearDown(void); - -// variables used in the tests below that have to be accessed in the setup and tear down methods - -// test includes that may require dut - -// define test group name -TEST_GROUP(IIC_pingPong2BoardsMaster_connected); -TEST_GROUP(IIC_pingPong2BoardsMaster_connectedInternal); - -// Setup method called by Unity before every individual test defined for this test group. -static TEST_SETUP(IIC_pingPong2BoardsMaster_connectedInternal) { - for (uint8_t count = 0; count < globalQuantity; ++count) { - masterData[count] = 0; - } -} - -// Tear down method called by Unity after every individual test defined for this test group. -static TEST_TEAR_DOWN(IIC_pingPong2BoardsMaster_connectedInternal) {} - -static bool masterSend(const uint8_t *data, const uint8_t quantity) { - master->beginTransmission(slaveAddress); - - TEST_ASSERT_EQUAL_UINT8(quantity, master->write(data, quantity)); - TEST_ASSERT_EQUAL_UINT8(0U, master->endTransmission()); // TODO: Fails from time to time ! - - return true; -} - -static bool masterReceive(uint8_t *data, uint8_t &quantity) { - uint8_t count = 0; - uint8_t locQuantity = quantity; - - TEST_ASSERT_EQUAL_UINT8(quantity, master->requestFrom(slaveAddress, quantity)); - TEST_ASSERT_EQUAL_UINT8(quantity, master->available()); - - while (master->available() > 0) { - uint8_t peekValue = master->peek(); - data[count] = master->read(); - - TEST_ASSERT_EQUAL_UINT8(peekValue, data[count]); - - ++count; - } - - TEST_ASSERT_EQUAL_UINT8(quantity, count); - - quantity = count; - - return quantity == locQuantity; -} - -static void IIC_pingPong(uint8_t quantity, uint8_t iterations) { - globalQuantity = quantity; - - uint8_t masterDataCopy[quantity]; - - for (uint8_t loop = 0; loop < iterations; ++loop) { - TEST_ASSERT_TRUE(masterSend(masterData, quantity)); - -#ifdef TRACE_OUTPUT - - printArray("\nMaster send", masterData, quantity); - -#endif - - for (uint8_t i = 0; i < quantity; ++i) { - masterDataCopy[i] = masterData[i] + slaveIncrement; - } - - TEST_ASSERT_TRUE(masterReceive(masterData, quantity)); - -#ifdef TRACE_OUTPUT - - printArray("\nMaster received", masterData, quantity); - -#endif - - TEST_ASSERT_EQUAL_UINT8_ARRAY(masterDataCopy, masterData, quantity); - - for (uint8_t i = 0; i < quantity; ++i) { - masterData[i] += masterIncrement; - } - } -} - -TEST_IFX(IIC_pingPong2BoardsMaster_connectedInternal, checkPingPong) { - // TODO: Loop over different amounts of data, clock frequencies and other parameters ! - // Must set variable globalQuantity identically in slave and master ! This can be done by - // communicating that value from master to slave, thereby allowing for a more dynamic behaviour. - // IIC_pingPong(1, 15); - // IIC_pingPong(2, 15); - IIC_pingPong(8, 15); -} - -static TEST_GROUP_RUNNER(IIC_pingPong2BoardsMaster_connectedInternal) { - RUN_TEST_CASE(IIC_pingPong2BoardsMaster_connectedInternal, checkPingPong); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(IIC_pingPong2BoardsMaster_connected) { - IIC_pingPong2BoardsMaster_connected_suiteSetup(); - - RUN_TEST_GROUP(IIC_pingPong2BoardsMaster_connectedInternal); - - IIC_pingPong2BoardsMaster_connected_suiteTearDown(); -} diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.cpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.cpp deleted file mode 100644 index 87b86d2f..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT - -// variables -const static uint8_t slaveAddress = 8U; -const static uint8_t slaveIncrement = 10U; - -const static uint8_t globalQuantityMax = 20U; - -static uint8_t globalQuantity = 8U; - -volatile static uint8_t slaveData[globalQuantityMax] = {0}; - -volatile static uint8_t howManyCopy[globalQuantityMax] = {0}; -volatile static uint8_t availCopy[globalQuantityMax] = {0}; -volatile static uint8_t peekCopy[globalQuantityMax] = {0}; - -volatile static uint8_t bytesWrittenCopy = 0; - -static TwoWire *slave = nullptr; - -// test feature includes requiring the above defined variables -#include "Test_IIC_pingPong2BoardsSlave_connected.hpp" - -static void slaveReceiveEventIIC(int howMany) { - uint8_t count = 0; - - while (slave->available() > 0) { - howManyCopy[count] = howMany; - availCopy[count] = slave->available(); - peekCopy[count] = slave->peek(); - slaveData[count] = slave->read(); - ++count; - } -} - -static void slaveRequestEventIIC() { - uint8_t count = 0; - - while (count < globalQuantity) { - slaveData[count] += slaveIncrement; - ++count; - } - - bytesWrittenCopy = slave->write((const uint8_t *)slaveData, globalQuantity); -} - -// Method invoked before a test suite is run. -static void IIC_pingPong2BoardsSlave_connected_suiteSetup() { - slave = &Wire; - - slave->begin(slaveAddress); - slave->onReceive(slaveReceiveEventIIC); - slave->onRequest(slaveRequestEventIIC); -} - -// Method invoked after a test suite is run. -static void IIC_pingPong2BoardsSlave_connected_suiteTearDown() { - // slave->end(); // TODO: Why can end() not be called here without disrupting the execution ? -} diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.hpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.hpp deleted file mode 100644 index 48f73222..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong2BoardsSlave_connected.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -static void IIC_pingPong2BoardsSlave_connected_suiteSetup(void); -static void IIC_pingPong2BoardsSlave_connected_suiteTearDown(void); - -// variables used in the tests below that have to be accessed in the setup and tear down methods - -// test includes that may require dut - -// define test group name -TEST_GROUP(IIC_pingPong2BoardsSlave_connected); -TEST_GROUP(IIC_pingPong2BoardsSlave_connectedInternal); - -// Setup method called by Unity before every individual test defined for this test group. -static TEST_SETUP(IIC_pingPong2BoardsSlave_connectedInternal) {} - -// Tear down method called by Unity after every individual test defined for this test group. -static TEST_TEAR_DOWN(IIC_pingPong2BoardsSlave_connectedInternal) {} - -TEST_IFX(IIC_pingPong2BoardsSlave_connectedInternal, checkPingPong) { -#ifdef TRACE_OUTPUT - - printArray("\nslaveData", slaveData, globalQuantity); - printArray("howManyCopy", howManyCopy, globalQuantity); - printArray("availCopy", availCopy, globalQuantity); - printArray("peekCopy", peekCopy, globalQuantity); - Serial.flush(); - - Serial.print("bytesWrittenCopy : "); - Serial.println(bytesWrittenCopy); - Serial.flush(); - -#endif - - for (uint8_t i = 0; i < globalQuantity; ++i) { - TEST_ASSERT_EQUAL_UINT8(globalQuantity, howManyCopy[i]); - TEST_ASSERT_EQUAL_UINT8(availCopy[i], globalQuantity - i); - - peekCopy[i] += slaveIncrement; - } - - TEST_ASSERT_EQUAL_UINT8_ARRAY(slaveData, peekCopy, globalQuantity); - - TEST_ASSERT_EQUAL_UINT8(globalQuantity, bytesWrittenCopy); -} - -static TEST_GROUP_RUNNER(IIC_pingPong2BoardsSlave_connectedInternal) { - RUN_TEST_CASE(IIC_pingPong2BoardsSlave_connectedInternal, checkPingPong); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(IIC_pingPong2BoardsSlave_connected) { - IIC_pingPong2BoardsSlave_connected_suiteSetup(); - - RUN_TEST_GROUP(IIC_pingPong2BoardsSlave_connectedInternal); - - IIC_pingPong2BoardsSlave_connected_suiteTearDown(); -} diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.cpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.cpp deleted file mode 100644 index ba2c6235..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -// defines -#define TRACE_OUTPUT - -// variables -const static uint8_t slaveAddress = 8U; -const static uint8_t slaveIncrement = 10U; -const static uint8_t masterIncrement = 1U; - -const static uint8_t globalQuantityMax = 20U; - -// TODO: Maximum value to request by master is 2, otherwise XMC_I2C_CH_MasterStart in line 253 of -// Wire.cpp hangs ! -static uint8_t globalQuantity = 1U; - -// static uint8_t slaveData[globalQuantityMax] = { 0 }; -static uint8_t masterData[globalQuantityMax] = {0}; - -volatile static uint8_t slaveData[globalQuantityMax] = {0}; - -volatile static uint8_t howManyCopy[globalQuantityMax] = {0}; -volatile static uint8_t availCopy[globalQuantityMax] = {0}; -volatile static uint8_t peekCopy[globalQuantityMax] = {0}; - -static TwoWire *master = nullptr; -static TwoWire *slave = nullptr; - -// test feature includes requiring the above defined variables -#include "Test_IIC_pingPong_connected.hpp" - -static void slaveReceiveEventIIC(int howMany) { - uint8_t count = 0; - - while (slave->available() > 0) { - howManyCopy[count] = howMany; - availCopy[count] = slave->available(); - peekCopy[count] = slave->peek(); - slaveData[count] = slave->read(); - ++count; - } -} - -static void slaveRequestEventIIC() { - uint8_t count = 0; - - while (count < globalQuantity) { - slaveData[count] += slaveIncrement; - ++count; - } - - (void)slave->write((const uint8_t *)slaveData, globalQuantity); -} - -// Method invoked before a test suite is run. -static void IIC_pingPong_connected_suiteSetup() { - master = &Wire; - master->begin(); - - slave = &Wire1; - slave->begin(slaveAddress); - slave->onReceive(slaveReceiveEventIIC); - slave->onRequest(slaveRequestEventIIC); -} - -// Method invoked after a test suite is run. -static void IIC_pingPong_connected_suiteTearDown() { - master->end(); - slave->end(); -} diff --git a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.hpp b/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.hpp deleted file mode 100644 index ba67e8b0..00000000 --- a/tests/unity/src/corelibs/Wire/Test_IIC_pingPong_connected.hpp +++ /dev/null @@ -1,130 +0,0 @@ -// std includes - -// test includes -#include "Test_common_includes.h" - -// project includes - -static void IIC_pingPong_connected_suiteSetup(void); -static void IIC_pingPong_connected_suiteTearDown(void); - -// variables used in the tests below that have to be accessed in the setup and tear down methods - -// test includes that may require dut - -// define test group name -TEST_GROUP(IIC_pingPong_connected); -TEST_GROUP(IIC_pingPong_connectedInternal); - -// Setup method called by Unity before every individual test defined for this test group. -static TEST_SETUP(IIC_pingPong_connectedInternal) { - for (uint8_t count = 0; count < globalQuantity; ++count) { - masterData[count] = 0; - slaveData[count] = 0; - } -} - -// Tear down method called by Unity after every individual test defined for this test group. -static TEST_TEAR_DOWN(IIC_pingPong_connectedInternal) {} - -static bool masterSend(const uint8_t *data, const uint8_t quantity) { - master->beginTransmission(slaveAddress); - - TEST_ASSERT_EQUAL_UINT8(quantity, master->write(data, quantity)); - TEST_ASSERT_EQUAL_UINT8( - 0U, master->endTransmission()); // TODO: endTransmission() fails from time to time. Why ? - - return true; -} - -static bool masterReceive(uint8_t *data, uint8_t &quantity) { - uint8_t count = 0; - uint8_t locQuantity = quantity; - - TEST_ASSERT_EQUAL_UINT8(quantity, master->requestFrom(slaveAddress, quantity)); - TEST_ASSERT_EQUAL_UINT8(quantity, master->available()); - - while (master->available() > 0) { - uint8_t peekValue = master->peek(); - data[count] = master->read(); - - TEST_ASSERT_EQUAL_UINT8(peekValue, data[count]); - - ++count; - } - - TEST_ASSERT_EQUAL_UINT8(quantity, count); - - quantity = count; - - return quantity == locQuantity; -} - -static void IIC_pingPong(uint8_t quantity, uint8_t iterations) { - globalQuantity = quantity; - - uint8_t masterDataCopy[quantity]; - - for (uint8_t loop = 0; loop < iterations; ++loop) { - TEST_ASSERT_TRUE(masterSend(masterData, quantity)); - -#ifdef TRACE_OUTPUT - - printArray("\nMaster send", masterData, quantity); - -#endif - - for (uint8_t i = 0; i < quantity; ++i) { - masterDataCopy[i] = masterData[i] + slaveIncrement; - } - - TEST_ASSERT_TRUE(masterReceive(masterData, quantity)); - -#ifdef TRACE_OUTPUT - - printArray("\nMaster received", masterData, quantity); - - printArray("\nslaveData", slaveData, globalQuantity); - printArray("howManyCopy", howManyCopy, globalQuantity); - printArray("availCopy", availCopy, globalQuantity); - printArray("peekCopy", peekCopy, globalQuantity); - Serial.flush(); - -#endif - - for (uint8_t i = 0; i < globalQuantity; ++i) { - TEST_ASSERT_EQUAL_UINT8(globalQuantity, howManyCopy[i]); - TEST_ASSERT_EQUAL_UINT8(availCopy[i], globalQuantity - i); - - peekCopy[i] += slaveIncrement; - } - - TEST_ASSERT_EQUAL_UINT8_ARRAY(slaveData, peekCopy, globalQuantity); - TEST_ASSERT_EQUAL_UINT8_ARRAY(masterDataCopy, masterData, quantity); - - for (uint8_t i = 0; i < quantity; ++i) { - masterData[i] += masterIncrement; - } - } -} - -TEST_IFX(IIC_pingPong_connectedInternal, checkPingPong) { - // TODO: Loop over different amounts of data, clock frequencies and other parameters ! - IIC_pingPong(1, 15); - IIC_pingPong(2, 15); - - // IIC_pingPong(8, 15); // TODO: Why does any quantity larger than 2 not work ? -} - -static TEST_GROUP_RUNNER(IIC_pingPong_connectedInternal) { - RUN_TEST_CASE(IIC_pingPong_connectedInternal, checkPingPong); -} - -// Bundle all tests to be executed for this test group -TEST_GROUP_RUNNER(IIC_pingPong_connected) { - IIC_pingPong_connected_suiteSetup(); - - RUN_TEST_GROUP(IIC_pingPong_connectedInternal); - - IIC_pingPong_connected_suiteTearDown(); -} diff --git a/tests/unity/src/unity_config.h b/tests/unity/src/unity_config.h deleted file mode 100644 index 4fb61df2..00000000 --- a/tests/unity/src/unity_config.h +++ /dev/null @@ -1,247 +0,0 @@ -/* Unity Configuration - * As of May 11th, 2016 at ThrowTheSwitch/Unity commit 837c529 - * Update: December 29th, 2016 - * See Also: Unity/docs/UnityConfigurationGuide.pdf - * - * Unity is designed to run on almost anything that is targeted by a C compiler. - * It would be awesome if this could be done with zero configuration. While - * there are some targets that come close to this dream, it is sadly not - * universal. It is likely that you are going to need at least a couple of the - * configuration options described in this document. - * - * All of Unity's configuration options are `#defines`. Most of these are simple - * definitions. A couple are macros with arguments. They live inside the - * unity_internals.h header file. We don't necessarily recommend opening that - * file unless you really need to. That file is proof that a cross-platform - * library is challenging to build. From a more positive perspective, it is also - * proof that a great deal of complexity can be centralized primarily to one - * place in order to provide a more consistent and simple experience elsewhere. - * - * Using These Options - * It doesn't matter if you're using a target-specific compiler and a simulator - * or a native compiler. In either case, you've got a couple choices for - * configuring these options: - * - * 1. Because these options are specified via C defines, you can pass most of - * these options to your compiler through command line compiler flags. Even - * if you're using an embedded target that forces you to use their - * overbearing IDE for all configuration, there will be a place somewhere in - * your project to configure defines for your compiler. - * 2. You can create a custom `unity_config.h` configuration file (present in - * your toolchain's search paths). In this file, you will list definitions - * and macros specific to your target. All you must do is define - * `UNITY_INCLUDE_CONFIG_H` and Unity will rely on `unity_config.h` for any - * further definitions it may need. - */ - -#ifndef UNITY_CONFIG_H -#define UNITY_CONFIG_H - -/* ************************* AUTOMATIC INTEGER TYPES *************************** - * C's concept of an integer varies from target to target. The C Standard has - * rules about the `int` matching the register size of the target - * microprocessor. It has rules about the `int` and how its size relates to - * other integer types. An `int` on one target might be 16 bits while on another - * target it might be 64. There are more specific types in compilers compliant - * with C99 or later, but that's certainly not every compiler you are likely to - * encounter. Therefore, Unity has a number of features for helping to adjust - * itself to match your required integer sizes. It starts off by trying to do it - * automatically. - **************************************************************************** */ - -/* The first attempt to guess your types is to check `limits.h`. Some compilers - * that don't support `stdint.h` could include `limits.h`. If you don't - * want Unity to check this file, define this to make it skip the inclusion. - * Unity looks at UINT_MAX & ULONG_MAX, which were available since C89. - */ -/* #define UNITY_EXCLUDE_LIMITS_H */ - -/* The second thing that Unity does to guess your types is check `stdint.h`. - * This file defines `UINTPTR_MAX`, since C99, that Unity can make use of to - * learn about your system. It's possible you don't want it to do this or it's - * possible that your system doesn't support `stdint.h`. If that's the case, - * you're going to want to define this. That way, Unity will know to skip the - * inclusion of this file and you won't be left with a compiler error. - */ -/* #define UNITY_EXCLUDE_STDINT_H */ - -/* ********************** MANUAL INTEGER TYPE DEFINITION *********************** - * If you've disabled all of the automatic options above, you're going to have - * to do the configuration yourself. There are just a handful of defines that - * you are going to specify if you don't like the defaults. - **************************************************************************** */ - -/* Define this to be the number of bits an `int` takes up on your system. The - * default, if not auto-detected, is 32 bits. - * - * Example: - */ -/* #define UNITY_INT_WIDTH 16 */ - -/* Define this to be the number of bits a `long` takes up on your system. The - * default, if not autodetected, is 32 bits. This is used to figure out what - * kind of 64-bit support your system can handle. Does it need to specify a - * `long` or a `long long` to get a 64-bit value. On 16-bit systems, this option - * is going to be ignored. - * - * Example: - */ -/* #define UNITY_LONG_WIDTH 16 */ - -/* Define this to be the number of bits a pointer takes up on your system. The - * default, if not autodetected, is 32-bits. If you're getting ugly compiler - * warnings about casting from pointers, this is the one to look at. - * - * Example: - */ -/* #define UNITY_POINTER_WIDTH 64 */ - -/* Unity will automatically include 64-bit support if it auto-detects it, or if - * your `int`, `long`, or pointer widths are greater than 32-bits. Define this - * to enable 64-bit support if none of the other options already did it for you. - * There can be a significant size and speed impact to enabling 64-bit support - * on small targets, so don't define it if you don't need it. - */ -/* #define UNITY_INCLUDE_64 */ - -/* *************************** FLOATING POINT TYPES **************************** - * In the embedded world, it's not uncommon for targets to have no support for - * floating point operations at all or to have support that is limited to only - * single precision. We are able to guess integer sizes on the fly because - * integers are always available in at least one size. Floating point, on the - * other hand, is sometimes not available at all. Trying to include `float.h` on - * these platforms would result in an error. This leaves manual configuration as - * the only option. - **************************************************************************** */ - -/* By default, Unity guesses that you will want single precision floating point - * support, but not double precision. It's easy to change either of these using - * the include and exclude options here. You may include neither, just float, - * or both, as suits your needs. - */ -/* #define UNITY_EXCLUDE_FLOAT */ -/* #define UNITY_INCLUDE_DOUBLE */ -/* #define UNITY_EXCLUDE_DOUBLE */ - -/* For features that are enabled, the following floating point options also - * become available. - */ - -/* Unity aims for as small of a footprint as possible and avoids most standard - * library calls (some embedded platforms don't have a standard library!). - * Because of this, its routines for printing integer values are minimalist and - * hand-coded. To keep Unity universal, though, we eventually chose to develop - * our own floating point print routines. Still, the display of floating point - * values during a failure are optional. By default, Unity will print the - * actual results of floating point assertion failures. So a failed assertion - * will produce a message like "Expected 4.0 Was 4.25". If you would like less - * verbose failure messages for floating point assertions, use this option to - * give a failure message `"Values Not Within Delta"` and trim the binary size. - */ -/* #define UNITY_EXCLUDE_FLOAT_PRINT */ - -/* If enabled, Unity assumes you want your `FLOAT` asserts to compare standard C - * floats. If your compiler supports a specialty floating point type, you can - * always override this behavior by using this definition. - * - * Example: - */ -/* #define UNITY_FLOAT_TYPE float16_t */ - -/* If enabled, Unity assumes you want your `DOUBLE` asserts to compare standard - * C doubles. If you would like to change this, you can specify something else - * by using this option. For example, defining `UNITY_DOUBLE_TYPE` to `long - * double` could enable gargantuan floating point types on your 64-bit processor - * instead of the standard `double`. - * - * Example: - */ -/* #define UNITY_DOUBLE_TYPE long double */ - -/* If you look up `UNITY_ASSERT_EQUAL_FLOAT` and `UNITY_ASSERT_EQUAL_DOUBLE` as - * documented in the Unity Assertion Guide, you will learn that they are not - * really asserting that two values are equal but rather that two values are - * "close enough" to equal. "Close enough" is controlled by these precision - * configuration options. If you are working with 32-bit floats and/or 64-bit - * doubles (the normal on most processors), you should have no need to change - * these options. They are both set to give you approximately 1 significant bit - * in either direction. The float precision is 0.00001 while the double is - * 10^-12. For further details on how this works, see the appendix of the Unity - * Assertion Guide. - * - * Example: - */ -/* #define UNITY_FLOAT_PRECISION 0.001f */ -/* #define UNITY_DOUBLE_PRECISION 0.001f */ - -/* *************************** MISCELLANEOUS *********************************** - * Miscellaneous configuration options for Unity - **************************************************************************** */ - -/* Unity uses the stddef.h header included in the C standard library for the - * "NULL" macro. Define this in order to disable the include of stddef.h. If you - * do this, you have to make sure to provide your own "NULL" definition. - */ -/* #define UNITY_EXCLUDE_STDDEF_H */ - -/* Define this to enable the unity formatted print macro: - * "TEST_PRINTF" - */ -/* #define UNITY_INCLUDE_PRINT_FORMATTED */ - -/* *************************** TOOLSET CUSTOMIZATION *************************** - * In addition to the options listed above, there are a number of other options - * which will come in handy to customize Unity's behavior for your specific - * toolchain. It is possible that you may not need to touch any of these but - * certain platforms, particularly those running in simulators, may need to jump - * through extra hoops to operate properly. These macros will help in those - * situations. - **************************************************************************** */ - -/* By default, Unity prints its results to `stdout` as it runs. This works - * perfectly fine in most situations where you are using a native compiler for - * testing. It works on some simulators as well so long as they have `stdout` - * routed back to the command line. There are times, however, where the - * simulator will lack support for dumping results or you will want to route - * results elsewhere for other reasons. In these cases, you should define the - * `UNITY_OUTPUT_CHAR` macro. This macro accepts a single character at a time - * (as an `int`, since this is the parameter type of the standard C `putchar` - * function most commonly used). You may replace this with whatever function - * call you like. - * - * Example: - * Say you are forced to run your test suite on an embedded processor with no - * `stdout` option. You decide to route your test result output to a custom - * serial `RS232_putc()` function you wrote like thus: - */ - -#define UNITY_OUTPUT_CHAR(a) putCharacter(a) -#define UNITY_OUTPUT_CHAR_HEADER_DECLARATION putCharacter(char c) -#define UNITY_OUTPUT_FLUSH() flushCharacter() -#define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION flushCharacter() - -/* #define UNITY_OUTPUT_CHAR(a) RS232_putc(a) */ -/* #define UNITY_OUTPUT_CHAR_HEADER_DECLARATION RS232_putc(int) */ -/* #define UNITY_OUTPUT_FLUSH() RS232_flush() */ -/* #define UNITY_OUTPUT_FLUSH_HEADER_DECLARATION RS232_flush(void) */ -/* #define UNITY_OUTPUT_START() RS232_config(115200,1,8,0) */ -/* #define UNITY_OUTPUT_COMPLETE() RS232_close() */ - -/* Some compilers require a custom attribute to be assigned to pointers, like - * `near` or `far`. In these cases, you can give Unity a safe default for these - * by defining this option with the attribute you would like. - * - * Example: - */ -/* #define UNITY_PTR_ATTRIBUTE __attribute__((far)) */ -/* #define UNITY_PTR_ATTRIBUTE near */ - -/* Print execution time of each test when executed in verbose mode - * - * Example: - * - * TEST - PASS (10 ms) - */ -#define UNITY_INCLUDE_EXEC_TIME (1) - -#endif /* UNITY_CONFIG_H */ diff --git a/tests/unity/src/unity_ifx.h b/tests/unity/src/unity_ifx.h deleted file mode 100644 index af1ec3bf..00000000 --- a/tests/unity/src/unity_ifx.h +++ /dev/null @@ -1,29 +0,0 @@ - -#ifndef UNITY_IFX_H -#define UNITY_IFX_H - -#define TEST_IFX(group, name) \ - static void TEST_##group##_##name##_(void); \ - static void TEST_##group##_##name##_run(void); \ - void TEST_##group##_##name##_run(void) { \ - UnityTestRunner(TEST_##group##_SETUP, TEST_##group##_##name##_, TEST_##group##_TEAR_DOWN, \ - "TEST(" #group ", " #name ")", TEST_GROUP_##group, #name, __FILE__, \ - __LINE__); \ - } \ - void TEST_##group##_##name##_(void) - -#ifdef __cplusplus - -extern "C" { - -#endif - -void putCharacter(char c); -void flushCharacter(); - -#ifdef __cplusplus -} - -#endif - -#endif // UNITY_IFX_H diff --git a/tests/unity/src/utils/Utilities.cpp b/tests/unity/src/utils/Utilities.cpp deleted file mode 100644 index 6179bdfd..00000000 --- a/tests/unity/src/utils/Utilities.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// std includes -#include - -// Arduino includes -#include - -// project cpp includes - -void printArray(const char *title, volatile uint8_t *data, uint8_t quantity) { - Serial.print(title); - Serial.print(" : ["); - - for (uint8_t i = 0; i < quantity; ++i) { - Serial.print(data[i]); - Serial.print(", "); - } - - Serial.println("]"); - Serial.flush(); -} diff --git a/tests/unity/src/utils/Utilities.hpp b/tests/unity/src/utils/Utilities.hpp deleted file mode 100644 index 6b239396..00000000 --- a/tests/unity/src/utils/Utilities.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef UTILITIES_HPP -#define UTILITIES_HPP - -// std includes -#include - -// project cpp includes - -void printArray(const char *title, volatile uint8_t *data, uint8_t quantity); - -#endif // UTILITIES_HPP diff --git a/tests/unity/src/utils/unity_ifx.cpp b/tests/unity/src/utils/unity_ifx.cpp deleted file mode 100644 index 1a957e10..00000000 --- a/tests/unity/src/utils/unity_ifx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// std includes - -// Arduino includes -#include - -// test includes -#include "unity_ifx.h" - -extern "C" { -// Method used by Unity to output a single character -void putCharacter(char c) { - Serial.print(c); - Serial.flush(); -} - -// Method used by Unity to flush the output -void flushCharacter() { Serial.flush(); } -}