Skip to content

Commit

Permalink
Merge branch 'main' into multichannel-adc
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiangottstein committed Sep 2, 2024
2 parents d84d60e + 75ece18 commit d416157
Show file tree
Hide file tree
Showing 44 changed files with 4,604 additions and 78 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, windows-2019, macos-latest]
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
Expand Down Expand Up @@ -73,12 +73,21 @@ jobs:
strategy:
matrix:
configuration: ["RelWithDebInfo"]
gcc: [ "10.3-2021.10" ]
target: ["stm32wb55", "stm32g070", "stm32g431", "stm32f407", "stm32f429", "stm32f746", "stm32f767", "stm32wba52", "stm32h563", "stm32h573"]
gcc: ["10.3-2021.10"]
target:
[
"stm32wb55",
"stm32wba52",
"stm32g070",
"stm32g431",
"stm32f407",
"stm32f429",
"stm32f746",
"stm32f767",
"stm32h563",
"stm32h573"
]
include:
- gcc: "7-2018-q2"
configuration: "RelWithDebInfo"
target: "stm32f767"
- gcc: "8-2019-q3"
configuration: "RelWithDebInfo"
target: "stm32f767"
Expand All @@ -87,6 +96,8 @@ jobs:
target: "stm32f767"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- name: Install GNU Arm Embedded Toolchain ${{ matrix.gcc }}
uses: carlosperate/arm-none-eabi-gcc-action@0cc83a7330501be1848887e2966aaceb49a4bb12 # v1.9.1
with:
Expand Down
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif()

project(hal_st LANGUAGES C CXX ASM VERSION 3.0.0) # x-release-please-version

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED On)

set_directory_properties(PROPERTY USE_FOLDERS ON)
Expand All @@ -40,10 +40,25 @@ else()
set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
endif()

if (EMIL_HOST_BUILD)
include(FetchContent)

FetchContent_Declare(
cucumber-cpp-runner
GIT_REPOSITORY https://github.com/philips-software/amp-cucumber-cpp-runner.git
GIT_TAG f3ef05b18363c2199e0978341b96cb2443a2b8f5 # unreleased
)

FetchContent_MakeAvailable(cucumber-cpp-runner)

endif()

add_subdirectory(st)
add_subdirectory(hal_st)
add_subdirectory(hal_st_lwip)
add_subdirectory(integration_test)
if (HALST_STANDALONE)
add_subdirectory(integration_test)
endif()
add_subdirectory(services)
add_subdirectory(examples)

Expand Down
11 changes: 5 additions & 6 deletions hal_st/stm32fxxx/DefaultClockNucleoF767ZI.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include DEVICE_HEADER
#include "hal_st/stm32fxxx/DefaultClockNucleoF767ZI.hpp"


/* The system Clock is configured as follows:
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 216000000
Expand Down Expand Up @@ -32,11 +31,11 @@ void ConfigureDefaultClockNucleo767ZI()
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 4; // Divides the 8MHz HSI to 2MHz
RCC_OscInitStruct.PLL.PLLN = 216; // Multiplies the 2MHz to 432MHz
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // Divides the 432MHz to 216MHz for SYSCLK
RCC_OscInitStruct.PLL.PLLQ = 9; // Divides the 432MHz to 48MHz for USB and SDMMC and RNG
RCC_OscInitStruct.PLL.PLLR = 7; // Divides the 432MHz to 62MHz for DSI (No clue what a good frequency would be here...)
RCC_OscInitStruct.PLL.PLLM = 4; // Divides the 8MHz HSI to 2MHz
RCC_OscInitStruct.PLL.PLLN = 216; // Multiplies the 2MHz to 432MHz
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // Divides the 432MHz to 216MHz for SYSCLK
RCC_OscInitStruct.PLL.PLLQ = 9; // Divides the 432MHz to 48MHz for USB and SDMMC and RNG
RCC_OscInitStruct.PLL.PLLR = 7; // Divides the 432MHz to 62MHz for DSI (No clue what a good frequency would be here...)
HAL_RCC_OscConfig(&RCC_OscInitStruct);

HAL_PWREx_EnableOverDrive();
Expand Down
1 change: 1 addition & 0 deletions integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(logic)
add_subdirectory(tested)
add_subdirectory(tester)
add_subdirectory(runner)
2 changes: 2 additions & 0 deletions integration_test/logic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ target_sources(integration_test.logic PRIVATE
Tested.hpp
Tester.cpp
Tester.hpp
Uart.cpp
Uart.hpp
)

target_link_libraries(integration_test.logic PUBLIC
Expand Down
26 changes: 17 additions & 9 deletions integration_test/logic/Gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,50 @@ namespace application
in.DisableInterrupt();
}

void GpioBase::SetGpio(bool state, uint32_t pin)
void GpioBase::SetGpio(bool state)
{
out.Set(state);
}

void GpioBase::InChanged()
{
if (!sending)
if (!std::exchange(sending, true))
RequestSend([this]()
{
sending = false;
TestedGpioChanged(in.Get(), 0);
GpioChanged(in.Get());
});

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)
void GpioTester::SetGpio(bool state)
{
GpioBase::SetGpio(state, pin);
GpioBase::SetGpio(state);
MethodDone();
}

void GpioTester::GpioChanged(bool state)
{
TesterGpioChanged(state);
}

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)
void GpioTested::SetGpio(bool state)
{
GpioBase::SetGpio(state, pin);
GpioBase::SetGpio(state);
MethodDone();
}

void GpioTested::GpioChanged(bool state)
{
TestedGpioChanged(state);
}
}
15 changes: 12 additions & 3 deletions integration_test/logic/Gpio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ namespace application
GpioBase(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);
~GpioBase();

void SetGpio(bool state, uint32_t pin);
void SetGpio(bool state);

protected:
virtual void GpioChanged(bool state) = 0;

private:
void InChanged();
Expand All @@ -32,7 +35,10 @@ namespace application
GpioTester(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);

// Implementation of GpioTester
void SetGpio(bool state, uint32_t pin) override;
void SetGpio(bool state) override;

protected:
virtual void GpioChanged(bool state) override;
};

class GpioTested
Expand All @@ -43,7 +49,10 @@ namespace application
GpioTested(services::Echo& echo, hal::GpioPin& inPin, hal::GpioPin& outPin);

// Implementation of GpioTested
void SetGpio(bool state, uint32_t pin) override;
void SetGpio(bool state) override;

protected:
virtual void GpioChanged(bool state) override;
};
}

Expand Down
5 changes: 5 additions & 0 deletions integration_test/logic/Peripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ namespace application
return false;
});
}

void Peripherals::Reset()
{
currentPeripheral = nullptr;
}
}
21 changes: 11 additions & 10 deletions integration_test/logic/Peripheral.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,38 @@ namespace application
virtual services::Echo& GetEcho() const = 0;

void EnablePeripheral(testing::Peripheral type);
void Reset();

private:
infra::SharedPtr<void> currentPeripheral;
};

template<class Constructed>
class Perpipheral
template<class Constructed, class... Args>
class Peripheral
: public PeripheralBase
{
public:
Perpipheral(Peripherals& subject, testing::Peripheral type);
Peripheral(Peripherals& subject, testing::Peripheral type, Args&&... args);

infra::SharedPtr<void> Construct() override;

private:
services::Echo& echo;
std::tuple<services::Echo&, Args...> args;
infra::SharedOptional<Constructed> constructed;
};

//// Implementation ////

template<class Constructed>
Perpipheral<Constructed>::Perpipheral(Peripherals& subject, testing::Peripheral type)
template<class Constructed, class... Args>
Peripheral<Constructed, Args...>::Peripheral(Peripherals& subject, testing::Peripheral type, Args&&... args)
: PeripheralBase(subject, type)
, echo(subject.GetEcho())
, args(subject.GetEcho(), std::forward<Args>(args)...)
{}

template<class Constructed>
infra::SharedPtr<void> Perpipheral<Constructed>::Construct()
template<class Constructed, class... Args>
infra::SharedPtr<void> Peripheral<Constructed, Args...>::Construct()
{
return constructed.Emplace(echo);
return std::apply(&infra::SharedOptional<Constructed>::template Emplace<services::Echo&, Args...>, std::tuple_cat(std::tuple<infra::SharedOptional<Constructed>&>(constructed), args));
}
}

Expand Down
10 changes: 10 additions & 0 deletions integration_test/logic/Tested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ namespace application
{
Tested::Tested(services::Echo& echo)
: testing::Tested(echo)
, testedObserver(echo)
{}

void Tested::Ping()
{
testedObserver.RequestSend([this]()
{
testedObserver.Pong();
MethodDone();
});
}

void Tested::EnablePeripheral(testing::Peripheral type)
{
Peripherals::EnablePeripheral(type);
Expand Down
25 changes: 25 additions & 0 deletions integration_test/logic/Tested.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,35 @@ namespace application
Tested(services::Echo& echo);

// Implementation of Tested
void Ping() override;
void EnablePeripheral(testing::Peripheral type) override;

// Implementation of Peripherals
services::Echo& GetEcho() const override;

private:
testing::TestedObserverProxy testedObserver;
};

class TestedObserver
: public testing::TestedObserver
{
public:
using testing::TestedObserver::TestedObserver;

void Pong() override
{
pongReceived = true;
MethodDone();
}

bool ReceivedPong()
{
return std::exchange(pongReceived, false);
}

private:
bool pongReceived = false;
};
}

Expand Down
8 changes: 6 additions & 2 deletions integration_test/logic/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

namespace application
{
Tester::Tester(services::Echo& echo, hal::GpioPin& resetTesterPin)
Tester::Tester(services::Echo& echo, hal::GpioPin& resetTesterPin, services::EchoOnSesame& echoToTested)
: testing::Tester(echo)
, echoToTested(echoToTested)
, resetTester(resetTesterPin, true)
{}

void Tester::Reset()
{
resetTester.Set(false);

resetTimer.Start(std::chrono::milliseconds(3000), [this]()
Peripherals::Reset();
echoToTested.Reset();

resetTimer.Start(std::chrono::milliseconds(10), [this]()
{
resetTester.Set(true);
MethodDone();
Expand Down
6 changes: 3 additions & 3 deletions integration_test/logic/Tester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "hal/interfaces/Gpio.hpp"
#include "infra/timer/Timer.hpp"
#include "integration_test/logic/Peripheral.hpp"
#include "services/util/EchoOnSesame.hpp"

namespace application
{
Expand All @@ -13,7 +14,7 @@ namespace application
, public Peripherals
{
public:
Tester(services::Echo& echo, hal::GpioPin& resetTesterPin);
Tester(services::Echo& echo, hal::GpioPin& resetTesterPin, services::EchoOnSesame& echoToTested);

// Implementation of Tester
void Reset() override;
Expand All @@ -23,10 +24,9 @@ namespace application
services::Echo& GetEcho() const override;

private:
services::EchoOnSesame& echoToTested;
hal::OutputPin resetTester;
infra::TimerSingleShot resetTimer;

infra::SharedPtr<void> currentPeripheral;
};
}

Expand Down
Loading

0 comments on commit d416157

Please sign in to comment.