From 52ac6fb59c88b86aaa67d2028b94a310967fc884 Mon Sep 17 00:00:00 2001 From: Thomas de Bont Date: Thu, 23 Mar 2023 17:35:26 +0100 Subject: [PATCH 01/21] Add dev container --- .devcontainer/devcontainer.json | 18 +++ .vscode/launch.json | 55 +++++-- CMakePresets.json | 252 ++++++++++++++++---------------- 3 files changed, 184 insertions(+), 141 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..df9f970f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + // This devcontainer has been set-up to run docker-from-docker scenarios as per + // https://github.com/microsoft/vscode-dev-containers/tree/main/containers/docker-from-docker + "name": "amp-devcontainer", + "image": "ghcr.io/philips-software/amp-devcontainer:2.2.0", + "runArgs": ["--add-host=host.docker.internal:host-gateway"], + "remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}" }, + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], + "extensions": [ + "llvm-vs-code-extensions.vscode-clangd", + "marus25.cortex-debug", + "matepek.vscode-catch2-test-adapter", + "ms-vscode.cmake-tools", + "SonarSource.sonarlint-vscode" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json index 9a17f66f..d0aa3d8b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,17 +1,42 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Current target (stm32f767)", - "cwd": "${workspaceRoot}", - "request": "launch", - "executable": "${command:cmake.launchTargetPath}", - "type": "cortex-debug", - "servertype": "jlink", - "device": "STM32F767ZI" - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Host", + "type": "cppdbg", + "request": "launch", + "program": "${command:cmake.launchTargetPath}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + }, + { + "name": "Debug stm32f767", + "cwd": "${workspaceFolder}", + "executable": "${command:cmake.launchTargetPath}", + "request": "launch", + "type": "cortex-debug", + "device": "STM32F767ZI", + "servertype": "external", + "showDevDebugOutput": "both", + "gdbTarget": "host.docker.internal:2331", + "overrideLaunchCommands": [ + "monitor reset", + "-target-download", + "monitor reset" + ], + "overrideRestartCommands": ["monitor reset"] + } + ] } diff --git a/CMakePresets.json b/CMakePresets.json index 1ce535a3..9d6f7349 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,129 +1,129 @@ { - "version": 3, - "cmakeMinimumRequired": { - "major": 3, - "minor": 24, - "patch": 0 - }, - "configurePresets": [ - { - "name": "defaults", - "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Ninja Multi-Config", - "cacheVariables": { - "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel", - "HALST_BUILD_EXAMPLES": true - } + "version": 3, + "cmakeMinimumRequired": { + "major": 3, + "minor": 24, + "patch": 0 }, - { - "name": "host", - "displayName": "host", - "description": "Build required tools for host", - "inherits": "defaults" - }, - { - "name": "stm32", - "hidden": true, - "inherits": "defaults", - "cacheVariables": { - "emil_DIR": "${sourceDir}/build/host/_deps/emil-build/cmake", - "EMIL_GENERATE_PACKAGE_CONFIG": false, - "TARGET_MCU_VENDOR": "st" - } - }, - { - "name": "stm32wb55cg", - "displayName": "stm32wb55cg", - "description": "Build for stm32wb55cg", - "inherits": "stm32", - "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", - "cacheVariables": { - "TARGET_CORTEX": "m4", - "TARGET_MCU_FAMILY": "stm32wbxx", - "TARGET_MCU": "stm32wb55", - "TARGET_MCU_VARIANT": "stm32wb55cg" - } - }, - { - "name": "stm32f407", - "displayName": "stm32f407", - "description": "Build for stm32f407", - "inherits": "stm32", - "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", - "cacheVariables": { - "TARGET_CORTEX": "m4", - "TARGET_MCU_FAMILY": "stm32f4xx", - "TARGET_MCU": "stm32f407" - } - }, - { - "name": "stm32f429", - "displayName": "stm32f429", - "description": "Build for stm32f429", - "inherits": "stm32", - "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", - "cacheVariables": { - "TARGET_CORTEX": "m4", - "TARGET_MCU_FAMILY": "stm32f4xx", - "TARGET_MCU": "stm32f429" - } - }, - { - "name": "stm32f746", - "displayName": "stm32f746", - "description": "Build for stm32f746", - "inherits": "stm32", - "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m7-fpv5-sp-d16.cmake", - "cacheVariables": { - "TARGET_CORTEX": "m7", - "TARGET_MCU_FAMILY": "stm32f7xx", - "TARGET_MCU": "stm32f746" - } - }, - { - "name": "stm32f767", - "displayName": "stm32f767", - "description": "Build for stm32f767", - "inherits": "stm32", - "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m7-fpv5-d16.cmake", - "cacheVariables": { - "TARGET_CORTEX": "m7", - "TARGET_MCU_FAMILY": "stm32f7xx", - "TARGET_MCU": "stm32f767" - } - } - ], - "buildPresets": [ - { - "name": "host-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "host" - }, - { - "name": "stm32wb55cg-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "stm32wb55cg" - }, - { - "name": "stm32f407-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "stm32f407" - }, - { - "name": "stm32f429-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "stm32f429" - }, - { - "name": "stm32f746-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "stm32f746" - }, - { - "name": "stm32f767-RelWithDebInfo", - "configuration": "RelWithDebInfo", - "configurePreset": "stm32f767" - } - ] + "configurePresets": [ + { + "name": "defaults", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja Multi-Config", + "cacheVariables": { + "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel", + "HALST_BUILD_EXAMPLES": true + } + }, + { + "name": "host", + "displayName": "host", + "description": "Build required tools for host", + "inherits": "defaults" + }, + { + "name": "stm32", + "hidden": true, + "inherits": "defaults", + "cacheVariables": { + "emil_DIR": "${sourceDir}/build/host/_deps/emil-build/cmake", + "EMIL_GENERATE_PACKAGE_CONFIG": false, + "TARGET_MCU_VENDOR": "st" + } + }, + { + "name": "stm32wb55cg", + "displayName": "stm32wb55cg", + "description": "Build for stm32wb55cg", + "inherits": "stm32", + "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", + "cacheVariables": { + "TARGET_CORTEX": "m4", + "TARGET_MCU_FAMILY": "stm32wbxx", + "TARGET_MCU": "stm32wb55", + "TARGET_MCU_VARIANT": "stm32wb55cg" + } + }, + { + "name": "stm32f407", + "displayName": "stm32f407", + "description": "Build for stm32f407", + "inherits": "stm32", + "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", + "cacheVariables": { + "TARGET_CORTEX": "m4", + "TARGET_MCU_FAMILY": "stm32f4xx", + "TARGET_MCU": "stm32f407" + } + }, + { + "name": "stm32f429", + "displayName": "stm32f429", + "description": "Build for stm32f429", + "inherits": "stm32", + "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m4-fpv4-sp-d16.cmake", + "cacheVariables": { + "TARGET_CORTEX": "m4", + "TARGET_MCU_FAMILY": "stm32f4xx", + "TARGET_MCU": "stm32f429" + } + }, + { + "name": "stm32f746", + "displayName": "stm32f746", + "description": "Build for stm32f746", + "inherits": "stm32", + "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m7-fpv5-sp-d16.cmake", + "cacheVariables": { + "TARGET_CORTEX": "m7", + "TARGET_MCU_FAMILY": "stm32f7xx", + "TARGET_MCU": "stm32f746" + } + }, + { + "name": "stm32f767", + "displayName": "stm32f767", + "description": "Build for stm32f767", + "inherits": "stm32", + "toolchainFile": "${sourceDir}/cmake/toolchain-arm-gcc-m7-fpv5-d16.cmake", + "cacheVariables": { + "TARGET_CORTEX": "m7", + "TARGET_MCU_FAMILY": "stm32f7xx", + "TARGET_MCU": "stm32f767" + } + } + ], + "buildPresets": [ + { + "name": "host-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "host" + }, + { + "name": "stm32wb55cg-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "stm32wb55cg" + }, + { + "name": "stm32f407-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "stm32f407" + }, + { + "name": "stm32f429-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "stm32f429" + }, + { + "name": "stm32f746-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "stm32f746" + }, + { + "name": "stm32f767-RelWithDebInfo", + "configuration": "RelWithDebInfo", + "configurePreset": "stm32f767" + } + ] } From d4386e6573a21f63f0ab65dd8a6f45211526b248 Mon Sep 17 00:00:00 2001 From: Thomas de Bont Date: Fri, 24 Mar 2023 14:29:43 +0000 Subject: [PATCH 02/21] feat: mininal stim+tester GPIO only, report over tester UI LEDs --- CMakeLists.txt | 1 + integration_test/CMakeLists.txt | 2 ++ integration_test/stim/CMakeLists.txt | 9 +++++++ integration_test/stim/Main.cpp | 31 +++++++++++++++++++++++ integration_test/tester/CMakeLists.txt | 9 +++++++ integration_test/tester/Main.cpp | 34 ++++++++++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 integration_test/CMakeLists.txt create mode 100644 integration_test/stim/CMakeLists.txt create mode 100644 integration_test/stim/Main.cpp create mode 100644 integration_test/tester/CMakeLists.txt create mode 100644 integration_test/tester/Main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3037d8fe..2673afb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ endif() add_subdirectory(hal_st) add_subdirectory(hal_st_lwip) +add_subdirectory(integration_test) emil_clangformat_directories(hal_st DIRECTORIES .) diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt new file mode 100644 index 00000000..7bdf241a --- /dev/null +++ b/integration_test/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(stim) +add_subdirectory(tester) diff --git a/integration_test/stim/CMakeLists.txt b/integration_test/stim/CMakeLists.txt new file mode 100644 index 00000000..82fa2a74 --- /dev/null +++ b/integration_test/stim/CMakeLists.txt @@ -0,0 +1,9 @@ +if ("${TARGET_MCU}" STREQUAL "stm32f767") + add_executable(integration_test.stim Main.cpp) + target_link_libraries(integration_test.stim PRIVATE + services.util + hal_st.instantiations + ) + + emil_generate_artifacts(TARGET integration_test.stim LST MAP BIN HEX) +endif() diff --git a/integration_test/stim/Main.cpp b/integration_test/stim/Main.cpp new file mode 100644 index 00000000..035a1514 --- /dev/null +++ b/integration_test/stim/Main.cpp @@ -0,0 +1,31 @@ +#include "hal_st/instantiations/NucleoUi.hpp" +#include "hal_st/instantiations/StmEventInfrastructure.hpp" +#include "services/util/DebugLed.hpp" +#include "hal/interfaces/Gpio.hpp" + +extern "C" void Default_Handler() +{ + hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); +} + +int main() +{ + static main_::StmEventInfrastructure eventInfrastructure; + static main_::NucleoF767ziUi ui; + static services::DebugLed debugLed(ui.ledBlue); + + static hal::GpioPinStm inPin(hal::Port::F, 7); + static hal::GpioPinStm outPin(hal::Port::F, 8); + static hal::GpioPinStm outNPin(hal::Port::F, 9); + inPin.Config(hal::PinConfigType::input); + outNPin.Set(true); + + inPin.EnableInterrupt([]() { + const auto value = inPin.Get(); + outPin.Set(value); + outNPin.Set(!value); + }, hal::InterruptTrigger::bothEdges); + + eventInfrastructure.Run(); + __builtin_unreachable(); +} diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt new file mode 100644 index 00000000..e91cfdd9 --- /dev/null +++ b/integration_test/tester/CMakeLists.txt @@ -0,0 +1,9 @@ +if ("${TARGET_MCU}" STREQUAL "stm32f767") + add_executable(integration_test.tester Main.cpp) + target_link_libraries(integration_test.tester PRIVATE + services.util + hal_st.instantiations + ) + + emil_generate_artifacts(TARGET integration_test.tester LST MAP BIN HEX) +endif() diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp new file mode 100644 index 00000000..7416c03d --- /dev/null +++ b/integration_test/tester/Main.cpp @@ -0,0 +1,34 @@ +#include "hal_st/instantiations/NucleoUi.hpp" +#include "hal_st/instantiations/StmEventInfrastructure.hpp" +#include "services/util/DebugLed.hpp" +#include "hal/interfaces/Gpio.hpp" + +extern "C" void Default_Handler() +{ + hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); +} + +int main() +{ + static main_::StmEventInfrastructure eventInfrastructure; + static main_::NucleoF767ziUi ui; + static services::DebugLed debugLed(ui.ledBlue); + + static hal::GpioPinStm outPin(hal::Port::F, 7); + static hal::GpioPinStm inPin(hal::Port::F, 8); + static hal::GpioPinStm inNPin(hal::Port::F, 9); + inPin.Config(hal::PinConfigType::input); + inNPin.Config(hal::PinConfigType::input); + + ui.userButtonPin.EnableInterrupt([]() { + const bool expect = true; + outPin.Set(expect); + const auto value = inPin.Get(); + const auto nValue = inNPin.Get(); + ui.ledGreen.Set(value == expect && nValue == !expect); + ui.ledRed.Set(value != expect || nValue != !expect); + }, hal::InterruptTrigger::fallingEdge); + + eventInfrastructure.Run(); + __builtin_unreachable(); +} From f098fa5cfb44ba406f652c5c96fff76aaefa1af4 Mon Sep 17 00:00:00 2001 From: Thomas de Bont Date: Tue, 28 Mar 2023 16:12:51 +0000 Subject: [PATCH 03/21] handshake and timeout to test GPIO --- integration_test/stim/Main.cpp | 8 ++++ integration_test/tester/Main.cpp | 75 ++++++++++++++++++++++++++++---- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/integration_test/stim/Main.cpp b/integration_test/stim/Main.cpp index 035a1514..f561255f 100644 --- a/integration_test/stim/Main.cpp +++ b/integration_test/stim/Main.cpp @@ -2,6 +2,7 @@ #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "services/util/DebugLed.hpp" #include "hal/interfaces/Gpio.hpp" +#include "services/util/GpioPinInverted.hpp" extern "C" void Default_Handler() { @@ -10,6 +11,11 @@ extern "C" void Default_Handler() int main() { + static hal::GpioPinStm nBooted(hal::Port::E, 3); + static services::GpioPinInverted booted(nBooted); + + booted.Set(false); + static main_::StmEventInfrastructure eventInfrastructure; static main_::NucleoF767ziUi ui; static services::DebugLed debugLed(ui.ledBlue); @@ -26,6 +32,8 @@ int main() outNPin.Set(!value); }, hal::InterruptTrigger::bothEdges); + booted.Set(true); + eventInfrastructure.Run(); __builtin_unreachable(); } diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 7416c03d..7a3f1a1b 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -1,7 +1,22 @@ #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "services/util/DebugLed.hpp" +#include "infra/timer/Timer.hpp" #include "hal/interfaces/Gpio.hpp" +#include "hal_st/stm32fxxx/DmaStm.hpp" +#include "hal_st/stm32fxxx/UartStmDma.hpp" +#include "services/util/GpioPinInverted.hpp" + +/* Tester Stim Function + * ------ ------ -------- + * CN8-9 -> CN8-9 E5V (NOTE: set JP3 on the Stim to E5V) + * CN8-11 -- CN8-11 ground + * CN9-20 -> CN8-5 nRst of Stim + * CN9-22 <> CN9-22 open drain "#booted" signal (pulled up by Tester) + * CN9-24 <- CN9-24 non-inverted GPIO + * CN9-26 -> CN9-26 Tester GPIO control + * CN9-28 <- CN9-28 inverted GPIO + */ extern "C" void Default_Handler() { @@ -19,15 +34,57 @@ int main() static hal::GpioPinStm inNPin(hal::Port::F, 9); inPin.Config(hal::PinConfigType::input); inNPin.Config(hal::PinConfigType::input); - - ui.userButtonPin.EnableInterrupt([]() { - const bool expect = true; - outPin.Set(expect); - const auto value = inPin.Get(); - const auto nValue = inNPin.Get(); - ui.ledGreen.Set(value == expect && nValue == !expect); - ui.ledRed.Set(value != expect || nValue != !expect); - }, hal::InterruptTrigger::fallingEdge); + + static hal::GpioPinStm nResetStim(hal::Port::E, 6, hal::Drive::OpenDrain); + static services::GpioPinInverted resetStim(nResetStim); // false: HiZ, true: Low + static hal::GpioPinStm nBooted(hal::Port::E, 3, hal::Drive::OpenDrain, hal::Speed::Default, hal::WeakPull::Up); + static services::GpioPinInverted booted(nBooted); + booted.Config(hal::PinConfigType::input); + + outPin.Set(false); // NOTE: is this redundant? + resetStim.Set(true); + infra::TimerSingleShot resetTimer(std::chrono::milliseconds(3), []() + { + if (booted.Get() == true) { + ui.ledGreen.Set(false); + ui.ledRed.Set(true); + } + else + { + booted.EnableInterrupt([]() { + ui.ledGreen.Set(true); + ui.ledRed.Set(true); + + ui.userButtonPin.EnableInterrupt([]() { + if (inPin.Get() == true) + { + ui.ledGreen.Set(false); + ui.ledRed.Set(true); + } + else + { + static infra::TimerSingleShot gpioTimeout(std::chrono::seconds(1), []() { + inPin.DisableInterrupt(); + ui.ledGreen.Set(false); + ui.ledRed.Set(true); + }); + + const bool expect = true; + inPin.EnableInterrupt([]() { + gpioTimeout.Cancel(); + const auto value = inPin.Get(); + const auto nValue = inNPin.Get(); + ui.ledGreen.Set(value == expect && nValue == !expect); + ui.ledRed.Set(value != expect || nValue != !expect); + }, hal::InterruptTrigger::risingEdge); + + outPin.Set(expect); + } + }, hal::InterruptTrigger::fallingEdge); + }, hal::InterruptTrigger::risingEdge); + resetStim.Set(false); + } + }); eventInfrastructure.Run(); __builtin_unreachable(); From b06e5597d983eb0c943b88fcf798da4fdc947db3 Mon Sep 17 00:00:00 2001 From: Thomas de Bont Date: Thu, 30 Mar 2023 10:00:28 +0000 Subject: [PATCH 04/21] Refactor and use InputPin/OutputPin --- integration_test/stim/Main.cpp | 49 +++++--- integration_test/tester/Main.cpp | 192 ++++++++++++++++++++++--------- 2 files changed, 174 insertions(+), 67 deletions(-) diff --git a/integration_test/stim/Main.cpp b/integration_test/stim/Main.cpp index f561255f..c552a2c8 100644 --- a/integration_test/stim/Main.cpp +++ b/integration_test/stim/Main.cpp @@ -9,12 +9,42 @@ extern "C" void Default_Handler() hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); } -int main() +class StimGpio { +public: + explicit StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin); + +private: + void Update(); + + hal::InputPin in; + hal::OutputPin out; + services::GpioPinInverted outNPinInverted; + hal::OutputPin outN; +}; + +StimGpio::StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin) +: in(inPin) +, out(outPin) +, outNPinInverted(outNPin) +, outN(outNPinInverted) +{ + Update(); + + in.EnableInterrupt([this]() { Update(); }, hal::InterruptTrigger::bothEdges); +} + +void StimGpio::Update() { - static hal::GpioPinStm nBooted(hal::Port::E, 3); - static services::GpioPinInverted booted(nBooted); + const auto value = in.Get(); + out.Set(value); + outN.Set(value); +} - booted.Set(false); +int main() +{ + static hal::GpioPinStm nBootedPin(hal::Port::E, 3); + static services::GpioPinInverted bootedPin(nBootedPin); + static hal::OutputPin booted(bootedPin, false); static main_::StmEventInfrastructure eventInfrastructure; static main_::NucleoF767ziUi ui; @@ -23,17 +53,10 @@ int main() static hal::GpioPinStm inPin(hal::Port::F, 7); static hal::GpioPinStm outPin(hal::Port::F, 8); static hal::GpioPinStm outNPin(hal::Port::F, 9); - inPin.Config(hal::PinConfigType::input); - outNPin.Set(true); - - inPin.EnableInterrupt([]() { - const auto value = inPin.Get(); - outPin.Set(value); - outNPin.Set(!value); - }, hal::InterruptTrigger::bothEdges); + + static StimGpio stimGpio(inPin, outPin, outNPin); booted.Set(true); - eventInfrastructure.Run(); __builtin_unreachable(); } diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 7a3f1a1b..87d7cc1b 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -6,6 +6,7 @@ #include "hal_st/stm32fxxx/DmaStm.hpp" #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "services/util/GpioPinInverted.hpp" +#include "services/util/DebouncedButton.hpp" /* Tester Stim Function * ------ ------ -------- @@ -23,69 +24,152 @@ extern "C" void Default_Handler() hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); } +class Report +{ +public: + Report(hal::GpioPin& redPin, hal::GpioPin& greenPin) + : red(redPin) + , green(greenPin) + {} + + enum class Condition + { + Ready, + Success, + Timeout, + FailedPrecondition, + Failed + }; + + void State(Condition condition) + { + red.Set(Conditions[static_cast(condition)].red); + green.Set(Conditions[static_cast(condition)].green); + } + +private: + hal::OutputPin red; + hal::OutputPin green; + + struct + { + bool red; + bool green; + } Conditions[5] = + { + {true, true}, + {false, true}, + {true, false}, + {true, false}, + {true, false} + }; +}; + +class Tester +{ +public: + Tester(hal::GpioPin& resetPin, hal::GpioPin& bootedPin, hal::GpioPin& outPin, hal::GpioPin& inPin, hal::GpioPin& inNPin, Report& report) + : ready(false) + , reset(resetPin, false) + , booted(bootedPin) + , out(outPin, false) + , in(inPin) + , inN(inNPin) + , report(report) + {} + + void ResetStim(); + void Run(); + +private: + void Timeout(); + void Triggered(); + +private: + volatile bool ready; + hal::OutputPin reset; + hal::InputPin booted; + hal::OutputPin out; + hal::InputPin in; + hal::InputPin inN; + Report& report; + infra::TimerSingleShot gpioTimeout; + infra::TimerSingleShot resetTimer; +}; + +void Tester::ResetStim() +{ + ready = false; + reset.Set(true); + + resetTimer.Start(std::chrono::milliseconds(3), [this]() + { + assert(booted.Get() == true); + booted.EnableInterrupt([this]() { + report.State(Report::Condition::Ready); + ready = true; + }, hal::InterruptTrigger::risingEdge); + reset.Set(false); + }); +} + +void Tester::Run() +{ + if (!ready) return; + + if (in.Get() == true) + { + report.State(Report::Condition::FailedPrecondition); + return; + } + + const bool expected = true; + const auto expectedEdge = expected ? hal::InterruptTrigger::risingEdge : hal::InterruptTrigger::fallingEdge; + gpioTimeout.Start(std::chrono::seconds(1), [this]() { Timeout(); }); + in.EnableInterrupt([this]() { Triggered(); }, expectedEdge); + out.Set(expected); +} + +void Tester::Timeout() +{ + in.DisableInterrupt(); + report.State(Report::Condition::Timeout); +} + +void Tester::Triggered() +{ + gpioTimeout.Cancel(); + if (in.Get() != inN.Get()) + report.State(Report::Condition::Success); + else + report.State(Report::Condition::Failed); +} + int main() { static main_::StmEventInfrastructure eventInfrastructure; static main_::NucleoF767ziUi ui; - static services::DebugLed debugLed(ui.ledBlue); + + // I/O towards Stim + static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); + static services::GpioPinInverted nResetStimPinInverted(nResetStimPin); // false: HiZ, true: Low + + static hal::GpioPinStm nBootedPin(hal::Port::E, 3, hal::Drive::OpenDrain, hal::Speed::Default, hal::WeakPull::Up); + static services::GpioPinInverted nBootedPinInverted(nBootedPin); static hal::GpioPinStm outPin(hal::Port::F, 7); static hal::GpioPinStm inPin(hal::Port::F, 8); static hal::GpioPinStm inNPin(hal::Port::F, 9); - inPin.Config(hal::PinConfigType::input); - inNPin.Config(hal::PinConfigType::input); - - static hal::GpioPinStm nResetStim(hal::Port::E, 6, hal::Drive::OpenDrain); - static services::GpioPinInverted resetStim(nResetStim); // false: HiZ, true: Low - static hal::GpioPinStm nBooted(hal::Port::E, 3, hal::Drive::OpenDrain, hal::Speed::Default, hal::WeakPull::Up); - static services::GpioPinInverted booted(nBooted); - booted.Config(hal::PinConfigType::input); - - outPin.Set(false); // NOTE: is this redundant? - resetStim.Set(true); - infra::TimerSingleShot resetTimer(std::chrono::milliseconds(3), []() - { - if (booted.Get() == true) { - ui.ledGreen.Set(false); - ui.ledRed.Set(true); - } - else - { - booted.EnableInterrupt([]() { - ui.ledGreen.Set(true); - ui.ledRed.Set(true); - - ui.userButtonPin.EnableInterrupt([]() { - if (inPin.Get() == true) - { - ui.ledGreen.Set(false); - ui.ledRed.Set(true); - } - else - { - static infra::TimerSingleShot gpioTimeout(std::chrono::seconds(1), []() { - inPin.DisableInterrupt(); - ui.ledGreen.Set(false); - ui.ledRed.Set(true); - }); - - const bool expect = true; - inPin.EnableInterrupt([]() { - gpioTimeout.Cancel(); - const auto value = inPin.Get(); - const auto nValue = inNPin.Get(); - ui.ledGreen.Set(value == expect && nValue == !expect); - ui.ledRed.Set(value != expect || nValue != !expect); - }, hal::InterruptTrigger::risingEdge); - - outPin.Set(expect); - } - }, hal::InterruptTrigger::fallingEdge); - }, hal::InterruptTrigger::risingEdge); - resetStim.Set(false); - } - }); + // Tester infrastucture + static Report report(ui.ledRed, ui.ledGreen); + + static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, report); + tester.ResetStim(); + static services::DebouncedButton button(ui.userButtonPin, []() { tester.Run(); }); // how to disable until booted? + + // Event loop + static services::DebugLed debugLed(ui.ledBlue); eventInfrastructure.Run(); __builtin_unreachable(); } From b562635f0bf7662039f878bc0019ac78990243cb Mon Sep 17 00:00:00 2001 From: Thomas de Bont Date: Wed, 5 Apr 2023 14:45:14 +0000 Subject: [PATCH 05/21] Added echo support (not working state) --- integration_test/tester/CMakeLists.txt | 3 + integration_test/tester/Main.cpp | 120 +++++++++++++++++++++---- integration_test/tester/Tester.proto | 28 ++++++ 3 files changed, 135 insertions(+), 16 deletions(-) create mode 100644 integration_test/tester/Tester.proto diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt index e91cfdd9..e9a752e5 100644 --- a/integration_test/tester/CMakeLists.txt +++ b/integration_test/tester/CMakeLists.txt @@ -3,7 +3,10 @@ if ("${TARGET_MCU}" STREQUAL "stm32f767") target_link_libraries(integration_test.tester PRIVATE services.util hal_st.instantiations + protobuf.echo ) + protocol_buffer_echo_cpp(integration_test.tester Tester.proto) + emil_generate_artifacts(TARGET integration_test.tester LST MAP BIN HEX) endif() diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 87d7cc1b..850c4b2f 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -7,6 +7,8 @@ #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "services/util/GpioPinInverted.hpp" #include "services/util/DebouncedButton.hpp" +#include "protobuf/echo/EchoInstantiation.hpp" +#include "generated/echo/Tester.pb.hpp" /* Tester Stim Function * ------ ------ -------- @@ -19,19 +21,20 @@ * CN9-28 <- CN9-28 inverted GPIO */ + +/* Connect debug session to GDB, bring up with: + * JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile + */ + extern "C" void Default_Handler() { hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); } + class Report { public: - Report(hal::GpioPin& redPin, hal::GpioPin& greenPin) - : red(redPin) - , green(greenPin) - {} - enum class Condition { Ready, @@ -41,21 +44,68 @@ class Report Failed }; - void State(Condition condition) + virtual void State(Condition condition) = 0; +}; + + +class LedReport + : public Report +{ +public: + LedReport(hal::GpioPin& redPin, hal::GpioPin& greenPin) + : red(redPin) + , green(greenPin) + {} + + void State(Condition condition) override { - red.Set(Conditions[static_cast(condition)].red); - green.Set(Conditions[static_cast(condition)].green); + red.Set(conditions[static_cast(condition)].red); + green.Set(conditions[static_cast(condition)].green); } private: hal::OutputPin red; hal::OutputPin green; - struct + static constexpr struct { bool red; bool green; - } Conditions[5] = + } conditions[5] = + { + {true, true}, + {false, true}, + {true, false}, + {true, false}, + {true, false} + }; +}; + + +class EchoReport + : public Report +{ +public: + EchoReport(tester_echo::ReponseProxy& response) + : response(response) + {} + + void State(Condition condition) override + { + response.RequestSend([this, condition]() { + response.GpioTestResult(conditions[static_cast(condition)].value, conditions[static_cast(condition)].valueN); + }); + + } + +private: + tester_echo::ReponseProxy& response; + + static constexpr struct + { + bool value; + bool valueN; + } conditions[5] = { {true, true}, {false, true}, @@ -97,12 +147,13 @@ class Tester infra::TimerSingleShot resetTimer; }; + void Tester::ResetStim() { ready = false; reset.Set(true); - resetTimer.Start(std::chrono::milliseconds(3), [this]() + resetTimer.Start(std::chrono::milliseconds(3000), [this]() { assert(booted.Get() == true); booted.EnableInterrupt([this]() { @@ -113,6 +164,7 @@ void Tester::ResetStim() }); } + void Tester::Run() { if (!ready) return; @@ -130,12 +182,14 @@ void Tester::Run() out.Set(expected); } + void Tester::Timeout() { in.DisableInterrupt(); report.State(Report::Condition::Timeout); } + void Tester::Triggered() { gpioTimeout.Cancel(); @@ -145,6 +199,31 @@ void Tester::Triggered() report.State(Report::Condition::Failed); } + +class Command + : public tester_echo::Command +{ +public: + Command(services::Echo& echo, Tester& tester, hal::GpioPin& led) + : tester_echo::Command(echo) + , tester(tester) + , led(led) + { + } + + void RunGpioTest(bool value) override + { + led.Set(true); + tester.Run(); + MethodDone(); + } + +private: + Tester& tester; + hal::OutputPin led; +}; + + int main() { static main_::StmEventInfrastructure eventInfrastructure; @@ -161,14 +240,23 @@ int main() static hal::GpioPinStm inPin(hal::Port::F, 8); static hal::GpioPinStm inNPin(hal::Port::F, 9); + // Echo infrastructure + static hal::GpioPinStm hostUartTxPin(hal::Port::C, 10); + static hal::GpioPinStm hostUartRxPin(hal::Port::C, 11); + static hal::DmaStm dma; + static hal::UartStmDma hostUart(dma, 4, hostUartTxPin, hostUartRxPin); + static main_::EchoOnSerialCommunication<60> echo(hostUart); + static tester_echo::ReponseProxy response(echo); + // Tester infrastucture - static Report report(ui.ledRed, ui.ledGreen); - - static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, report); + static LedReport ledReport(ui.ledRed, ui.ledGreen); + static EchoReport echoReport(response); + static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, echoReport); tester.ResetStim(); - static services::DebouncedButton button(ui.userButtonPin, []() { tester.Run(); }); // how to disable until booted? + static services::DebouncedButton button(ui.userButtonPin, []() { tester.Run(); }); - // Event loop + // Event infrastructure + static Command command(echo, tester, ui.ledGreen); static services::DebugLed debugLed(ui.ledBlue); eventInfrastructure.Run(); __builtin_unreachable(); diff --git a/integration_test/tester/Tester.proto b/integration_test/tester/Tester.proto new file mode 100644 index 00000000..0f2c5941 --- /dev/null +++ b/integration_test/tester/Tester.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +import "EchoAttributes.proto"; + +package tester_echo; + +message GpioOut { + bool value = 1; +} + +message GpioIn { + bool value = 1; + bool valueN = 2; +} + +service Command +{ + option (service_id) = 1; + + rpc RunGpioTest(GpioOut) returns (Nothing) { option (method_id) = 1; } +} + +service Reponse +{ + option (service_id) = 2; + + rpc GpioTestResult(GpioIn) returns (Nothing) { option (method_id) = 1; } +} \ No newline at end of file From d9959ca5773afe329977cbf651751f9ae22e3b0d Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Sat, 3 Jun 2023 08:29:58 +0200 Subject: [PATCH 06/21] Format CMakeLists.txt and Main.cpp --- examples/freertos/Main.cpp | 25 +++-- integration_test/stim/CMakeLists.txt | 18 ++-- integration_test/stim/Main.cpp | 21 ++-- integration_test/tester/CMakeLists.txt | 22 ++-- integration_test/tester/Main.cpp | 136 +++++++++++-------------- 5 files changed, 113 insertions(+), 109 deletions(-) diff --git a/examples/freertos/Main.cpp b/examples/freertos/Main.cpp index 9ed4d5ab..da19c9e1 100644 --- a/examples/freertos/Main.cpp +++ b/examples/freertos/Main.cpp @@ -14,9 +14,20 @@ extern "C" void xPortPendSVHandler(); extern "C" void xPortSysTickHandler(); extern "C" void vPortSVCHandler(); -extern "C" [[gnu::naked]] void SVC_Handler() { asm("b vPortSVCHandler"); } -extern "C" [[gnu::naked]] void PendSV_Handler() { asm("b xPortPendSVHandler"); } -extern "C" [[gnu::naked]] void SysTick_Handler() { asm("b xPortSysTickHandler"); }; +extern "C" [[gnu::naked]] void SVC_Handler() +{ + asm("b vPortSVCHandler"); +} + +extern "C" [[gnu::naked]] void PendSV_Handler() +{ + asm("b xPortPendSVHandler"); +} + +extern "C" [[gnu::naked]] void SysTick_Handler() +{ + asm("b xPortSysTickHandler"); +}; unsigned int hse_value = 8000000; @@ -25,7 +36,7 @@ int main() HAL_Init(); // Configure your clock here - //ConfigureDefaultClockNucleo767ZI(); + // ConfigureDefaultClockNucleo767ZI(); static hal::InterruptTable::WithStorage<128> interruptTable; static hal::GpioStm gpio{ hal::pinoutTableDefaultStm, hal::analogTableDefaultStm }; @@ -48,8 +59,7 @@ int main() pin.Set(true); std::this_thread::sleep_for(200ms); pin.Set(false); - } - }); + } }); static std::thread t2([]() { @@ -60,8 +70,7 @@ int main() pin.Set(!pin.GetOutputLatch()); }); - eventDispatcher.Run(); - }); + eventDispatcher.Run(); }); osal::Run(); __builtin_unreachable(); diff --git a/integration_test/stim/CMakeLists.txt b/integration_test/stim/CMakeLists.txt index 82fa2a74..23d3383f 100644 --- a/integration_test/stim/CMakeLists.txt +++ b/integration_test/stim/CMakeLists.txt @@ -1,9 +1,11 @@ -if ("${TARGET_MCU}" STREQUAL "stm32f767") - add_executable(integration_test.stim Main.cpp) - target_link_libraries(integration_test.stim PRIVATE - services.util - hal_st.instantiations - ) +add_executable(integration_test.stim) +emil_build_for(integration_test.stim TARGET_MCU stm32f767) - emil_generate_artifacts(TARGET integration_test.stim LST MAP BIN HEX) -endif() +target_sources(integration_test.stim PRIVATE + Main.cpp +) + +target_link_libraries(integration_test.stim PRIVATE + services.util + hal_st.instantiations +) diff --git a/integration_test/stim/Main.cpp b/integration_test/stim/Main.cpp index c552a2c8..0c81d208 100644 --- a/integration_test/stim/Main.cpp +++ b/integration_test/stim/Main.cpp @@ -1,7 +1,7 @@ +#include "hal/interfaces/Gpio.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "services/util/DebugLed.hpp" -#include "hal/interfaces/Gpio.hpp" #include "services/util/GpioPinInverted.hpp" extern "C" void Default_Handler() @@ -9,7 +9,8 @@ extern "C" void Default_Handler() hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); } -class StimGpio { +class StimGpio +{ public: explicit StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin); @@ -23,14 +24,16 @@ class StimGpio { }; StimGpio::StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin) -: in(inPin) -, out(outPin) -, outNPinInverted(outNPin) -, outN(outNPinInverted) + : in(inPin) + , out(outPin) + , outNPinInverted(outNPin) + , outN(outNPinInverted) { Update(); - - in.EnableInterrupt([this]() { Update(); }, hal::InterruptTrigger::bothEdges); + + in.EnableInterrupt([this]() + { Update(); }, + hal::InterruptTrigger::bothEdges); } void StimGpio::Update() @@ -48,7 +51,7 @@ int main() static main_::StmEventInfrastructure eventInfrastructure; static main_::NucleoF767ziUi ui; - static services::DebugLed debugLed(ui.ledBlue); + static services::DebugLed debugLed(ui.ledBlue); static hal::GpioPinStm inPin(hal::Port::F, 7); static hal::GpioPinStm outPin(hal::Port::F, 8); diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt index e9a752e5..6c082dd1 100644 --- a/integration_test/tester/CMakeLists.txt +++ b/integration_test/tester/CMakeLists.txt @@ -1,12 +1,14 @@ -if ("${TARGET_MCU}" STREQUAL "stm32f767") - add_executable(integration_test.tester Main.cpp) - target_link_libraries(integration_test.tester PRIVATE - services.util - hal_st.instantiations - protobuf.echo - ) +add_executable(integration_test.tester) +emil_build_for(integration_test.tester TARGET_MCU stm32f767) - protocol_buffer_echo_cpp(integration_test.tester Tester.proto) +protocol_buffer_echo_cpp(integration_test.tester Tester.proto) - emil_generate_artifacts(TARGET integration_test.tester LST MAP BIN HEX) -endif() +target_sources(integration_test.tester PRIVATE + Main.cpp +) + +target_link_libraries(integration_test.tester PRIVATE + services.util + hal_st.instantiations + protobuf.echo +) diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 850c4b2f..59f19074 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -1,37 +1,33 @@ +#include "generated/echo/Tester.pb.hpp" +#include "hal/interfaces/Gpio.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" -#include "services/util/DebugLed.hpp" -#include "infra/timer/Timer.hpp" -#include "hal/interfaces/Gpio.hpp" #include "hal_st/stm32fxxx/DmaStm.hpp" #include "hal_st/stm32fxxx/UartStmDma.hpp" -#include "services/util/GpioPinInverted.hpp" -#include "services/util/DebouncedButton.hpp" +#include "infra/timer/Timer.hpp" #include "protobuf/echo/EchoInstantiation.hpp" -#include "generated/echo/Tester.pb.hpp" - -/* Tester Stim Function - * ------ ------ -------- - * CN8-9 -> CN8-9 E5V (NOTE: set JP3 on the Stim to E5V) - * CN8-11 -- CN8-11 ground - * CN9-20 -> CN8-5 nRst of Stim - * CN9-22 <> CN9-22 open drain "#booted" signal (pulled up by Tester) - * CN9-24 <- CN9-24 non-inverted GPIO - * CN9-26 -> CN9-26 Tester GPIO control - * CN9-28 <- CN9-28 inverted GPIO - */ +#include "services/util/DebouncedButton.hpp" +#include "services/util/DebugLed.hpp" +#include "services/util/GpioPinInverted.hpp" +// Tester Stim Function +// ------ ------ -------- +// CN8-9 -> CN8-9 E5V (NOTE: set JP3 on the Stim to E5V) +// CN8-11 -- CN8-11 ground +// CN9-20 -> CN8-5 nRst of Stim +// CN9-22 <> CN9-22 open drain "#booted" signal (pulled up by Tester) +// CN9-24 <- CN9-24 non-inverted GPIO +// CN9-26 -> CN9-26 Tester GPIO control +// CN9-28 <- CN9-28 inverted GPIO -/* Connect debug session to GDB, bring up with: - * JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile - */ +// Connect debug session to GDB, bring up with: +// JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile extern "C" void Default_Handler() { hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); } - class Report { public: @@ -47,14 +43,13 @@ class Report virtual void State(Condition condition) = 0; }; - class LedReport : public Report { public: LedReport(hal::GpioPin& redPin, hal::GpioPin& greenPin) - : red(redPin) - , green(greenPin) + : red(redPin) + , green(greenPin) {} void State(Condition condition) override @@ -71,31 +66,27 @@ class LedReport { bool red; bool green; - } conditions[5] = - { - {true, true}, - {false, true}, - {true, false}, - {true, false}, - {true, false} + } conditions[5] = { + { true, true }, + { false, true }, + { true, false }, + { true, false }, + { true, false } }; }; - class EchoReport : public Report { public: EchoReport(tester_echo::ReponseProxy& response) - : response(response) + : response(response) {} void State(Condition condition) override { - response.RequestSend([this, condition]() { - response.GpioTestResult(conditions[static_cast(condition)].value, conditions[static_cast(condition)].valueN); - }); - + response.RequestSend([this, condition]() + { response.GpioTestResult(conditions[static_cast(condition)].value, conditions[static_cast(condition)].valueN); }); } private: @@ -105,13 +96,12 @@ class EchoReport { bool value; bool valueN; - } conditions[5] = - { - {true, true}, - {false, true}, - {true, false}, - {true, false}, - {true, false} + } conditions[5] = { + { true, true }, + { false, true }, + { true, false }, + { true, false }, + { true, false } }; }; @@ -119,13 +109,13 @@ class Tester { public: Tester(hal::GpioPin& resetPin, hal::GpioPin& bootedPin, hal::GpioPin& outPin, hal::GpioPin& inPin, hal::GpioPin& inNPin, Report& report) - : ready(false) - , reset(resetPin, false) - , booted(bootedPin) - , out(outPin, false) - , in(inPin) - , inN(inNPin) - , report(report) + : ready(false) + , reset(resetPin, false) + , booted(bootedPin) + , out(outPin, false) + , in(inPin) + , inN(inNPin) + , report(report) {} void ResetStim(); @@ -147,59 +137,57 @@ class Tester infra::TimerSingleShot resetTimer; }; - void Tester::ResetStim() { ready = false; reset.Set(true); resetTimer.Start(std::chrono::milliseconds(3000), [this]() - { - assert(booted.Get() == true); + { + assert(booted.Get()); booted.EnableInterrupt([this]() { report.State(Report::Condition::Ready); ready = true; }, hal::InterruptTrigger::risingEdge); - reset.Set(false); - }); + reset.Set(false); }); } - void Tester::Run() { - if (!ready) return; + if (!ready) + return; - if (in.Get() == true) + if (in.Get()) { report.State(Report::Condition::FailedPrecondition); return; } - + const bool expected = true; const auto expectedEdge = expected ? hal::InterruptTrigger::risingEdge : hal::InterruptTrigger::fallingEdge; - gpioTimeout.Start(std::chrono::seconds(1), [this]() { Timeout(); }); - in.EnableInterrupt([this]() { Triggered(); }, expectedEdge); + gpioTimeout.Start(std::chrono::seconds(1), [this]() + { Timeout(); }); + in.EnableInterrupt([this]() + { Triggered(); }, + expectedEdge); out.Set(expected); } - void Tester::Timeout() { in.DisableInterrupt(); report.State(Report::Condition::Timeout); } - void Tester::Triggered() { - gpioTimeout.Cancel(); - if (in.Get() != inN.Get()) - report.State(Report::Condition::Success); - else - report.State(Report::Condition::Failed); + gpioTimeout.Cancel(); + if (in.Get() != inN.Get()) + report.State(Report::Condition::Success); + else + report.State(Report::Condition::Failed); } - class Command : public tester_echo::Command { @@ -223,7 +211,6 @@ class Command hal::OutputPin led; }; - int main() { static main_::StmEventInfrastructure eventInfrastructure; @@ -232,7 +219,7 @@ int main() // I/O towards Stim static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); static services::GpioPinInverted nResetStimPinInverted(nResetStimPin); // false: HiZ, true: Low - + static hal::GpioPinStm nBootedPin(hal::Port::E, 3, hal::Drive::OpenDrain, hal::Speed::Default, hal::WeakPull::Up); static services::GpioPinInverted nBootedPinInverted(nBootedPin); @@ -247,13 +234,14 @@ int main() static hal::UartStmDma hostUart(dma, 4, hostUartTxPin, hostUartRxPin); static main_::EchoOnSerialCommunication<60> echo(hostUart); static tester_echo::ReponseProxy response(echo); - + // Tester infrastucture static LedReport ledReport(ui.ledRed, ui.ledGreen); static EchoReport echoReport(response); static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, echoReport); tester.ResetStim(); - static services::DebouncedButton button(ui.userButtonPin, []() { tester.Run(); }); + static services::DebouncedButton button(ui.userButtonPin, []() + { tester.Run(); }); // Event infrastructure static Command command(echo, tester, ui.ledGreen); From 80526bedef4893346236af754bfe752d997b7409 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Mon, 12 Jun 2023 10:21:04 +0200 Subject: [PATCH 07/21] Update and restructure --- integration_test/CMakeLists.txt | 3 ++- integration_test/logic/CMakeLists.txt | 11 ++++++++ .../{tester => logic}/Tester.proto | 4 +-- integration_test/stim/CMakeLists.txt | 11 -------- integration_test/tested/CMakeLists.txt | 14 +++++++++++ integration_test/{stim => tested}/Main.cpp | 13 +++++----- integration_test/tester/CMakeLists.txt | 8 +++--- integration_test/tester/Main.cpp | 25 ++++++++++--------- 8 files changed, 53 insertions(+), 36 deletions(-) create mode 100644 integration_test/logic/CMakeLists.txt rename integration_test/{tester => logic}/Tester.proto (94%) delete mode 100644 integration_test/stim/CMakeLists.txt create mode 100644 integration_test/tested/CMakeLists.txt rename integration_test/{stim => tested}/Main.cpp (89%) diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt index 7bdf241a..bdd05027 100644 --- a/integration_test/CMakeLists.txt +++ b/integration_test/CMakeLists.txt @@ -1,2 +1,3 @@ -add_subdirectory(stim) +add_subdirectory(logic) +add_subdirectory(tested) add_subdirectory(tester) diff --git a/integration_test/logic/CMakeLists.txt b/integration_test/logic/CMakeLists.txt new file mode 100644 index 00000000..9b121bab --- /dev/null +++ b/integration_test/logic/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(integration_test.logic ${HALST_EXCLUDE_FROM_ALL}) + +protocol_buffer_echo_cpp(integration_test.logic Tester.proto) + +#target_sources(integration_test.logic PRIVATE +#) + +target_link_libraries(integration_test.logic PRIVATE + services.util + protobuf.echo +) diff --git a/integration_test/tester/Tester.proto b/integration_test/logic/Tester.proto similarity index 94% rename from integration_test/tester/Tester.proto rename to integration_test/logic/Tester.proto index 0f2c5941..79b7b4eb 100644 --- a/integration_test/tester/Tester.proto +++ b/integration_test/logic/Tester.proto @@ -2,7 +2,7 @@ syntax = "proto3"; import "EchoAttributes.proto"; -package tester_echo; +package tester; message GpioOut { bool value = 1; @@ -25,4 +25,4 @@ service Reponse option (service_id) = 2; rpc GpioTestResult(GpioIn) returns (Nothing) { option (method_id) = 1; } -} \ No newline at end of file +} diff --git a/integration_test/stim/CMakeLists.txt b/integration_test/stim/CMakeLists.txt deleted file mode 100644 index 23d3383f..00000000 --- a/integration_test/stim/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_executable(integration_test.stim) -emil_build_for(integration_test.stim TARGET_MCU stm32f767) - -target_sources(integration_test.stim PRIVATE - Main.cpp -) - -target_link_libraries(integration_test.stim PRIVATE - services.util - hal_st.instantiations -) diff --git a/integration_test/tested/CMakeLists.txt b/integration_test/tested/CMakeLists.txt new file mode 100644 index 00000000..33144840 --- /dev/null +++ b/integration_test/tested/CMakeLists.txt @@ -0,0 +1,14 @@ +add_executable(integration_test.tested) +emil_build_for(integration_test.tested TARGET_MCU stm32f767) + +target_sources(integration_test.tested PRIVATE + Main.cpp +) + +target_link_libraries(integration_test.tested PRIVATE + integration_test.logic + hal_st.instantiations +) + +halst_target_default_linker_scripts(integration_test.tested) +halst_target_default_init(integration_test.tested) diff --git a/integration_test/stim/Main.cpp b/integration_test/tested/Main.cpp similarity index 89% rename from integration_test/stim/Main.cpp rename to integration_test/tested/Main.cpp index 0c81d208..efe77762 100644 --- a/integration_test/stim/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -1,14 +1,10 @@ #include "hal/interfaces/Gpio.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" +#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" #include "services/util/DebugLed.hpp" #include "services/util/GpioPinInverted.hpp" -extern "C" void Default_Handler() -{ - hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); -} - class StimGpio { public: @@ -43,14 +39,19 @@ void StimGpio::Update() outN.Set(value); } +unsigned int hse_value = 8000000; + int main() { + HAL_Init(); + ConfigureDefaultClockNucleo767ZI(); + static hal::GpioPinStm nBootedPin(hal::Port::E, 3); static services::GpioPinInverted bootedPin(nBootedPin); static hal::OutputPin booted(bootedPin, false); static main_::StmEventInfrastructure eventInfrastructure; - static main_::NucleoF767ziUi ui; + static main_::Nucleo144Ui ui; static services::DebugLed debugLed(ui.ledBlue); static hal::GpioPinStm inPin(hal::Port::F, 7); diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt index 6c082dd1..31871ede 100644 --- a/integration_test/tester/CMakeLists.txt +++ b/integration_test/tester/CMakeLists.txt @@ -1,14 +1,14 @@ add_executable(integration_test.tester) emil_build_for(integration_test.tester TARGET_MCU stm32f767) -protocol_buffer_echo_cpp(integration_test.tester Tester.proto) - target_sources(integration_test.tester PRIVATE Main.cpp ) target_link_libraries(integration_test.tester PRIVATE - services.util + integration_test.logic hal_st.instantiations - protobuf.echo ) + +halst_target_default_linker_scripts(integration_test.tester) +halst_target_default_init(integration_test.tester) diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 59f19074..b0dcfddb 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -2,6 +2,7 @@ #include "hal/interfaces/Gpio.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" +#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" #include "hal_st/stm32fxxx/DmaStm.hpp" #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "infra/timer/Timer.hpp" @@ -23,11 +24,6 @@ // Connect debug session to GDB, bring up with: // JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile -extern "C" void Default_Handler() -{ - hal::InterruptTable::Instance().Invoke(hal::ActiveInterrupt()); -} - class Report { public: @@ -79,7 +75,7 @@ class EchoReport : public Report { public: - EchoReport(tester_echo::ReponseProxy& response) + EchoReport(tester::ReponseProxy& response) : response(response) {} @@ -90,7 +86,7 @@ class EchoReport } private: - tester_echo::ReponseProxy& response; + tester::ReponseProxy& response; static constexpr struct { @@ -189,11 +185,11 @@ void Tester::Triggered() } class Command - : public tester_echo::Command + : public tester::Command { public: Command(services::Echo& echo, Tester& tester, hal::GpioPin& led) - : tester_echo::Command(echo) + : tester::Command(echo) , tester(tester) , led(led) { @@ -211,10 +207,15 @@ class Command hal::OutputPin led; }; +unsigned int hse_value = 8000000; + int main() { + HAL_Init(); + ConfigureDefaultClockNucleo767ZI(); + static main_::StmEventInfrastructure eventInfrastructure; - static main_::NucleoF767ziUi ui; + static main_::Nucleo144Ui ui; // I/O towards Stim static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); @@ -233,14 +234,14 @@ int main() static hal::DmaStm dma; static hal::UartStmDma hostUart(dma, 4, hostUartTxPin, hostUartRxPin); static main_::EchoOnSerialCommunication<60> echo(hostUart); - static tester_echo::ReponseProxy response(echo); + static tester::ReponseProxy response(echo); // Tester infrastucture static LedReport ledReport(ui.ledRed, ui.ledGreen); static EchoReport echoReport(response); static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, echoReport); tester.ResetStim(); - static services::DebouncedButton button(ui.userButtonPin, []() + static services::DebouncedButton button(ui.buttonOne, []() { tester.Run(); }); // Event infrastructure From ed48769a4c8b3214fbe29baf8ed4b7ca6d9a2bd3 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Mon, 12 Jun 2023 18:53:47 +0200 Subject: [PATCH 08/21] More restructuring --- CMakeLists.txt | 2 +- integration_test/CMakeLists.txt | 1 + .../instantiations_st/CMakeLists.txt | 11 +++ .../instantiations_st/EchoOnSesame.cpp | 1 + .../instantiations_st/EchoOnSesame.hpp | 19 ++++++ integration_test/logic/CMakeLists.txt | 4 +- integration_test/logic/Tester.proto | 28 -------- integration_test/logic/Testing.proto | 56 ++++++++++++++++ integration_test/tested/CMakeLists.txt | 3 +- integration_test/tested/Main.cpp | 64 ++++++++++-------- integration_test/tester/CMakeLists.txt | 3 +- integration_test/tester/Main.cpp | 67 +++++++------------ 12 files changed, 153 insertions(+), 106 deletions(-) create mode 100644 integration_test/instantiations_st/CMakeLists.txt create mode 100644 integration_test/instantiations_st/EchoOnSesame.cpp create mode 100644 integration_test/instantiations_st/EchoOnSesame.hpp delete mode 100644 integration_test/logic/Tester.proto create mode 100644 integration_test/logic/Testing.proto diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6b1683..34294a73 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if (HALST_STANDALONE) FetchContent_Declare( emil GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git - GIT_TAG 77eb4170285a16e31cae5aee6a96e792baea2aa7 # Unreleased + GIT_TAG d8b89886d0c903199821f133f0f0c511b8bef04f # Unreleased ) FetchContent_MakeAvailable(emil) diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt index bdd05027..a9345e50 100644 --- a/integration_test/CMakeLists.txt +++ b/integration_test/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(logic) +add_subdirectory(instantiations_st) add_subdirectory(tested) add_subdirectory(tester) diff --git a/integration_test/instantiations_st/CMakeLists.txt b/integration_test/instantiations_st/CMakeLists.txt new file mode 100644 index 00000000..fd65f120 --- /dev/null +++ b/integration_test/instantiations_st/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(integration_test.instantiations_st ${HALST_EXCLUDE_FROM_ALL}) + +target_sources(integration_test.instantiations_st PRIVATE + EchoOnSesame.cpp + EchoOnSesame.hpp +) + +target_link_libraries(integration_test.instantiations_st PUBLIC + integration_test.logic + hal_st.instantiations +) diff --git a/integration_test/instantiations_st/EchoOnSesame.cpp b/integration_test/instantiations_st/EchoOnSesame.cpp new file mode 100644 index 00000000..5bf23b1d --- /dev/null +++ b/integration_test/instantiations_st/EchoOnSesame.cpp @@ -0,0 +1 @@ +#include "integration_test/instantiations_st/EchoOnSesame.hpp" diff --git a/integration_test/instantiations_st/EchoOnSesame.hpp b/integration_test/instantiations_st/EchoOnSesame.hpp new file mode 100644 index 00000000..3e2ca854 --- /dev/null +++ b/integration_test/instantiations_st/EchoOnSesame.hpp @@ -0,0 +1,19 @@ +#ifndef HAL_ST_INTEGRATION_TEST_ECHO_ON_SESAME_HPP +#define HAL_ST_INTEGRATION_TEST_ECHO_ON_SESAME_HPP + +#include "hal_st/stm32fxxx/GpioStm.hpp" +#include "hal_st/stm32fxxx/UartStm.hpp" +#include "services/util/EchoInstantiation.hpp" + +namespace main_ +{ + struct EchoBetweenTesterAndTested + { + hal::GpioPinStm echoUartTx{ hal::Port::D, 2 }; + hal::GpioPinStm echoUartRx{ hal::Port::C, 12 }; + hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; + main_::EchoOnSerialCommunication<1024> echo{ echoUart }; + }; +} + +#endif diff --git a/integration_test/logic/CMakeLists.txt b/integration_test/logic/CMakeLists.txt index 9b121bab..eb189085 100644 --- a/integration_test/logic/CMakeLists.txt +++ b/integration_test/logic/CMakeLists.txt @@ -1,11 +1,11 @@ add_library(integration_test.logic ${HALST_EXCLUDE_FROM_ALL}) -protocol_buffer_echo_cpp(integration_test.logic Tester.proto) +protocol_buffer_echo_cpp(integration_test.logic Testing.proto) #target_sources(integration_test.logic PRIVATE #) -target_link_libraries(integration_test.logic PRIVATE +target_link_libraries(integration_test.logic PUBLIC services.util protobuf.echo ) diff --git a/integration_test/logic/Tester.proto b/integration_test/logic/Tester.proto deleted file mode 100644 index 79b7b4eb..00000000 --- a/integration_test/logic/Tester.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; - -import "EchoAttributes.proto"; - -package tester; - -message GpioOut { - bool value = 1; -} - -message GpioIn { - bool value = 1; - bool valueN = 2; -} - -service Command -{ - option (service_id) = 1; - - rpc RunGpioTest(GpioOut) returns (Nothing) { option (method_id) = 1; } -} - -service Reponse -{ - option (service_id) = 2; - - rpc GpioTestResult(GpioIn) returns (Nothing) { option (method_id) = 1; } -} diff --git a/integration_test/logic/Testing.proto b/integration_test/logic/Testing.proto new file mode 100644 index 00000000..e9453e90 --- /dev/null +++ b/integration_test/logic/Testing.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +import "EchoAttributes.proto"; + +package testing; + +message GpioOut { + bool value = 1; +} + +message GpioIn { + bool value = 1; + bool valueN = 2; +} + +message GpioState +{ + bool state = 1; + uint32 pin = 2; +} + +service Command +{ + option (service_id) = 1; + + rpc RunGpioTest(GpioOut) returns (Nothing) { option (method_id) = 1; } +} + +service Reponse +{ + option (service_id) = 2; + + rpc GpioTestResult(GpioIn) returns (Nothing) { option (method_id) = 1; } +} + +service GpioTester +{ + option (service_id) = 3; + + rpc SetGpio(GpioState) returns (Nothing) { option (method_id) = 1; } +} + +service GpioTested +{ + option (service_id) = 4; + + rpc SetGpio(GpioState) returns (Nothing) { option (method_id) = 1; } +} + +service GpioObserver +{ + option (service_id) = 5; + + rpc TesterGpioChanged(GpioState) returns (Nothing) { option (method_id) = 1; } + rpc TestedGpioChanged(GpioState) returns (Nothing) { option (method_id) = 2; } +} diff --git a/integration_test/tested/CMakeLists.txt b/integration_test/tested/CMakeLists.txt index 33144840..57167012 100644 --- a/integration_test/tested/CMakeLists.txt +++ b/integration_test/tested/CMakeLists.txt @@ -6,8 +6,7 @@ target_sources(integration_test.tested PRIVATE ) target_link_libraries(integration_test.tested PRIVATE - integration_test.logic - hal_st.instantiations + integration_test.instantiations_st ) halst_target_default_linker_scripts(integration_test.tested) diff --git a/integration_test/tested/Main.cpp b/integration_test/tested/Main.cpp index efe77762..fa9c4e8c 100644 --- a/integration_test/tested/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -1,66 +1,74 @@ -#include "hal/interfaces/Gpio.hpp" +#include "generated/echo/Testing.pb.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" +#include "integration_test/instantiations_st/EchoOnSesame.hpp" #include "services/util/DebugLed.hpp" #include "services/util/GpioPinInverted.hpp" -class StimGpio +unsigned int hse_value = 8000000; + +class GpioTested + : public testing::GpioTested + , public testing::GpioObserverProxy { public: - explicit StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin); + GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + + // Implementation of GpioTested + void SetGpio(bool state, uint32_t pin) override; private: - void Update(); + void InChanged(); +private: hal::InputPin in; hal::OutputPin out; - services::GpioPinInverted outNPinInverted; - hal::OutputPin outN; + bool sending = false; }; -StimGpio::StimGpio(hal::GpioPin& inPin, hal::GpioPin& outPin, hal::GpioPin& outNPin) - : in(inPin) - , out(outPin) - , outNPinInverted(outNPin) - , outN(outNPinInverted) +GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : testing::GpioTested(echo) + , testing::GpioObserverProxy(echo) + , in(inPin) + , out(outPin, false) { - Update(); - - in.EnableInterrupt([this]() - { Update(); }, - hal::InterruptTrigger::bothEdges); + in.EnableInterrupt([this]() { InChanged(); }, hal::InterruptTrigger::bothEdges); } -void StimGpio::Update() +void GpioTested::SetGpio(bool state, uint32_t pin) { - const auto value = in.Get(); - out.Set(value); - outN.Set(value); + out.Set(state); } -unsigned int hse_value = 8000000; +void GpioTested::InChanged() +{ + if (!sending) + RequestSend([this]() + { + sending = false; + TestedGpioChanged(in.Get(), 0); + }); + + sending = true; +} int main() { HAL_Init(); ConfigureDefaultClockNucleo767ZI(); - static hal::GpioPinStm nBootedPin(hal::Port::E, 3); - static services::GpioPinInverted bootedPin(nBootedPin); - static hal::OutputPin booted(bootedPin, false); - static main_::StmEventInfrastructure eventInfrastructure; static main_::Nucleo144Ui ui; static services::DebugLed debugLed(ui.ledBlue); static hal::GpioPinStm inPin(hal::Port::F, 7); static hal::GpioPinStm outPin(hal::Port::F, 8); - static hal::GpioPinStm outNPin(hal::Port::F, 9); - static StimGpio stimGpio(inPin, outPin, outNPin); + static main_::EchoBetweenTesterAndTested echo; + + GpioTested gpioTested(echo.echo, inPin, outPin); - booted.Set(true); eventInfrastructure.Run(); __builtin_unreachable(); } diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt index 31871ede..f688673e 100644 --- a/integration_test/tester/CMakeLists.txt +++ b/integration_test/tester/CMakeLists.txt @@ -6,8 +6,7 @@ target_sources(integration_test.tester PRIVATE ) target_link_libraries(integration_test.tester PRIVATE - integration_test.logic - hal_st.instantiations + integration_test.instantiations_st ) halst_target_default_linker_scripts(integration_test.tester) diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index b0dcfddb..4c23ad57 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -1,25 +1,24 @@ -#include "generated/echo/Tester.pb.hpp" -#include "hal/interfaces/Gpio.hpp" +#include "generated/echo/Testing.pb.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" #include "hal_st/stm32fxxx/DmaStm.hpp" #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "infra/timer/Timer.hpp" -#include "protobuf/echo/EchoInstantiation.hpp" +#include "integration_test/instantiations_st/EchoOnSesame.hpp" #include "services/util/DebouncedButton.hpp" #include "services/util/DebugLed.hpp" #include "services/util/GpioPinInverted.hpp" -// Tester Stim Function +// Tester Tested Function // ------ ------ -------- // CN8-9 -> CN8-9 E5V (NOTE: set JP3 on the Stim to E5V) // CN8-11 -- CN8-11 ground +// CN8-10 <- CN8-12 ECHO on SESAME +// CN8-12 -> CN8-10 ECHO on SESAME // CN9-20 -> CN8-5 nRst of Stim -// CN9-22 <> CN9-22 open drain "#booted" signal (pulled up by Tester) -// CN9-24 <- CN9-24 non-inverted GPIO +// CN9-24 <- CN9-24 GPIO set by Tester // CN9-26 -> CN9-26 Tester GPIO control -// CN9-28 <- CN9-28 inverted GPIO // Connect debug session to GDB, bring up with: // JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile @@ -75,7 +74,7 @@ class EchoReport : public Report { public: - EchoReport(tester::ReponseProxy& response) + EchoReport(testing::ReponseProxy& response) : response(response) {} @@ -86,7 +85,7 @@ class EchoReport } private: - tester::ReponseProxy& response; + testing::ReponseProxy& response; static constexpr struct { @@ -104,13 +103,10 @@ class EchoReport class Tester { public: - Tester(hal::GpioPin& resetPin, hal::GpioPin& bootedPin, hal::GpioPin& outPin, hal::GpioPin& inPin, hal::GpioPin& inNPin, Report& report) - : ready(false) - , reset(resetPin, false) - , booted(bootedPin) + Tester(hal::GpioPin& resetPin, hal::GpioPin& outPin, hal::GpioPin& inPin, Report& report) + : reset(resetPin, false) , out(outPin, false) , in(inPin) - , inN(inNPin) , report(report) {} @@ -122,12 +118,9 @@ class Tester void Triggered(); private: - volatile bool ready; hal::OutputPin reset; - hal::InputPin booted; hal::OutputPin out; hal::InputPin in; - hal::InputPin inN; Report& report; infra::TimerSingleShot gpioTimeout; infra::TimerSingleShot resetTimer; @@ -135,24 +128,16 @@ class Tester void Tester::ResetStim() { - ready = false; reset.Set(true); resetTimer.Start(std::chrono::milliseconds(3000), [this]() { - assert(booted.Get()); - booted.EnableInterrupt([this]() { - report.State(Report::Condition::Ready); - ready = true; - }, hal::InterruptTrigger::risingEdge); - reset.Set(false); }); + reset.Set(false); + }); } void Tester::Run() { - if (!ready) - return; - if (in.Get()) { report.State(Report::Condition::FailedPrecondition); @@ -178,19 +163,16 @@ void Tester::Timeout() void Tester::Triggered() { gpioTimeout.Cancel(); - if (in.Get() != inN.Get()) - report.State(Report::Condition::Success); - else - report.State(Report::Condition::Failed); + report.State(Report::Condition::Success); } class Command - : public tester::Command + : public testing::Command { public: - Command(services::Echo& echo, Tester& tester, hal::GpioPin& led) - : tester::Command(echo) - , tester(tester) + Command(services::Echo& echo, Tester& testing, hal::GpioPin& led) + : testing::Command(echo) + , testing(testing) , led(led) { } @@ -198,12 +180,12 @@ class Command void RunGpioTest(bool value) override { led.Set(true); - tester.Run(); + testing.Run(); MethodDone(); } private: - Tester& tester; + Tester& testing; hal::OutputPin led; }; @@ -221,12 +203,8 @@ int main() static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); static services::GpioPinInverted nResetStimPinInverted(nResetStimPin); // false: HiZ, true: Low - static hal::GpioPinStm nBootedPin(hal::Port::E, 3, hal::Drive::OpenDrain, hal::Speed::Default, hal::WeakPull::Up); - static services::GpioPinInverted nBootedPinInverted(nBootedPin); - static hal::GpioPinStm outPin(hal::Port::F, 7); static hal::GpioPinStm inPin(hal::Port::F, 8); - static hal::GpioPinStm inNPin(hal::Port::F, 9); // Echo infrastructure static hal::GpioPinStm hostUartTxPin(hal::Port::C, 10); @@ -234,12 +212,12 @@ int main() static hal::DmaStm dma; static hal::UartStmDma hostUart(dma, 4, hostUartTxPin, hostUartRxPin); static main_::EchoOnSerialCommunication<60> echo(hostUart); - static tester::ReponseProxy response(echo); + static testing::ReponseProxy response(echo); // Tester infrastucture static LedReport ledReport(ui.ledRed, ui.ledGreen); static EchoReport echoReport(response); - static Tester tester(nResetStimPinInverted, nBootedPinInverted, outPin, inPin, inNPin, echoReport); + static Tester tester(nResetStimPinInverted, outPin, inPin, echoReport); tester.ResetStim(); static services::DebouncedButton button(ui.buttonOne, []() { tester.Run(); }); @@ -247,6 +225,9 @@ int main() // Event infrastructure static Command command(echo, tester, ui.ledGreen); static services::DebugLed debugLed(ui.ledBlue); + + static main_::EchoBetweenTesterAndTested echoToTested; + eventInfrastructure.Run(); __builtin_unreachable(); } From 121621de2a54cbeeb0c47dea49c8e7926b2c1d29 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Tue, 13 Jun 2023 08:30:58 +0200 Subject: [PATCH 09/21] Extract integration_test/logic/Gpio --- integration_test/logic/CMakeLists.txt | 10 +++- integration_test/logic/Gpio.cpp | 34 ++++++++++++++ integration_test/logic/Gpio.hpp | 29 ++++++++++++ integration_test/tested/Main.cpp | 48 +------------------ integration_test/tester/Main.cpp | 67 +++++++++++++++++++++++---- 5 files changed, 131 insertions(+), 57 deletions(-) create mode 100644 integration_test/logic/Gpio.cpp create mode 100644 integration_test/logic/Gpio.hpp diff --git a/integration_test/logic/CMakeLists.txt b/integration_test/logic/CMakeLists.txt index eb189085..8f05dd23 100644 --- a/integration_test/logic/CMakeLists.txt +++ b/integration_test/logic/CMakeLists.txt @@ -1,9 +1,15 @@ add_library(integration_test.logic ${HALST_EXCLUDE_FROM_ALL}) +target_include_directories(integration_test.logic PUBLIC + "$" +) + protocol_buffer_echo_cpp(integration_test.logic Testing.proto) -#target_sources(integration_test.logic PRIVATE -#) +target_sources(integration_test.logic PRIVATE + Gpio.cpp + Gpio.hpp +) target_link_libraries(integration_test.logic PUBLIC services.util diff --git a/integration_test/logic/Gpio.cpp b/integration_test/logic/Gpio.cpp new file mode 100644 index 00000000..bea90fb5 --- /dev/null +++ b/integration_test/logic/Gpio.cpp @@ -0,0 +1,34 @@ +#include "integration_test/logic/Gpio.hpp" + +namespace application +{ + GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : testing::GpioTested(echo) + , testing::GpioObserverProxy(echo) + , in(inPin) + , out(outPin, false) + { + in.EnableInterrupt([this]() + { + InChanged(); + }, + hal::InterruptTrigger::bothEdges); + } + + void GpioTested::SetGpio(bool state, uint32_t pin) + { + out.Set(state); + } + + void GpioTested::InChanged() + { + if (!sending) + RequestSend([this]() + { + sending = false; + TestedGpioChanged(in.Get(), 0); + }); + + sending = true; + } +} diff --git a/integration_test/logic/Gpio.hpp b/integration_test/logic/Gpio.hpp new file mode 100644 index 00000000..80fa2b67 --- /dev/null +++ b/integration_test/logic/Gpio.hpp @@ -0,0 +1,29 @@ +#ifndef HAL_ST_INTEGRATION_TEST_GPIO_HPP +#define HAL_ST_INTEGRATION_TEST_GPIO_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal/interfaces/Gpio.hpp" + +namespace application +{ + class GpioTested + : public testing::GpioTested + , public testing::GpioObserverProxy + { + public: + GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + + // Implementation of GpioTested + void SetGpio(bool state, uint32_t pin) override; + + private: + void InChanged(); + + private: + hal::InputPin in; + hal::OutputPin out; + bool sending = false; + }; +} + +#endif diff --git a/integration_test/tested/Main.cpp b/integration_test/tested/Main.cpp index fa9c4e8c..13aafaa1 100644 --- a/integration_test/tested/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -2,57 +2,13 @@ #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" +#include "integration_test/logic/Gpio.hpp" #include "integration_test/instantiations_st/EchoOnSesame.hpp" #include "services/util/DebugLed.hpp" #include "services/util/GpioPinInverted.hpp" unsigned int hse_value = 8000000; -class GpioTested - : public testing::GpioTested - , public testing::GpioObserverProxy -{ -public: - GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); - - // Implementation of GpioTested - void SetGpio(bool state, uint32_t pin) override; - -private: - void InChanged(); - -private: - hal::InputPin in; - hal::OutputPin out; - bool sending = false; -}; - -GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) - : testing::GpioTested(echo) - , testing::GpioObserverProxy(echo) - , in(inPin) - , out(outPin, false) -{ - in.EnableInterrupt([this]() { InChanged(); }, hal::InterruptTrigger::bothEdges); -} - -void GpioTested::SetGpio(bool state, uint32_t pin) -{ - out.Set(state); -} - -void GpioTested::InChanged() -{ - if (!sending) - RequestSend([this]() - { - sending = false; - TestedGpioChanged(in.Get(), 0); - }); - - sending = true; -} - int main() { HAL_Init(); @@ -67,7 +23,7 @@ int main() static main_::EchoBetweenTesterAndTested echo; - GpioTested gpioTested(echo.echo, inPin, outPin); + application::GpioTested gpioTested(echo.echo, inPin, outPin); eventInfrastructure.Run(); __builtin_unreachable(); diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 4c23ad57..94d4ae65 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -191,6 +191,55 @@ class Command unsigned int hse_value = 8000000; +class GpioTester + : public testing::GpioTester + , public testing::GpioObserverProxy +{ +public: + GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + + // Implementation of GpioTester + void SetGpio(bool state, uint32_t pin) override; + +private: + void InChanged(); + +private: + hal::InputPin in; + hal::OutputPin out; + bool sending = false; +}; + +GpioTester::GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : testing::GpioTester(echo) + , testing::GpioObserverProxy(echo) + , in(inPin) + , out(outPin, false) +{ + in.EnableInterrupt([this]() + { + InChanged(); + }, + hal::InterruptTrigger::bothEdges); +} + +void GpioTester::SetGpio(bool state, uint32_t pin) +{ + out.Set(state); +} + +void GpioTester::InChanged() +{ + if (!sending) + RequestSend([this]() + { + sending = false; + TestedGpioChanged(in.Get(), 0); + }); + + sending = true; +} + int main() { HAL_Init(); @@ -203,9 +252,6 @@ int main() static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); static services::GpioPinInverted nResetStimPinInverted(nResetStimPin); // false: HiZ, true: Low - static hal::GpioPinStm outPin(hal::Port::F, 7); - static hal::GpioPinStm inPin(hal::Port::F, 8); - // Echo infrastructure static hal::GpioPinStm hostUartTxPin(hal::Port::C, 10); static hal::GpioPinStm hostUartRxPin(hal::Port::C, 11); @@ -217,17 +263,20 @@ int main() // Tester infrastucture static LedReport ledReport(ui.ledRed, ui.ledGreen); static EchoReport echoReport(response); - static Tester tester(nResetStimPinInverted, outPin, inPin, echoReport); - tester.ResetStim(); - static services::DebouncedButton button(ui.buttonOne, []() - { tester.Run(); }); + //static Tester tester(nResetStimPinInverted, outPin, inPin, echoReport); + //tester.ResetStim(); + //static services::DebouncedButton button(ui.buttonOne, []() + // { tester.Run(); }); - // Event infrastructure - static Command command(echo, tester, ui.ledGreen); + //static Command command(echo, tester, ui.ledGreen); static services::DebugLed debugLed(ui.ledBlue); static main_::EchoBetweenTesterAndTested echoToTested; + static hal::GpioPinStm outPin(hal::Port::F, 7); + static hal::GpioPinStm inPin(hal::Port::F, 8); + static GpioTester gpioTester(echo, inPin, outPin); + eventInfrastructure.Run(); __builtin_unreachable(); } From f40193e52f7aa9ea1f7178b9b09d2bcf84d45879 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 15 Jun 2023 13:56:10 +0200 Subject: [PATCH 10/21] Refactor --- .../instantiations_st/EchoOnSesame.hpp | 3 + integration_test/logic/CMakeLists.txt | 6 + integration_test/logic/Gpio.cpp | 31 ++- integration_test/logic/Gpio.hpp | 32 ++- integration_test/logic/Peripheral.cpp | 30 ++ integration_test/logic/Peripheral.hpp | 66 +++++ integration_test/logic/Tested.cpp | 20 ++ integration_test/logic/Tested.hpp | 26 ++ integration_test/logic/Tester.cpp | 33 +++ integration_test/logic/Tester.hpp | 33 +++ integration_test/logic/Testing.proto | 27 +- integration_test/tested/Main.cpp | 38 ++- integration_test/tester/Main.cpp | 262 +++--------------- 13 files changed, 352 insertions(+), 255 deletions(-) create mode 100644 integration_test/logic/Peripheral.cpp create mode 100644 integration_test/logic/Peripheral.hpp create mode 100644 integration_test/logic/Tested.cpp create mode 100644 integration_test/logic/Tested.hpp create mode 100644 integration_test/logic/Tester.cpp create mode 100644 integration_test/logic/Tester.hpp diff --git a/integration_test/instantiations_st/EchoOnSesame.hpp b/integration_test/instantiations_st/EchoOnSesame.hpp index 3e2ca854..b263c78e 100644 --- a/integration_test/instantiations_st/EchoOnSesame.hpp +++ b/integration_test/instantiations_st/EchoOnSesame.hpp @@ -14,6 +14,9 @@ namespace main_ hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; main_::EchoOnSerialCommunication<1024> echo{ echoUart }; }; + + using EchoToTested = EchoBetweenTesterAndTested; + using EchoFromTester = EchoBetweenTesterAndTested; } #endif diff --git a/integration_test/logic/CMakeLists.txt b/integration_test/logic/CMakeLists.txt index 8f05dd23..6cd1c391 100644 --- a/integration_test/logic/CMakeLists.txt +++ b/integration_test/logic/CMakeLists.txt @@ -9,6 +9,12 @@ protocol_buffer_echo_cpp(integration_test.logic Testing.proto) target_sources(integration_test.logic PRIVATE Gpio.cpp Gpio.hpp + Peripheral.cpp + Peripheral.hpp + Tested.cpp + Tested.hpp + Tester.cpp + Tester.hpp ) target_link_libraries(integration_test.logic PUBLIC diff --git a/integration_test/logic/Gpio.cpp b/integration_test/logic/Gpio.cpp index bea90fb5..9beb6247 100644 --- a/integration_test/logic/Gpio.cpp +++ b/integration_test/logic/Gpio.cpp @@ -2,9 +2,8 @@ namespace application { - GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) - : testing::GpioTested(echo) - , testing::GpioObserverProxy(echo) + GpioBase::GpioBase(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : testing::GpioObserverProxy(echo) , in(inPin) , out(outPin, false) { @@ -15,12 +14,12 @@ namespace application hal::InterruptTrigger::bothEdges); } - void GpioTested::SetGpio(bool state, uint32_t pin) + void GpioBase::SetGpio(bool state, uint32_t pin) { out.Set(state); } - void GpioTested::InChanged() + void GpioBase::InChanged() { if (!sending) RequestSend([this]() @@ -31,4 +30,26 @@ namespace application sending = true; } + + GpioTester::GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : GpioBase(echo, inPin, outPin) + , testing::GpioTester(echo) + {} + + void GpioTester::SetGpio(bool state, uint32_t pin) + { + GpioBase::SetGpio(state, pin); + MethodDone(); + } + + GpioTested::GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) + : GpioBase(echo, inPin, outPin) + , testing::GpioTested(echo) + {} + + void GpioTested::SetGpio(bool state, uint32_t pin) + { + GpioBase::SetGpio(state, pin); + MethodDone(); + } } diff --git a/integration_test/logic/Gpio.hpp b/integration_test/logic/Gpio.hpp index 80fa2b67..ab444792 100644 --- a/integration_test/logic/Gpio.hpp +++ b/integration_test/logic/Gpio.hpp @@ -6,15 +6,13 @@ namespace application { - class GpioTested - : public testing::GpioTested - , public testing::GpioObserverProxy + class GpioBase + : public testing::GpioObserverProxy { public: - GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + GpioBase(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); - // Implementation of GpioTested - void SetGpio(bool state, uint32_t pin) override; + void SetGpio(bool state, uint32_t pin); private: void InChanged(); @@ -24,6 +22,28 @@ namespace application hal::OutputPin out; bool sending = false; }; + + class GpioTester + : public GpioBase + , public testing::GpioTester + { + public: + GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + + // Implementation of GpioTester + void SetGpio(bool state, uint32_t pin) override; + }; + + class GpioTested + : public GpioBase + , public testing::GpioTested + { + public: + GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + + // Implementation of GpioTested + void SetGpio(bool state, uint32_t pin) override; + }; } #endif diff --git a/integration_test/logic/Peripheral.cpp b/integration_test/logic/Peripheral.cpp new file mode 100644 index 00000000..070c1578 --- /dev/null +++ b/integration_test/logic/Peripheral.cpp @@ -0,0 +1,30 @@ +#include "integration_test/logic/Peripheral.hpp" + +namespace application +{ + PeripheralBase::PeripheralBase(Peripherals& subject, testing::Peripheral type) + : infra::Observer(subject) + , type(type) + {} + + testing::Peripheral PeripheralBase::Type() const + { + return type; + } + + void Peripherals::EnablePeripheral(testing::Peripheral type) + { + currentPeripheral = nullptr; + + NotifyObservers([this, type](auto& peripheral) + { + if (peripheral.Type() == type) + { + currentPeripheral = peripheral.Construct(); + return true; + } + + return false; + }); + } +} diff --git a/integration_test/logic/Peripheral.hpp b/integration_test/logic/Peripheral.hpp new file mode 100644 index 00000000..83bf2cb7 --- /dev/null +++ b/integration_test/logic/Peripheral.hpp @@ -0,0 +1,66 @@ +#ifndef HAL_ST_INTEGRATION_TEST_PERIPHERAL_HPP +#define HAL_ST_INTEGRATION_TEST_PERIPHERAL_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "infra/util/Observer.hpp" +#include "infra/util/SharedOptional.hpp" + +namespace application +{ + class Peripherals; + + class PeripheralBase + : public infra::Observer + { + public: + PeripheralBase(Peripherals& subject, testing::Peripheral type); + + testing::Peripheral Type() const; + virtual infra::SharedPtr Construct() = 0; + + private: + testing::Peripheral type; + }; + + class Peripherals + : public infra::Subject + { + public: + virtual services::Echo& GetEcho() const = 0; + + void EnablePeripheral(testing::Peripheral type); + + private: + infra::SharedPtr currentPeripheral; + }; + + template + class Perpipheral + : public PeripheralBase + { + public: + Perpipheral(Peripherals& subject); + + infra::SharedPtr Construct() override; + + private: + services::Echo& echo; + infra::SharedOptional constructed; + }; + + //// Implementation //// + + template + Perpipheral::Perpipheral(Peripherals& subject) + : PeripheralBase(subject, testing::Peripheral::gpio_input) + , echo(subject.GetEcho()) + {} + + template + infra::SharedPtr Perpipheral::Construct() + { + return constructed.Emplace(echo); + } +} + +#endif diff --git a/integration_test/logic/Tested.cpp b/integration_test/logic/Tested.cpp new file mode 100644 index 00000000..5ed71657 --- /dev/null +++ b/integration_test/logic/Tested.cpp @@ -0,0 +1,20 @@ +#include "integration_test/logic/Tested.hpp" + +namespace application +{ + Tested::Tested(services::Echo& echo) + : testing::Tested(echo) + {} + + void Tested::EnablePeripheral(testing::Peripheral type) + { + Peripherals::EnablePeripheral(type); + + MethodDone(); + } + + services::Echo& Tested::GetEcho() const + { + return testing::Tested::Subject(); + } +} diff --git a/integration_test/logic/Tested.hpp b/integration_test/logic/Tested.hpp new file mode 100644 index 00000000..8a0de162 --- /dev/null +++ b/integration_test/logic/Tested.hpp @@ -0,0 +1,26 @@ +#ifndef HAL_ST_INTEGRATION_TEST_TESTED_HPP +#define HAL_ST_INTEGRATION_TEST_TESTED_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal/interfaces/Gpio.hpp" +#include "infra/timer/Timer.hpp" +#include "integration_test/logic/Peripheral.hpp" + +namespace application +{ + class Tested + : public testing::Tested + , public Peripherals + { + public: + Tested(services::Echo& echo); + + // Implementation of Tested + void EnablePeripheral(testing::Peripheral type) override; + + // Implementation of Peripherals + services::Echo& GetEcho() const override; + }; +} + +#endif diff --git a/integration_test/logic/Tester.cpp b/integration_test/logic/Tester.cpp new file mode 100644 index 00000000..db3a0ce2 --- /dev/null +++ b/integration_test/logic/Tester.cpp @@ -0,0 +1,33 @@ +#include "integration_test/logic/Tester.hpp" + +namespace application +{ + Tester::Tester(services::Echo& echo, hal::GpioPin& resetTesterPin) + : testing::Tester(echo) + , resetTester(resetTesterPin, true) + {} + + void Tester::Reset() + { + resetTester.Set(false); + + resetTimer.Start(std::chrono::milliseconds(3000), [this]() + { + resetTester.Set(true); + MethodDone(); + }); + } + + void Tester::EnablePeripheral(testing::Peripheral type) + { + Peripherals::EnablePeripheral(type); + + MethodDone(); + + } + + services::Echo& Tester::GetEcho() const + { + return testing::Tester::Subject(); + } +} diff --git a/integration_test/logic/Tester.hpp b/integration_test/logic/Tester.hpp new file mode 100644 index 00000000..eb3494b4 --- /dev/null +++ b/integration_test/logic/Tester.hpp @@ -0,0 +1,33 @@ +#ifndef HAL_ST_INTEGRATION_TEST_TESTER_HPP +#define HAL_ST_INTEGRATION_TEST_TESTER_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal/interfaces/Gpio.hpp" +#include "infra/timer/Timer.hpp" +#include "integration_test/logic/Peripheral.hpp" + +namespace application +{ + class Tester + : public testing::Tester + , public Peripherals + { + public: + Tester(services::Echo& echo, hal::GpioPin& resetTesterPin); + + // Implementation of Tester + void Reset() override; + void EnablePeripheral(testing::Peripheral type) override; + + // Implementation of Peripherals + services::Echo& GetEcho() const override; + + private: + hal::OutputPin resetTester; + infra::TimerSingleShot resetTimer; + + infra::SharedPtr currentPeripheral; + }; +} + +#endif diff --git a/integration_test/logic/Testing.proto b/integration_test/logic/Testing.proto index e9453e90..c5344d69 100644 --- a/integration_test/logic/Testing.proto +++ b/integration_test/logic/Testing.proto @@ -4,33 +4,36 @@ import "EchoAttributes.proto"; package testing; -message GpioOut { - bool value = 1; +message GpioState +{ + bool state = 1; + uint32 pin = 2; } -message GpioIn { - bool value = 1; - bool valueN = 2; +enum Peripheral +{ + gpio_input = 0; + gpio_output = 1; } -message GpioState +message PeripheralType { - bool state = 1; - uint32 pin = 2; + Peripheral peripheral = 1; } -service Command +service Tester { option (service_id) = 1; - rpc RunGpioTest(GpioOut) returns (Nothing) { option (method_id) = 1; } + rpc Reset(Nothing) returns (Nothing) { option (method_id) = 1; } + rpc EnablePeripheral(PeripheralType) returns (Nothing) { option (method_id) = 2; } } -service Reponse +service Tested { option (service_id) = 2; - rpc GpioTestResult(GpioIn) returns (Nothing) { option (method_id) = 1; } + rpc EnablePeripheral(PeripheralType) returns (Nothing) { option (method_id) = 2; } } service GpioTester diff --git a/integration_test/tested/Main.cpp b/integration_test/tested/Main.cpp index 13aafaa1..eb19fbd2 100644 --- a/integration_test/tested/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -3,12 +3,40 @@ #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" #include "integration_test/logic/Gpio.hpp" +#include "integration_test/logic/Tested.hpp" #include "integration_test/instantiations_st/EchoOnSesame.hpp" #include "services/util/DebugLed.hpp" -#include "services/util/GpioPinInverted.hpp" unsigned int hse_value = 8000000; +namespace main_ +{ + struct GpioTested + { + GpioTested(services::Echo& echo); + + hal::GpioPinStm inPin{ hal::Port::F, 7 }; + hal::GpioPinStm outPin{ hal::Port::F, 8 }; + application::GpioTested gpioTested; + }; + + GpioTested::GpioTested(services::Echo& echo) + : gpioTested(echo, inPin, outPin) + {} + + struct Tested + { + Tested(services::Echo& echo); + + application::Tested tested; + application::Perpipheral gpioTested{ tested }; + }; + + Tested::Tested(services::Echo& echo) + : tested(echo) + {} +} + int main() { HAL_Init(); @@ -18,12 +46,8 @@ int main() static main_::Nucleo144Ui ui; static services::DebugLed debugLed(ui.ledBlue); - static hal::GpioPinStm inPin(hal::Port::F, 7); - static hal::GpioPinStm outPin(hal::Port::F, 8); - - static main_::EchoBetweenTesterAndTested echo; - - application::GpioTested gpioTested(echo.echo, inPin, outPin); + static main_::EchoFromTester echo; + static main_::Tested tested(echo.echo); eventInfrastructure.Run(); __builtin_unreachable(); diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 94d4ae65..61e4fc40 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -6,9 +6,9 @@ #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "infra/timer/Timer.hpp" #include "integration_test/instantiations_st/EchoOnSesame.hpp" -#include "services/util/DebouncedButton.hpp" +#include "integration_test/logic/Gpio.hpp" +#include "integration_test/logic/Tester.hpp" #include "services/util/DebugLed.hpp" -#include "services/util/GpioPinInverted.hpp" // Tester Tested Function // ------ ------ -------- @@ -23,221 +23,57 @@ // Connect debug session to GDB, bring up with: // JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile -class Report -{ -public: - enum class Condition - { - Ready, - Success, - Timeout, - FailedPrecondition, - Failed - }; - - virtual void State(Condition condition) = 0; -}; +unsigned int hse_value = 8000000; -class LedReport - : public Report +namespace main_ { -public: - LedReport(hal::GpioPin& redPin, hal::GpioPin& greenPin) - : red(redPin) - , green(greenPin) - {} - - void State(Condition condition) override + struct GpioTester { - red.Set(conditions[static_cast(condition)].red); - green.Set(conditions[static_cast(condition)].green); - } + GpioTester(services::Echo& echo); -private: - hal::OutputPin red; - hal::OutputPin green; - - static constexpr struct - { - bool red; - bool green; - } conditions[5] = { - { true, true }, - { false, true }, - { true, false }, - { true, false }, - { true, false } + hal::GpioPinStm outPin{ hal::Port::F, 7 }; + hal::GpioPinStm inPin{ hal::Port::F, 8 }; + application::GpioTester gpioTester; }; -}; -class EchoReport - : public Report -{ -public: - EchoReport(testing::ReponseProxy& response) - : response(response) + GpioTester::GpioTester(services::Echo& echo) + : gpioTester{ echo, inPin, outPin } {} - void State(Condition condition) override + struct Tester { - response.RequestSend([this, condition]() - { response.GpioTestResult(conditions[static_cast(condition)].value, conditions[static_cast(condition)].valueN); }); - } - -private: - testing::ReponseProxy& response; + Tester(services::Echo& echo); - static constexpr struct - { - bool value; - bool valueN; - } conditions[5] = { - { true, true }, - { false, true }, - { true, false }, - { true, false }, - { true, false } + hal::GpioPinStm nResetTester{ hal::Port::E, 6, hal::Drive::OpenDrain }; + application::Tester tester; + application::Perpipheral gpioTester{ tester }; }; -}; -class Tester -{ -public: - Tester(hal::GpioPin& resetPin, hal::GpioPin& outPin, hal::GpioPin& inPin, Report& report) - : reset(resetPin, false) - , out(outPin, false) - , in(inPin) - , report(report) + Tester::Tester(services::Echo& echo) + : tester(echo, nResetTester) {} - void ResetStim(); - void Run(); - -private: - void Timeout(); - void Triggered(); - -private: - hal::OutputPin reset; - hal::OutputPin out; - hal::InputPin in; - Report& report; - infra::TimerSingleShot gpioTimeout; - infra::TimerSingleShot resetTimer; -}; - -void Tester::ResetStim() -{ - reset.Set(true); - - resetTimer.Start(std::chrono::milliseconds(3000), [this]() - { - reset.Set(false); - }); -} - -void Tester::Run() -{ - if (in.Get()) + struct EchoFromCloud { - report.State(Report::Condition::FailedPrecondition); - return; - } - - const bool expected = true; - const auto expectedEdge = expected ? hal::InterruptTrigger::risingEdge : hal::InterruptTrigger::fallingEdge; - gpioTimeout.Start(std::chrono::seconds(1), [this]() - { Timeout(); }); - in.EnableInterrupt([this]() - { Triggered(); }, - expectedEdge); - out.Set(expected); -} - -void Tester::Timeout() -{ - in.DisableInterrupt(); - report.State(Report::Condition::Timeout); -} - -void Tester::Triggered() -{ - gpioTimeout.Cancel(); - report.State(Report::Condition::Success); -} - -class Command - : public testing::Command -{ -public: - Command(services::Echo& echo, Tester& testing, hal::GpioPin& led) - : testing::Command(echo) - , testing(testing) - , led(led) - { - } + hal::GpioPinStm hostUartTxPin{ hal::Port::C, 10 }; + hal::GpioPinStm hostUartRxPin{ hal::Port::C, 11 }; + hal::DmaStm dma; + hal::UartStmDma hostUart{ dma, 4, hostUartTxPin, hostUartRxPin }; + main_::EchoOnSerialCommunication<60> echo{ hostUart }; + }; - void RunGpioTest(bool value) override + struct ForwardingEchoToTested { - led.Set(true); - testing.Run(); - MethodDone(); - } - -private: - Tester& testing; - hal::OutputPin led; -}; - -unsigned int hse_value = 8000000; - -class GpioTester - : public testing::GpioTester - , public testing::GpioObserverProxy -{ -public: - GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); - - // Implementation of GpioTester - void SetGpio(bool state, uint32_t pin) override; + ForwardingEchoToTested(services::Echo& echo); -private: - void InChanged(); - -private: - hal::InputPin in; - hal::OutputPin out; - bool sending = false; -}; - -GpioTester::GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin) - : testing::GpioTester(echo) - , testing::GpioObserverProxy(echo) - , in(inPin) - , out(outPin, false) -{ - in.EnableInterrupt([this]() - { - InChanged(); - }, - hal::InterruptTrigger::bothEdges); -} - -void GpioTester::SetGpio(bool state, uint32_t pin) -{ - out.Set(state); -} - -void GpioTester::InChanged() -{ - if (!sending) - RequestSend([this]() - { - sending = false; - TestedGpioChanged(in.Get(), 0); - }); + main_::EchoToTested echoToTested; + std::array buffer; + services::ServiceForwarder forwardGpioTested; + }; - sending = true; + ForwardingEchoToTested::ForwardingEchoToTested(services::Echo& echo) + : forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) + {} } int main() @@ -247,35 +83,11 @@ int main() static main_::StmEventInfrastructure eventInfrastructure; static main_::Nucleo144Ui ui; - - // I/O towards Stim - static hal::GpioPinStm nResetStimPin(hal::Port::E, 6, hal::Drive::OpenDrain); - static services::GpioPinInverted nResetStimPinInverted(nResetStimPin); // false: HiZ, true: Low - - // Echo infrastructure - static hal::GpioPinStm hostUartTxPin(hal::Port::C, 10); - static hal::GpioPinStm hostUartRxPin(hal::Port::C, 11); - static hal::DmaStm dma; - static hal::UartStmDma hostUart(dma, 4, hostUartTxPin, hostUartRxPin); - static main_::EchoOnSerialCommunication<60> echo(hostUart); - static testing::ReponseProxy response(echo); - - // Tester infrastucture - static LedReport ledReport(ui.ledRed, ui.ledGreen); - static EchoReport echoReport(response); - //static Tester tester(nResetStimPinInverted, outPin, inPin, echoReport); - //tester.ResetStim(); - //static services::DebouncedButton button(ui.buttonOne, []() - // { tester.Run(); }); - - //static Command command(echo, tester, ui.ledGreen); static services::DebugLed debugLed(ui.ledBlue); - static main_::EchoBetweenTesterAndTested echoToTested; - - static hal::GpioPinStm outPin(hal::Port::F, 7); - static hal::GpioPinStm inPin(hal::Port::F, 8); - static GpioTester gpioTester(echo, inPin, outPin); + static main_::EchoFromCloud echo; + static main_::Tester tester(echo.echo); + static main_::ForwardingEchoToTested forwarder(echo.echo); eventInfrastructure.Run(); __builtin_unreachable(); From 28ef4e4c3f021e60faecf916196f9b0d9f8b511f Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 15 Jun 2023 14:31:52 +0200 Subject: [PATCH 11/21] Fix building for host --- CMakeLists.txt | 2 +- hal_st/cortex/CMakeLists.txt | 3 ++- hal_st/default_init/CMakeLists.txt | 3 ++- hal_st/instantiations/CMakeLists.txt | 3 ++- hal_st/stm32fxxx/CMakeLists.txt | 3 ++- hal_st/synchronous_stm32fxxx/CMakeLists.txt | 3 ++- integration_test/instantiations_st/CMakeLists.txt | 3 ++- st/CMakeLists.txt | 3 ++- 8 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34294a73..91b672e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set_directory_properties(PROPERTY USE_FOLDERS ON) # When building HalSt by itself do not exclude any targets from all # Libraries will only be excluded from all when HalSt is a consumed as a dependency. -if (HALST_STANDALONE AND NOT EMIL_HOST_BUILD) +if (HALST_STANDALONE) set(HALST_EXCLUDE_FROM_ALL "") else() set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL") diff --git a/hal_st/cortex/CMakeLists.txt b/hal_st/cortex/CMakeLists.txt index eb00d7ba..c9ce1bcf 100644 --- a/hal_st/cortex/CMakeLists.txt +++ b/hal_st/cortex/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(hal_st.cortex ${HALST_EXCLUDE_FROM_ALL} STATIC) +add_library(hal_st.cortex STATIC) +emil_build_for(hal_st.cortex TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS hal_st.cortex EXPORT halStTargets) target_include_directories(hal_st.cortex PUBLIC diff --git a/hal_st/default_init/CMakeLists.txt b/hal_st/default_init/CMakeLists.txt index 3613eb52..4e2202c7 100644 --- a/hal_st/default_init/CMakeLists.txt +++ b/hal_st/default_init/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(hal_st.default_init ${HALST_EXCLUDE_FROM_ALL} STATIC) +add_library(hal_st.default_init STATIC) +emil_build_for(hal_st.default_init TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS hal_st.default_init EXPORT halStTargets) target_include_directories(hal_st.default_init PUBLIC diff --git a/hal_st/instantiations/CMakeLists.txt b/hal_st/instantiations/CMakeLists.txt index aa5c27be..ab0d1f9b 100644 --- a/hal_st/instantiations/CMakeLists.txt +++ b/hal_st/instantiations/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(hal_st.instantiations ${HALST_EXCLUDE_FROM_ALL} STATIC) +add_library(hal_st.instantiations STATIC) +emil_build_for(hal_st.instantiations TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS hal_st.instantiations EXPORT halStTargets) target_include_directories(hal_st.instantiations PUBLIC diff --git a/hal_st/stm32fxxx/CMakeLists.txt b/hal_st/stm32fxxx/CMakeLists.txt index 06aa2a7c..1fbf0491 100644 --- a/hal_st/stm32fxxx/CMakeLists.txt +++ b/hal_st/stm32fxxx/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(hal_st.stm32fxxx ${HALST_EXCLUDE_FROM_ALL} STATIC) +add_library(hal_st.stm32fxxx STATIC) +emil_build_for(hal_st.stm32fxxx TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS hal_st.stm32fxxx EXPORT halStTargets) target_include_directories(hal_st.stm32fxxx PUBLIC diff --git a/hal_st/synchronous_stm32fxxx/CMakeLists.txt b/hal_st/synchronous_stm32fxxx/CMakeLists.txt index e574673c..4ec3a800 100644 --- a/hal_st/synchronous_stm32fxxx/CMakeLists.txt +++ b/hal_st/synchronous_stm32fxxx/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(hal_st.synchronous_stm32fxxx ${HALST_EXCLUDE_FROM_ALL} STATIC) +add_library(hal_st.synchronous_stm32fxxx STATIC) +emil_build_for(hal_st.synchronous_stm32fxxx TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS hal_st.synchronous_stm32fxxx EXPORT halStTargets) target_include_directories(hal_st.synchronous_stm32fxxx PUBLIC diff --git a/integration_test/instantiations_st/CMakeLists.txt b/integration_test/instantiations_st/CMakeLists.txt index fd65f120..637a68cb 100644 --- a/integration_test/instantiations_st/CMakeLists.txt +++ b/integration_test/instantiations_st/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(integration_test.instantiations_st ${HALST_EXCLUDE_FROM_ALL}) +add_library(integration_test.instantiations_st) +emil_build_for(integration_test.instantiations_st TARGET_MCU stm32f767) target_sources(integration_test.instantiations_st PRIVATE EchoOnSesame.cpp diff --git a/st/CMakeLists.txt b/st/CMakeLists.txt index 159e300e..012d4916 100644 --- a/st/CMakeLists.txt +++ b/st/CMakeLists.txt @@ -49,7 +49,8 @@ target_compile_definitions(st.hal_driver_stm32wbxx PUBLIC DEVICE_HEADER="stm32wbxx.h" ) -add_library(st.hal_driver ${HALST_EXCLUDE_FROM_ALL} INTERFACE) +add_library(st.hal_driver INTERFACE) +emil_build_for(st.hal_driver TARGET_MCU_VENDOR st PREREQUISITE_BOOL HALST_STANDALONE) install(TARGETS st.hal_driver EXPORT halStTargets) if (TARGET_MCU_VENDOR STREQUAL st) From 655e27098f212d89477b9a2353ef69868c571348 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Fri, 16 Jun 2023 13:15:37 +0200 Subject: [PATCH 12/21] A few small fixes --- CMakePresets.json | 5 +++++ integration_test/instantiations_st/EchoOnSesame.hpp | 4 ++-- integration_test/logic/Gpio.cpp | 5 +++++ integration_test/logic/Gpio.hpp | 1 + integration_test/logic/Peripheral.hpp | 6 +++--- integration_test/logic/Tester.cpp | 1 - integration_test/logic/Testing.proto | 3 +-- integration_test/tested/Main.cpp | 2 +- integration_test/tester/Main.cpp | 10 +++++++--- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index b09b35d7..e5bf495b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -162,6 +162,11 @@ "name": "stm32f767-RelWithDebInfo", "configuration": "RelWithDebInfo", "configurePreset": "stm32f767" + }, + { + "name": "stm32f767-Debug", + "configuration": "Debug", + "configurePreset": "stm32f767" } ] } diff --git a/integration_test/instantiations_st/EchoOnSesame.hpp b/integration_test/instantiations_st/EchoOnSesame.hpp index b263c78e..cd2f8a06 100644 --- a/integration_test/instantiations_st/EchoOnSesame.hpp +++ b/integration_test/instantiations_st/EchoOnSesame.hpp @@ -9,8 +9,8 @@ namespace main_ { struct EchoBetweenTesterAndTested { - hal::GpioPinStm echoUartTx{ hal::Port::D, 2 }; - hal::GpioPinStm echoUartRx{ hal::Port::C, 12 }; + hal::GpioPinStm echoUartTx{ hal::Port::C, 12 }; + hal::GpioPinStm echoUartRx{ hal::Port::D, 2 }; hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; main_::EchoOnSerialCommunication<1024> echo{ echoUart }; }; diff --git a/integration_test/logic/Gpio.cpp b/integration_test/logic/Gpio.cpp index 9beb6247..5648c3b0 100644 --- a/integration_test/logic/Gpio.cpp +++ b/integration_test/logic/Gpio.cpp @@ -14,6 +14,11 @@ namespace application hal::InterruptTrigger::bothEdges); } + GpioBase::~GpioBase() + { + in.DisableInterrupt(); + } + void GpioBase::SetGpio(bool state, uint32_t pin) { out.Set(state); diff --git a/integration_test/logic/Gpio.hpp b/integration_test/logic/Gpio.hpp index ab444792..4c7537ec 100644 --- a/integration_test/logic/Gpio.hpp +++ b/integration_test/logic/Gpio.hpp @@ -11,6 +11,7 @@ namespace application { public: GpioBase(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin); + ~GpioBase(); void SetGpio(bool state, uint32_t pin); diff --git a/integration_test/logic/Peripheral.hpp b/integration_test/logic/Peripheral.hpp index 83bf2cb7..13df7191 100644 --- a/integration_test/logic/Peripheral.hpp +++ b/integration_test/logic/Peripheral.hpp @@ -39,7 +39,7 @@ namespace application : public PeripheralBase { public: - Perpipheral(Peripherals& subject); + Perpipheral(Peripherals& subject, testing::Peripheral type); infra::SharedPtr Construct() override; @@ -51,8 +51,8 @@ namespace application //// Implementation //// template - Perpipheral::Perpipheral(Peripherals& subject) - : PeripheralBase(subject, testing::Peripheral::gpio_input) + Perpipheral::Perpipheral(Peripherals& subject, testing::Peripheral type) + : PeripheralBase(subject, type) , echo(subject.GetEcho()) {} diff --git a/integration_test/logic/Tester.cpp b/integration_test/logic/Tester.cpp index db3a0ce2..40cf7233 100644 --- a/integration_test/logic/Tester.cpp +++ b/integration_test/logic/Tester.cpp @@ -23,7 +23,6 @@ namespace application Peripherals::EnablePeripheral(type); MethodDone(); - } services::Echo& Tester::GetEcho() const diff --git a/integration_test/logic/Testing.proto b/integration_test/logic/Testing.proto index c5344d69..0995d036 100644 --- a/integration_test/logic/Testing.proto +++ b/integration_test/logic/Testing.proto @@ -12,8 +12,7 @@ message GpioState enum Peripheral { - gpio_input = 0; - gpio_output = 1; + gpio = 0; } message PeripheralType diff --git a/integration_test/tested/Main.cpp b/integration_test/tested/Main.cpp index eb19fbd2..7601057b 100644 --- a/integration_test/tested/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -29,7 +29,7 @@ namespace main_ Tested(services::Echo& echo); application::Tested tested; - application::Perpipheral gpioTested{ tested }; + application::Perpipheral gpioTested{ tested, testing::Peripheral::gpio }; }; Tested::Tested(services::Echo& echo) diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index 61e4fc40..bd48cdcb 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -31,8 +31,8 @@ namespace main_ { GpioTester(services::Echo& echo); - hal::GpioPinStm outPin{ hal::Port::F, 7 }; hal::GpioPinStm inPin{ hal::Port::F, 8 }; + hal::GpioPinStm outPin{ hal::Port::F, 7 }; application::GpioTester gpioTester; }; @@ -46,7 +46,7 @@ namespace main_ hal::GpioPinStm nResetTester{ hal::Port::E, 6, hal::Drive::OpenDrain }; application::Tester tester; - application::Perpipheral gpioTester{ tester }; + application::Perpipheral gpioTester{ tester, testing::Peripheral::gpio }; }; Tester::Tester(services::Echo& echo) @@ -68,11 +68,15 @@ namespace main_ main_::EchoToTested echoToTested; std::array buffer; + services::ServiceForwarder forwardTested; services::ServiceForwarder forwardGpioTested; + services::ServiceForwarder forwardGpioObserver; }; ForwardingEchoToTested::ForwardingEchoToTested(services::Echo& echo) - : forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) + : forwardTested(buffer, echo, testing::Tested::serviceId, echoToTested.echo) + , forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) + , forwardGpioObserver(buffer, echoToTested.echo, testing::GpioObserver::serviceId, echo) {} } From cbe6ba8999a41955481372922284af21e2ed7e6d Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Fri, 16 Jun 2023 13:45:15 +0200 Subject: [PATCH 13/21] Extract instantiations from main --- integration_test/CMakeLists.txt | 1 - .../instantiations_st/CMakeLists.txt | 12 ---- .../instantiations_st/EchoOnSesame.cpp | 1 - integration_test/tested/CMakeLists.txt | 6 +- .../EchoFromTester.hpp} | 9 +-- integration_test/tested/Main.cpp | 34 +--------- integration_test/tested/Tested.cpp | 12 ++++ integration_test/tested/Tested.hpp | 29 +++++++++ integration_test/tester/CMakeLists.txt | 8 ++- integration_test/tester/EchoFromCloud.hpp | 19 ++++++ .../tester/ForwardingEchoToTested.cpp | 10 +++ .../tester/ForwardingEchoToTested.hpp | 32 +++++++++ integration_test/tester/Main.cpp | 65 +------------------ integration_test/tester/Tester.cpp | 12 ++++ integration_test/tester/Tester.hpp | 30 +++++++++ 15 files changed, 164 insertions(+), 116 deletions(-) delete mode 100644 integration_test/instantiations_st/CMakeLists.txt delete mode 100644 integration_test/instantiations_st/EchoOnSesame.cpp rename integration_test/{instantiations_st/EchoOnSesame.hpp => tested/EchoFromTester.hpp} (61%) create mode 100644 integration_test/tested/Tested.cpp create mode 100644 integration_test/tested/Tested.hpp create mode 100644 integration_test/tester/EchoFromCloud.hpp create mode 100644 integration_test/tester/ForwardingEchoToTested.cpp create mode 100644 integration_test/tester/ForwardingEchoToTested.hpp create mode 100644 integration_test/tester/Tester.cpp create mode 100644 integration_test/tester/Tester.hpp diff --git a/integration_test/CMakeLists.txt b/integration_test/CMakeLists.txt index a9345e50..bdd05027 100644 --- a/integration_test/CMakeLists.txt +++ b/integration_test/CMakeLists.txt @@ -1,4 +1,3 @@ add_subdirectory(logic) -add_subdirectory(instantiations_st) add_subdirectory(tested) add_subdirectory(tester) diff --git a/integration_test/instantiations_st/CMakeLists.txt b/integration_test/instantiations_st/CMakeLists.txt deleted file mode 100644 index 637a68cb..00000000 --- a/integration_test/instantiations_st/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_library(integration_test.instantiations_st) -emil_build_for(integration_test.instantiations_st TARGET_MCU stm32f767) - -target_sources(integration_test.instantiations_st PRIVATE - EchoOnSesame.cpp - EchoOnSesame.hpp -) - -target_link_libraries(integration_test.instantiations_st PUBLIC - integration_test.logic - hal_st.instantiations -) diff --git a/integration_test/instantiations_st/EchoOnSesame.cpp b/integration_test/instantiations_st/EchoOnSesame.cpp deleted file mode 100644 index 5bf23b1d..00000000 --- a/integration_test/instantiations_st/EchoOnSesame.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "integration_test/instantiations_st/EchoOnSesame.hpp" diff --git a/integration_test/tested/CMakeLists.txt b/integration_test/tested/CMakeLists.txt index 57167012..701f3dfb 100644 --- a/integration_test/tested/CMakeLists.txt +++ b/integration_test/tested/CMakeLists.txt @@ -2,11 +2,15 @@ add_executable(integration_test.tested) emil_build_for(integration_test.tested TARGET_MCU stm32f767) target_sources(integration_test.tested PRIVATE + EchoFromTester.hpp Main.cpp + Tested.cpp + Tested.hpp ) target_link_libraries(integration_test.tested PRIVATE - integration_test.instantiations_st + integration_test.logic + hal_st.instantiations ) halst_target_default_linker_scripts(integration_test.tested) diff --git a/integration_test/instantiations_st/EchoOnSesame.hpp b/integration_test/tested/EchoFromTester.hpp similarity index 61% rename from integration_test/instantiations_st/EchoOnSesame.hpp rename to integration_test/tested/EchoFromTester.hpp index cd2f8a06..eabad8ea 100644 --- a/integration_test/instantiations_st/EchoOnSesame.hpp +++ b/integration_test/tested/EchoFromTester.hpp @@ -1,5 +1,5 @@ -#ifndef HAL_ST_INTEGRATION_TEST_ECHO_ON_SESAME_HPP -#define HAL_ST_INTEGRATION_TEST_ECHO_ON_SESAME_HPP +#ifndef HAL_ST_INTEGRATION_TEST_ECHO_FROM_TESTER_HPP +#define HAL_ST_INTEGRATION_TEST_ECHO_FROM_TESTER_HPP #include "hal_st/stm32fxxx/GpioStm.hpp" #include "hal_st/stm32fxxx/UartStm.hpp" @@ -7,16 +7,13 @@ namespace main_ { - struct EchoBetweenTesterAndTested + struct EchoFromTester { hal::GpioPinStm echoUartTx{ hal::Port::C, 12 }; hal::GpioPinStm echoUartRx{ hal::Port::D, 2 }; hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; main_::EchoOnSerialCommunication<1024> echo{ echoUart }; }; - - using EchoToTested = EchoBetweenTesterAndTested; - using EchoFromTester = EchoBetweenTesterAndTested; } #endif diff --git a/integration_test/tested/Main.cpp b/integration_test/tested/Main.cpp index 7601057b..a838d82a 100644 --- a/integration_test/tested/Main.cpp +++ b/integration_test/tested/Main.cpp @@ -1,42 +1,12 @@ -#include "generated/echo/Testing.pb.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" -#include "integration_test/logic/Gpio.hpp" -#include "integration_test/logic/Tested.hpp" -#include "integration_test/instantiations_st/EchoOnSesame.hpp" +#include "integration_test/tested/EchoFromTester.hpp" +#include "integration_test/tested/Tested.hpp" #include "services/util/DebugLed.hpp" unsigned int hse_value = 8000000; -namespace main_ -{ - struct GpioTested - { - GpioTested(services::Echo& echo); - - hal::GpioPinStm inPin{ hal::Port::F, 7 }; - hal::GpioPinStm outPin{ hal::Port::F, 8 }; - application::GpioTested gpioTested; - }; - - GpioTested::GpioTested(services::Echo& echo) - : gpioTested(echo, inPin, outPin) - {} - - struct Tested - { - Tested(services::Echo& echo); - - application::Tested tested; - application::Perpipheral gpioTested{ tested, testing::Peripheral::gpio }; - }; - - Tested::Tested(services::Echo& echo) - : tested(echo) - {} -} - int main() { HAL_Init(); diff --git a/integration_test/tested/Tested.cpp b/integration_test/tested/Tested.cpp new file mode 100644 index 00000000..f0dccc4c --- /dev/null +++ b/integration_test/tested/Tested.cpp @@ -0,0 +1,12 @@ +#include "integration_test/tested/Tested.hpp" + +namespace main_ +{ + GpioTested::GpioTested(services::Echo& echo) + : gpioTested(echo, inPin, outPin) + {} + + Tested::Tested(services::Echo& echo) + : tested(echo) + {} +} diff --git a/integration_test/tested/Tested.hpp b/integration_test/tested/Tested.hpp new file mode 100644 index 00000000..238c7147 --- /dev/null +++ b/integration_test/tested/Tested.hpp @@ -0,0 +1,29 @@ +#ifndef HAL_ST_INTEGRATION_TEST_TESTED_TESTED_HPP +#define HAL_ST_INTEGRATION_TEST_TESTED_TESTED_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal_st/stm32fxxx/GpioStm.hpp" +#include "integration_test/logic/Gpio.hpp" +#include "integration_test/logic/Tested.hpp" + +namespace main_ +{ + struct GpioTested + { + GpioTested(services::Echo& echo); + + hal::GpioPinStm inPin{ hal::Port::F, 7 }; + hal::GpioPinStm outPin{ hal::Port::F, 8 }; + application::GpioTested gpioTested; + }; + + struct Tested + { + Tested(services::Echo& echo); + + application::Tested tested; + application::Perpipheral gpioTested{ tested, testing::Peripheral::gpio }; + }; +} + +#endif diff --git a/integration_test/tester/CMakeLists.txt b/integration_test/tester/CMakeLists.txt index f688673e..1e069942 100644 --- a/integration_test/tester/CMakeLists.txt +++ b/integration_test/tester/CMakeLists.txt @@ -3,10 +3,16 @@ emil_build_for(integration_test.tester TARGET_MCU stm32f767) target_sources(integration_test.tester PRIVATE Main.cpp + EchoFromCloud.hpp + ForwardingEchoToTested.cpp + ForwardingEchoToTested.hpp + Tester.cpp + Tester.hpp ) target_link_libraries(integration_test.tester PRIVATE - integration_test.instantiations_st + integration_test.logic + hal_st.instantiations ) halst_target_default_linker_scripts(integration_test.tester) diff --git a/integration_test/tester/EchoFromCloud.hpp b/integration_test/tester/EchoFromCloud.hpp new file mode 100644 index 00000000..f956a59e --- /dev/null +++ b/integration_test/tester/EchoFromCloud.hpp @@ -0,0 +1,19 @@ +#ifndef HAL_ST_INTEGRATION_TEST_ECHO_FROM_CLOUD_HPP +#define HAL_ST_INTEGRATION_TEST_ECHO_FROM_CLOUD_HPP + +#include "hal_st/stm32fxxx/UartStmDma.hpp" +#include "services/util/EchoInstantiation.hpp" + +namespace main_ +{ + struct EchoFromCloud + { + hal::GpioPinStm hostUartTxPin{ hal::Port::C, 10 }; + hal::GpioPinStm hostUartRxPin{ hal::Port::C, 11 }; + hal::DmaStm dma; + hal::UartStmDma hostUart{ dma, 4, hostUartTxPin, hostUartRxPin }; + main_::EchoOnSerialCommunication<60> echo{ hostUart }; + }; +} + +#endif diff --git a/integration_test/tester/ForwardingEchoToTested.cpp b/integration_test/tester/ForwardingEchoToTested.cpp new file mode 100644 index 00000000..c2c74a84 --- /dev/null +++ b/integration_test/tester/ForwardingEchoToTested.cpp @@ -0,0 +1,10 @@ +#include "integration_test/tester/ForwardingEchoToTested.hpp" + +namespace main_ +{ + ForwardingEchoToTested::ForwardingEchoToTested(services::Echo& echo) + : forwardTested(buffer, echo, testing::Tested::serviceId, echoToTested.echo) + , forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) + , forwardGpioObserver(buffer, echoToTested.echo, testing::GpioObserver::serviceId, echo) + {} +} diff --git a/integration_test/tester/ForwardingEchoToTested.hpp b/integration_test/tester/ForwardingEchoToTested.hpp new file mode 100644 index 00000000..1853a427 --- /dev/null +++ b/integration_test/tester/ForwardingEchoToTested.hpp @@ -0,0 +1,32 @@ +#ifndef HAL_ST_INTEGRATION_TEST_FORWARDING_ECHO_TO_TESTED_HPP +#define HAL_ST_INTEGRATION_TEST_FORWARDING_ECHO_TO_TESTED_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal_st/stm32fxxx/GpioStm.hpp" +#include "hal_st/stm32fxxx/UartStm.hpp" +#include "protobuf/echo/ServiceForwarder.hpp" +#include "services/util/EchoInstantiation.hpp" + +namespace main_ +{ + struct EchoToTested + { + hal::GpioPinStm echoUartTx{ hal::Port::C, 12 }; + hal::GpioPinStm echoUartRx{ hal::Port::D, 2 }; + hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; + main_::EchoOnSerialCommunication<1024> echo{ echoUart }; + }; + + struct ForwardingEchoToTested + { + ForwardingEchoToTested(services::Echo& echo); + + main_::EchoToTested echoToTested; + std::array buffer; + services::ServiceForwarder forwardTested; + services::ServiceForwarder forwardGpioTested; + services::ServiceForwarder forwardGpioObserver; + }; +} + +#endif diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index bd48cdcb..f31977e9 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -1,13 +1,9 @@ -#include "generated/echo/Testing.pb.hpp" #include "hal_st/instantiations/NucleoUi.hpp" #include "hal_st/instantiations/StmEventInfrastructure.hpp" #include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp" -#include "hal_st/stm32fxxx/DmaStm.hpp" -#include "hal_st/stm32fxxx/UartStmDma.hpp" -#include "infra/timer/Timer.hpp" -#include "integration_test/instantiations_st/EchoOnSesame.hpp" -#include "integration_test/logic/Gpio.hpp" -#include "integration_test/logic/Tester.hpp" +#include "integration_test/tester/EchoFromCloud.hpp" +#include "integration_test/tester/ForwardingEchoToTested.hpp" +#include "integration_test/tester/Tester.hpp" #include "services/util/DebugLed.hpp" // Tester Tested Function @@ -25,61 +21,6 @@ unsigned int hse_value = 8000000; -namespace main_ -{ - struct GpioTester - { - GpioTester(services::Echo& echo); - - hal::GpioPinStm inPin{ hal::Port::F, 8 }; - hal::GpioPinStm outPin{ hal::Port::F, 7 }; - application::GpioTester gpioTester; - }; - - GpioTester::GpioTester(services::Echo& echo) - : gpioTester{ echo, inPin, outPin } - {} - - struct Tester - { - Tester(services::Echo& echo); - - hal::GpioPinStm nResetTester{ hal::Port::E, 6, hal::Drive::OpenDrain }; - application::Tester tester; - application::Perpipheral gpioTester{ tester, testing::Peripheral::gpio }; - }; - - Tester::Tester(services::Echo& echo) - : tester(echo, nResetTester) - {} - - struct EchoFromCloud - { - hal::GpioPinStm hostUartTxPin{ hal::Port::C, 10 }; - hal::GpioPinStm hostUartRxPin{ hal::Port::C, 11 }; - hal::DmaStm dma; - hal::UartStmDma hostUart{ dma, 4, hostUartTxPin, hostUartRxPin }; - main_::EchoOnSerialCommunication<60> echo{ hostUart }; - }; - - struct ForwardingEchoToTested - { - ForwardingEchoToTested(services::Echo& echo); - - main_::EchoToTested echoToTested; - std::array buffer; - services::ServiceForwarder forwardTested; - services::ServiceForwarder forwardGpioTested; - services::ServiceForwarder forwardGpioObserver; - }; - - ForwardingEchoToTested::ForwardingEchoToTested(services::Echo& echo) - : forwardTested(buffer, echo, testing::Tested::serviceId, echoToTested.echo) - , forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) - , forwardGpioObserver(buffer, echoToTested.echo, testing::GpioObserver::serviceId, echo) - {} -} - int main() { HAL_Init(); diff --git a/integration_test/tester/Tester.cpp b/integration_test/tester/Tester.cpp new file mode 100644 index 00000000..debc4250 --- /dev/null +++ b/integration_test/tester/Tester.cpp @@ -0,0 +1,12 @@ +#include "integration_test/tester/Tester.hpp" + +namespace main_ +{ + GpioTester::GpioTester(services::Echo& echo) + : gpioTester{ echo, inPin, outPin } + {} + + Tester::Tester(services::Echo& echo) + : tester(echo, nResetTester) + {} +} diff --git a/integration_test/tester/Tester.hpp b/integration_test/tester/Tester.hpp new file mode 100644 index 00000000..e62ffbce --- /dev/null +++ b/integration_test/tester/Tester.hpp @@ -0,0 +1,30 @@ +#ifndef HAL_ST_INTEGRATION_TEST_TESTER_TESTER_HPP +#define HAL_ST_INTEGRATION_TEST_TESTER_TESTER_HPP + +#include "generated/echo/Testing.pb.hpp" +#include "hal_st/stm32fxxx/GpioStm.hpp" +#include "integration_test/logic/Gpio.hpp" +#include "integration_test/logic/Tester.hpp" + +namespace main_ +{ + struct GpioTester + { + GpioTester(services::Echo& echo); + + hal::GpioPinStm inPin{ hal::Port::F, 8 }; + hal::GpioPinStm outPin{ hal::Port::F, 7 }; + application::GpioTester gpioTester; + }; + + struct Tester + { + Tester(services::Echo& echo); + + hal::GpioPinStm nResetTester{ hal::Port::E, 6, hal::Drive::OpenDrain }; + application::Tester tester; + application::Perpipheral gpioTester{ tester, testing::Peripheral::gpio }; + }; +} + +#endif From c7e1f7358733940cd9f601e9d8ba6f1e76836f6f Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Sun, 29 Oct 2023 08:21:58 +0100 Subject: [PATCH 14/21] Update EmbeddedInfraLib --- .gitignore | 1 + CMakeLists.txt | 2 +- CMakePresets.json | 4 ++-- integration_test/tested/EchoFromTester.hpp | 4 +++- integration_test/tester/EchoFromCloud.hpp | 4 +++- integration_test/tester/ForwardingEchoToTested.cpp | 6 +++--- integration_test/tester/ForwardingEchoToTested.hpp | 4 ++-- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 65212e5e..a8c25b94 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build/ out/ megalinter-reports/ +install/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7430b923..bce7a3d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if (HALST_STANDALONE) FetchContent_Declare( emil GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git - GIT_TAG 2f5b81492e511ebe441b9811ef08cf3c96c3a058 # Unreleased + GIT_TAG b929074c01be1eea57044ef327c10e30cc3beff9 # Unreleased ) FetchContent_MakeAvailable(emil) diff --git a/CMakePresets.json b/CMakePresets.json index 6bdff237..fd763188 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,7 +15,8 @@ "displayName": "Configuration for Host Tooling and Tests", "inherits": "defaults", "cacheVariables": { - "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel" + "CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel", + "EMIL_BUILD_ECHO_COMPILERS": true }, "generator": "Ninja Multi-Config" }, @@ -44,7 +45,6 @@ "CMAKE_TOOLCHAIN_FILE": "" }, "cacheVariables": { - "EMIL_GENERATE_PACKAGE_CONFIG": false, "TARGET_MCU_VENDOR": "st" } }, diff --git a/integration_test/tested/EchoFromTester.hpp b/integration_test/tested/EchoFromTester.hpp index eabad8ea..e46f70b5 100644 --- a/integration_test/tested/EchoFromTester.hpp +++ b/integration_test/tested/EchoFromTester.hpp @@ -1,6 +1,7 @@ #ifndef HAL_ST_INTEGRATION_TEST_ECHO_FROM_TESTER_HPP #define HAL_ST_INTEGRATION_TEST_ECHO_FROM_TESTER_HPP +#include "generated/echo/Testing.pb.hpp" #include "hal_st/stm32fxxx/GpioStm.hpp" #include "hal_st/stm32fxxx/UartStm.hpp" #include "services/util/EchoInstantiation.hpp" @@ -12,7 +13,8 @@ namespace main_ hal::GpioPinStm echoUartTx{ hal::Port::C, 12 }; hal::GpioPinStm echoUartRx{ hal::Port::D, 2 }; hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; - main_::EchoOnSerialCommunication<1024> echo{ echoUart }; + services::MethodSerializerFactory ::ForServices::AndProxies serializerFactory; + main_::EchoOnSerialCommunication<256> echo{ echoUart, serializerFactory }; }; } diff --git a/integration_test/tester/EchoFromCloud.hpp b/integration_test/tester/EchoFromCloud.hpp index f956a59e..24f786ea 100644 --- a/integration_test/tester/EchoFromCloud.hpp +++ b/integration_test/tester/EchoFromCloud.hpp @@ -1,6 +1,7 @@ #ifndef HAL_ST_INTEGRATION_TEST_ECHO_FROM_CLOUD_HPP #define HAL_ST_INTEGRATION_TEST_ECHO_FROM_CLOUD_HPP +#include "generated/echo/Testing.pb.hpp" #include "hal_st/stm32fxxx/UartStmDma.hpp" #include "services/util/EchoInstantiation.hpp" @@ -12,7 +13,8 @@ namespace main_ hal::GpioPinStm hostUartRxPin{ hal::Port::C, 11 }; hal::DmaStm dma; hal::UartStmDma hostUart{ dma, 4, hostUartTxPin, hostUartRxPin }; - main_::EchoOnSerialCommunication<60> echo{ hostUart }; + services::MethodSerializerFactory ::ForServices::AndProxies serializerFactory; + main_::EchoOnSerialCommunication<256> echo{ hostUart, serializerFactory }; }; } diff --git a/integration_test/tester/ForwardingEchoToTested.cpp b/integration_test/tester/ForwardingEchoToTested.cpp index c2c74a84..6de80c07 100644 --- a/integration_test/tester/ForwardingEchoToTested.cpp +++ b/integration_test/tester/ForwardingEchoToTested.cpp @@ -3,8 +3,8 @@ namespace main_ { ForwardingEchoToTested::ForwardingEchoToTested(services::Echo& echo) - : forwardTested(buffer, echo, testing::Tested::serviceId, echoToTested.echo) - , forwardGpioTested(buffer, echo, testing::GpioTested::serviceId, echoToTested.echo) - , forwardGpioObserver(buffer, echoToTested.echo, testing::GpioObserver::serviceId, echo) + : forwardTested(echo, testing::Tested::serviceId, echoToTested.echo) + , forwardGpioTested(echo, testing::GpioTested::serviceId, echoToTested.echo) + , forwardGpioObserver(echoToTested.echo, testing::GpioObserver::serviceId, echo) {} } diff --git a/integration_test/tester/ForwardingEchoToTested.hpp b/integration_test/tester/ForwardingEchoToTested.hpp index 1853a427..17c8c79f 100644 --- a/integration_test/tester/ForwardingEchoToTested.hpp +++ b/integration_test/tester/ForwardingEchoToTested.hpp @@ -14,7 +14,8 @@ namespace main_ hal::GpioPinStm echoUartTx{ hal::Port::C, 12 }; hal::GpioPinStm echoUartRx{ hal::Port::D, 2 }; hal::UartStm echoUart{ 5, echoUartTx, echoUartRx }; - main_::EchoOnSerialCommunication<1024> echo{ echoUart }; + services::MethodSerializerFactory ::ForServices::AndProxies serializerFactory; + main_::EchoOnSerialCommunication<256> echo{ echoUart, serializerFactory }; }; struct ForwardingEchoToTested @@ -22,7 +23,6 @@ namespace main_ ForwardingEchoToTested(services::Echo& echo); main_::EchoToTested echoToTested; - std::array buffer; services::ServiceForwarder forwardTested; services::ServiceForwarder forwardGpioTested; services::ServiceForwarder forwardGpioObserver; From 03599eeb63fb12e6ed09a959a07ef7ebf60b5d49 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 12:58:47 +0100 Subject: [PATCH 15/21] Create install package in host build, pass on to embedded build --- .github/workflows/ci.yml | 18 ++++++++++++------ CMakeLists.txt | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f344d755..78b7559e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,14 +26,14 @@ jobs: - uses: lukka/run-cmake@c2b72aff009141774c5a5fabe74ea46c8c04d9c4 # v10.6 with: configurePreset: "host" - buildPreset: "host-Debug" #-WithPackage" + buildPreset: "host-Debug-WithPackage" #testPreset: "host" configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']" - #- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - # with: - # name: halst - # path: build/host/halst-*-Linux.tar.gz - # if-no-files-found: error + - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 + with: + name: halst + path: build/host/halst-*-Linux.tar.gz + if-no-files-found: error #- name: Upload test logs # if: ${{ failure() }} # uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 @@ -69,6 +69,7 @@ jobs: embedded_build: name: Embedded Build runs-on: ubuntu-latest + needs: [host_build_test_ubuntu] strategy: matrix: configuration: ["RelWithDebInfo"] @@ -93,6 +94,11 @@ jobs: - uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9 with: key: ${{ matrix.gcc }}-${{ matrix.configuration }}-${{ matrix.target }} + - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 + with: + name: halst + - run: tar -zxvf halst-*.tar.gz + - run: mkdir install && mv halst-*/* install/ - run: | sudo apt-get update && sudo apt-get install --no-install-recommends ninja-build xsltproc echo "::add-matcher::.github/matchers/gcc-problem-matcher.json" diff --git a/CMakeLists.txt b/CMakeLists.txt index bce7a3d4..548e598e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if (HALST_STANDALONE) FetchContent_Declare( emil GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git - GIT_TAG b929074c01be1eea57044ef327c10e30cc3beff9 # Unreleased + GIT_TAG 81625ecd1589cefbd437febe8e4dc2518a91f237 # Unreleased ) FetchContent_MakeAvailable(emil) @@ -52,3 +52,19 @@ emil_clangformat_directories(hal_st DIRECTORIES .) if (HALST_STANDALONE) emil_folderize_all_targets() endif() + +set(CPACK_GENERATOR "ZIP;TGZ") +set(CPACK_SOURCE_IGNORE_FILES ".vs/;.git/;build/") +set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") +set(CPACK_PACKAGE_VENDOR "Koninklijke Philips N.V") +set(CPACK_PACKAGE_DESCRIPTION "${PROJECT_DESCRIPTION}") +set(CPACK_DEBIAN_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") +set(CPACK_RPM_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") +set(CPACK_PACKAGE_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}") +set(CPACK_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}") +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") + +include(CPack) From 31d4f72f69c608773bb2210decdb6b62af7ae851 Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 13:00:27 +0100 Subject: [PATCH 16/21] Fix artifact name --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78b7559e..17147e2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']" - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: - name: halst - path: build/host/halst-*-Linux.tar.gz + name: hal_st + path: build/host/hal_st-*-Linux.tar.gz if-no-files-found: error #- name: Upload test logs # if: ${{ failure() }} @@ -96,9 +96,9 @@ jobs: key: ${{ matrix.gcc }}-${{ matrix.configuration }}-${{ matrix.target }} - uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 with: - name: halst - - run: tar -zxvf halst-*.tar.gz - - run: mkdir install && mv halst-*/* install/ + name: hal_st + - run: tar -zxvf hal_st-*.tar.gz + - run: mkdir install && mv hal_st-*/* install/ - run: | sudo apt-get update && sudo apt-get install --no-install-recommends ninja-build xsltproc echo "::add-matcher::.github/matchers/gcc-problem-matcher.json" From bd652b649267c62cc1c753728c291daefe61749b Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 13:23:20 +0100 Subject: [PATCH 17/21] Apply clang-format --- examples/freertos/Main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/freertos/Main.cpp b/examples/freertos/Main.cpp index d6e606c1..ea724527 100644 --- a/examples/freertos/Main.cpp +++ b/examples/freertos/Main.cpp @@ -59,7 +59,8 @@ int main() pin.Set(true); std::this_thread::sleep_for(200ms); pin.Set(false); - } }); + } + }); static std::thread t2([]() { @@ -70,7 +71,8 @@ int main() pin.Set(!pin.GetOutputLatch()); }); - eventDispatcher.Run(); }); + eventDispatcher.Run(); + }); osal::Run(); __builtin_unreachable(); From f5fe87ea6d0854bb1ff4b7b328a9bfff6d973f8f Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 13:23:55 +0100 Subject: [PATCH 18/21] .github/workflows/ci.yml: remove superfluous host build --- .github/workflows/ci.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17147e2a..bb134e30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,6 +91,7 @@ jobs: uses: carlosperate/arm-none-eabi-gcc-action@6a221d7c85f5b36647d6e9b25e874abf187409d3 # v1.7.1 with: release: ${{ matrix.gcc }} + - run: sudo apt-get update && sudo apt-get install ninja-build - uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e # v1.2.9 with: key: ${{ matrix.gcc }}-${{ matrix.configuration }}-${{ matrix.target }} @@ -99,10 +100,8 @@ jobs: name: hal_st - run: tar -zxvf hal_st-*.tar.gz - run: mkdir install && mv hal_st-*/* install/ - - run: | - sudo apt-get update && sudo apt-get install --no-install-recommends ninja-build xsltproc - echo "::add-matcher::.github/matchers/gcc-problem-matcher.json" - cmake --preset host -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build --preset host-${{ matrix.configuration }} - cmake --preset ${{ matrix.target }} -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build --preset ${{ matrix.target }}-${{ matrix.configuration }} + - uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # v10.7 + with: + configurePreset: ${{ matrix.target }} + buildPreset: ${{ matrix.target }}-${{ matrix.configuration }} + configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=ccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=ccache']" From 27f883880bd89d89890711bca4d39d4ec3d0e4bd Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 13:45:37 +0100 Subject: [PATCH 19/21] .github/workflows/ci.yml: install xsltproc --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0e008d5..ea3ee8a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: uses: carlosperate/arm-none-eabi-gcc-action@e9cd61b92edb079b14b2d0449b21f8a517121fe8 # v1.8.0 with: release: ${{ matrix.gcc }} - - run: sudo apt-get update && sudo apt-get install ninja-build + - run: sudo apt-get update && sudo apt-get install ninja-build xsltproc - uses: hendrikmuhs/ccache-action@6d1841ec156c39a52b1b23a810da917ab98da1f4 # v1.2.10 with: key: ${{ matrix.gcc }}-${{ matrix.configuration }}-${{ matrix.target }} From 871eb8c222588198e45c1b6b97dad3adea870d4b Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 14:44:59 +0100 Subject: [PATCH 20/21] integration_test/tester/Main: Update names of Tester/Tested --- integration_test/tester/Main.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/integration_test/tester/Main.cpp b/integration_test/tester/Main.cpp index f31977e9..cbfe440f 100644 --- a/integration_test/tester/Main.cpp +++ b/integration_test/tester/Main.cpp @@ -8,17 +8,14 @@ // Tester Tested Function // ------ ------ -------- -// CN8-9 -> CN8-9 E5V (NOTE: set JP3 on the Stim to E5V) +// CN8-9 -> CN8-9 E5V (NOTE: set JP3 on both the Tester and Tested to E5V) // CN8-11 -- CN8-11 ground // CN8-10 <- CN8-12 ECHO on SESAME // CN8-12 -> CN8-10 ECHO on SESAME -// CN9-20 -> CN8-5 nRst of Stim +// CN9-20 -> CN8-5 nRst of Tested // CN9-24 <- CN9-24 GPIO set by Tester // CN9-26 -> CN9-26 Tester GPIO control -// Connect debug session to GDB, bring up with: -// JLinkGDBServer -select USB -device STM32F767ZI -endian little -if JTAG -speed auto -noir -LocalhostOnly -nologtofile - unsigned int hse_value = 8000000; int main() From 18c618b47d59a673efc8c8ff73ff6d1b13c85e0e Mon Sep 17 00:00:00 2001 From: Richard Peters Date: Thu, 9 Nov 2023 14:46:42 +0100 Subject: [PATCH 21/21] Update amp-embedded-infra-lib to v5.0.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 548e598e..8a50cc12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if (HALST_STANDALONE) FetchContent_Declare( emil GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git - GIT_TAG 81625ecd1589cefbd437febe8e4dc2518a91f237 # Unreleased + GIT_TAG 2ddda404d8822d9cdeb817629e036647a8a3a136 # v5.0.0 ) FetchContent_MakeAvailable(emil)