Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add integration_test.flash_tested #293

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
5ef4bc6
Add cucumber submodule
richardapeters Nov 23, 2023
e018d20
Add integration_test/test
richardapeters Nov 23, 2023
2fa388f
.github/workflows/ci.yml: Checkout submodules
richardapeters Nov 23, 2023
703758a
Update amp-embedded-infra-lib
richardapeters Nov 23, 2023
6b56845
Update amp-embedded-infra-lib: fix: infra/util/Endian: fix comparison…
richardapeters Nov 23, 2023
710f06f
Update amp-cucumber-cpp-runner-poc
richardapeters Nov 23, 2023
7612ec6
.github/workflows/ci.yml: Remove Visual Studio 2019 and gcc 7 from te…
richardapeters Nov 25, 2023
e7b437f
Do some work on integration tests
richardapeters Nov 27, 2023
1e23606
Various fixes
richardapeters Nov 30, 2023
84fe55d
Fix compilation
richardapeters Dec 2, 2023
b2135d9
Run clang-format
richardapeters Dec 2, 2023
077fc22
Update .github/workflows/ci.yml
richardapeters Dec 2, 2023
15f7ce5
Merge branch 'feature/cucumber' of https://github.com/philips-softwar…
richardapeters Dec 2, 2023
0f5f86a
Update devcontainer
richardapeters Dec 2, 2023
89999ff
Exclude gherkin libraries from all target
richardapeters Dec 3, 2023
7f54233
feat!: update MessageCommunication to Sesame
richardapeters Dec 28, 2023
c01cab9
Merge branch 'main' into feature/cucumber
richardapeters Dec 31, 2023
99e0cc0
Merge remote-tracking branch 'origin/feature/sesame' into feature/cuc…
richardapeters Dec 31, 2023
40140fd
integration_test/test/FixtureEcho: Adapt for Sesame
richardapeters Dec 31, 2023
7947ed4
CMakeLists: Don't set EXCLUDE_FROM_ALL on gherkin targets because oth…
richardapeters Dec 31, 2023
e592f22
integration_test/logic/Gpio: Differentiate between GpioTester and Gpi…
richardapeters Dec 31, 2023
9bc2e4a
integration_test/tested,tester/Main: Add tracing infrastructure
richardapeters Dec 31, 2023
3956d8f
chore: add integration test board pcb
richardapeters Nov 23, 2023
a56f450
integration_test/logic/Gpio: Fix order of RequestSend and setting sen…
richardapeters Jan 1, 2024
83f2daf
integration_test: Use UartStmDuplexDma
richardapeters Jan 1, 2024
e85a88e
CMakeLists: Update amp-embedded-infralib
richardapeters Jan 4, 2024
6cb70d8
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 4, 2024
22454a0
integration_test/{tester,tested}/Main: Add missing include
richardapeters Jan 4, 2024
27f2f90
integration_test/{tester,tested}: Add tracing on ECHO calls
richardapeters Jan 4, 2024
7ad0b79
integration_test/test: Update and fix
richardapeters Jan 4, 2024
066dd9e
Update amp-cucumber-cpp-runner-poc
richardapeters Jan 4, 2024
3382c9c
Merge commit '066dd9e0f1dbbe479401e93164eeef4526bcb7a2' into feature/…
richardapeters Jan 4, 2024
5656774
Update amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
a7f79e0
Change amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
bb582c5
Update amp-cucumber-cpp-runner
richardapeters Jan 4, 2024
2b3b436
CMakeLists: Rename amp-cucumber-cpp-runner-poc to amp-cucumber-cpp-ru…
richardapeters Jan 4, 2024
0a39688
launch.json: Set gdbPath to gdb-multiarch
richardapeters Jan 4, 2024
3fb6d1f
Apply clang-format
richardapeters Jan 4, 2024
3bb9c93
Update amp-embedded-infralib, reset colour in GlobalTracer
richardapeters Jan 6, 2024
aed23bb
integration_test: Reset tested before starting a scenario
richardapeters Jan 11, 2024
4271b6c
Update amp-cucumber-cpp-runner
richardapeters Jan 11, 2024
f136c67
integration_test/test: Run tests and EventDispatcher from single thread
richardapeters Jan 13, 2024
d98af9e
Remove integration_test/test/FixtureSystemChanges
richardapeters Jan 13, 2024
85e3bbe
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 13, 2024
b36226b
Move EventDispatcherThreadAware to amp-embedded-infra-lib
richardapeters Jan 13, 2024
3df6094
integration_test: Add UART test
richardapeters Jan 15, 2024
9dfd095
integration_test/test/Hooks: Get serial port to use from command line…
richardapeters Jan 17, 2024
cf63ce4
integration_test/test/FixtureEcho: Support Unix serial ports
richardapeters Jan 17, 2024
81c9305
Extract FixtureEchoSerial from FixtureEcho
richardapeters Jan 17, 2024
8ab6b56
integration_test/test/FixtureEcho: Refactor FixtureEchoSerial
richardapeters Jan 18, 2024
6913ee3
integration_test/test/FixtureEcho: Add EchoClientWebSocket
richardapeters Jan 20, 2024
4882511
Add integration_test/test/features/uart_duplex_dma.feature
richardapeters Jan 20, 2024
a225a91
Update amp-cucumber-cpp-runner
richardapeters Jan 20, 2024
b5f9440
Rename integration_test.test to integration_test.runner
richardapeters Jan 20, 2024
3aa8977
integration_test/tested: Add main for stm32wb55
richardapeters Jan 26, 2024
8cd8116
Merge remote-tracking branch 'origin/main' into feature/cucumber
richardapeters Jan 30, 2024
5594a45
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Feb 1, 2024
5b6746a
integration_test/runner/FixtureEcho: Add EchoClientTcp
richardapeters Feb 3, 2024
83785ec
Merge branch 'main' into feature/cucumber
richardapeters Feb 24, 2024
e035480
integration_test: Adjust for DMA refactoring
richardapeters Jan 30, 2024
700e942
.github/workflows/ci.yml: fix merge mistake
richardapeters Feb 24, 2024
d5bb1ec
CMakeLists: Only build integration_test when building amp-hal-st stan…
richardapeters Feb 29, 2024
fc8269e
Merge branch 'main' into feature/cucumber
rjaegers Feb 29, 2024
dcef943
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Mar 28, 2024
75efdbf
test: add integration_test.flash_tested
richardapeters Apr 11, 2024
6a3fdf3
integration_test/flash_tested/Flash: Reduce lambda context size
richardapeters Apr 12, 2024
bb4dab5
Enable running tests on GitHub
richardapeters Apr 12, 2024
5f7bfed
Update amp-embedded-infra-lib
richardapeters Jun 6, 2024
0b64f2c
integration_test/logic/Tester: Add Ping
richardapeters Jun 6, 2024
cec2d01
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Jun 6, 2024
b78e83f
Merge remote-tracking branch 'origin/main' into feature/sesame
richardapeters Jun 6, 2024
eb47856
Merge branch 'feature/sesame' into feature/flash-tested
richardapeters Jun 6, 2024
9517edb
Merge remote-tracking branch 'origin/feature/cucumber' into feature/f…
richardapeters Jun 6, 2024
c624001
Fix merge conflict
richardapeters Jun 6, 2024
6fc47e1
Process review comments
richardapeters Jun 6, 2024
863496d
Update amp-embedded-infra-lib
richardapeters Jun 6, 2024
6e9fdf7
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
fe8d4f2
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
fdc7248
Update amp-cucumber-cpp-runner
richardapeters Jun 6, 2024
2fbc9c3
Merge branch 'main' into feature/flash-tested
richardapeters Jun 7, 2024
a3ac27b
Move Flash into integration_test/logic
richardapeters Jul 4, 2024
965e886
Update amp-cucumber-cpp-runner
richardapeters Jul 4, 2024
4f0c605
Use EXPECT_TRUE around infra::WaitUntilDone and infra::WaitFor
richardapeters Jul 4, 2024
4c0a86a
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Jul 4, 2024
c39bbbd
Disable compilation for stm32wb because it doesn't have Port::F
richardapeters Jul 5, 2024
7d561fe
Update amp-cucumber-cpp-runner
richardapeters Jul 5, 2024
de793a2
Update .github/workflows/ci.yml
richardapeters Jul 5, 2024
33eece1
Temporarily add amp-embedded-infra-lib as submodule
richardapeters Jul 18, 2024
2d3e5af
Add integration_test/flasher
richardapeters Jul 22, 2024
870e000
Use submodule amp-embedded-infra-lib
richardapeters Jul 25, 2024
5d1fd13
Merge remote-tracking branch 'origin/main' into feature/flash-tested
richardapeters Sep 11, 2024
e8fe18d
Fix merge mistakes
richardapeters Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
persist-credentials: false
submodules: true
token: ${{ secrets.AMP_ACCESS_TOKEN }}
- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13
with:
key: ${{ github.job }}-ubuntu-latest
Expand All @@ -27,29 +29,31 @@ jobs:
with:
configurePreset: "host"
buildPreset: "host-Debug-WithPackage"
#testPreset: "host"
testPreset: "host"
configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']"
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: hal_st
path: build/host/hal_st-*-Linux.tar.gz
if-no-files-found: error
#- name: Upload test logs
# if: ${{ failure() }}
# uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# with:
# name: test-logs
# path: build/host/Testing/Temporary/
- name: Upload test logs
if: ${{ failure() }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: test-logs
path: build/host/Testing/Temporary/
host_build_test:
name: Host Build & Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, windows-2019, macos-latest]
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
persist-credentials: false
submodules: true
token: ${{ secrets.AMP_ACCESS_TOKEN }}
- uses: hendrikmuhs/ccache-action@c92f40bee50034e84c763e33b317c77adaa81c92 # v1.2.13
with:
key: ${{ github.job }}-${{ matrix.os }}
Expand All @@ -58,27 +62,24 @@ jobs:
with:
configurePreset: "host-single-Debug"
buildPreset: "host-single-Debug"
#testPreset: "host-single-Debug"
testPreset: "host-single-Debug"
configurePresetAdditionalArgs: "['-DCMAKE_C_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache']"
#- name: Upload test logs
# if: ${{ failure() }}
# uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
# with:
# name: test-logs
# path: build/host/Testing/Temporary/
- name: Upload test logs
if: ${{ failure() }}
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: test-logs
path: build/host/Testing/Temporary/
embedded_build:
name: Embedded Build
runs-on: ubuntu-latest
needs: [host_build_test_ubuntu]
strategy:
matrix:
configuration: ["RelWithDebInfo"]
gcc: [ "10.3-2021.10" ]
gcc: ["10.3-2021.10"]
target: ["stm32wb55", "stm32g070", "stm32g431", "stm32f407", "stm32f429", "stm32f746", "stm32f767", "stm32wba52"]
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
include:
- gcc: "7-2018-q2"
configuration: "RelWithDebInfo"
target: "stm32f767"
- gcc: "8-2019-q3"
configuration: "RelWithDebInfo"
target: "stm32f767"
Expand All @@ -87,6 +88,10 @@ jobs:
target: "stm32f767"
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
persist-credentials: false
submodules: true
token: ${{ secrets.AMP_ACCESS_TOKEN }}
- name: Install GNU Arm Embedded Toolchain ${{ matrix.gcc }}
uses: carlosperate/arm-none-eabi-gcc-action@b864ac853a2d2f74ec2b8b3ec4deb9cb684b4627 # v1.8.2
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "amp-cucumber-cpp-runner"]
path = amp-cucumber-cpp-runner
url = https://github.com/philips-software/amp-cucumber-cpp-runner.git
26 changes: 23 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()

option(CMAKE_COMPILE_WARNING_AS_ERROR "Enable warnings-as-error" ON)
option(HALST_BUILD_TESTS "Enable building the tests" Off)
option(HALST_INCLUDE_DEFAULT_INIT "Include default initialization code; turn off when providing custom initialization" ON)
option(HALST_BUILD_TESTS "Enable building the tests" Off)

option(HALST_BUILD_EXAMPLES "Enable build of the examples" OFF)
option(HALST_BUILD_EXAMPLES_FREERTOS "Enable build of the FreeRTOS example" OFF)
set(HALST_XML_GPIO "" CACHE STRING "XML GPIO table")
set(HALST_XML_STM32 "" CACHE STRING "XML STM32 table")

if (HALST_BUILD_TESTS)
richardapeters marked this conversation as resolved.
Show resolved Hide resolved
# CTest cannot be included before the first project() statement, but amp-embedded-infa-lib
# needs to see that test utilities need to be built.
set(BUILD_TESTING On)
endif()

if (HALST_STANDALONE)
set(EMIL_INCLUDE_FREERTOS ${HALST_BUILD_EXAMPLES_FREERTOS})

Expand All @@ -19,15 +28,15 @@ if (HALST_STANDALONE)
FetchContent_Declare(
emil
GIT_REPOSITORY https://github.com/philips-software/amp-embedded-infra-lib.git
GIT_TAG eeefdbabb671c1bed0142b06ffe25546d702c7d0 # unreleased
GIT_TAG 1ac66fc6aca64fb750b7133766c53d4d67b01be1 # sesame
)

FetchContent_MakeAvailable(emil)
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 +49,21 @@ else()
set(HALST_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL")
endif()

if (HALST_BUILD_TESTS)
include(CTest)
emil_enable_testing()
endif()

if (EMIL_HOST_BUILD)
add_subdirectory(amp-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
9 changes: 6 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"inherits": "defaults",
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "Debug;Release;RelWithDebInfo;MinSizeRel",
"EMIL_BUILD_ECHO_COMPILERS": true
"EMIL_BUILD_ECHO_COMPILERS": true,
"HALST_BUILD_TESTS": true
},
"generator": "Ninja Multi-Config"
},
Expand All @@ -26,15 +27,17 @@
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, Debug",
"inherits": "defaults",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
"CMAKE_BUILD_TYPE": "Debug",
"HALST_BUILD_TESTS": true
}
},
{
"name": "host-single-MinSizeRel",
"displayName": "Configuration for Host Tooling and Tests, Single Config Generator, MinSizeRel",
"inherits": "defaults",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
"CMAKE_BUILD_TYPE": "MinSizeRel",
"HALST_BUILD_TESTS": true
}
},
{
Expand Down
1 change: 1 addition & 0 deletions amp-cucumber-cpp-runner
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
2 changes: 2 additions & 0 deletions integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_subdirectory(logic)
add_subdirectory(flash_tested)
add_subdirectory(tested)
add_subdirectory(tester)
add_subdirectory(runner)
19 changes: 19 additions & 0 deletions integration_test/flash_tested/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_library(integration_test.flash_tested ${HALST_EXCLUDE_FROM_ALL})

target_include_directories(integration_test.flash_tested PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/../..>"
)

protocol_buffer_echo_cpp(integration_test.flash_tested Flash.proto)

target_sources(integration_test.flash_tested PRIVATE
Flash.cpp
Flash.hpp
)

target_link_libraries(integration_test.flash_tested PUBLIC
services.util
protobuf.echo
)

add_subdirectory(test)
149 changes: 149 additions & 0 deletions integration_test/flash_tested/Flash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#include "integration_test/flash_tested/Flash.hpp"
#include <utility>

namespace application
{
Flash::Flash(services::Echo& echo, hal::Flash& flash)
: flash::Flash(echo)
, flashResult(echo)
, flash(flash)
{}

void Flash::Read(uint32_t address, uint32_t size)
{
flash.ReadBuffer(infra::Head(infra::MakeRange(buffer), size), address, [this, size]()
{
flashResult.RequestSend([this, size]()
{
flashResult.ReadDone(infra::Head(infra::MakeRange(buffer), size));
MethodDone();
});
});
}

void Flash::Write(uint32_t address, infra::ConstByteRange contents)
{
flash.WriteBuffer(contents, address, [this]()
{
flashResult.RequestSend([this]()
{
flashResult.WriteDone();
MethodDone();
});
});
}

void Flash::EraseSectors(uint32_t sector, uint32_t numberOfSectors)
{
flash.EraseSectors(sector, sector + numberOfSectors, [this]()
{
flashResult.RequestSend([this]()
{
flashResult.EraseSectorsDone();
MethodDone();
});
});
}

FlashProxy::FlashProxy(services::Echo& echo)
: flash::FlashResult(echo)
, proxy(echo)
{}

void FlashProxy::WriteBuffer(infra::ConstByteRange buffer, uint32_t address, infra::Function<void()> onDone)
{
writingBuffer = buffer;
this->onDone = onDone;

if (!writingBuffer.empty())
proxy.RequestSend([this, address]()
{
++transferBuffers;
auto size = std::min(writingBuffer.size(), std::tuple_size<std::remove_reference_t<decltype(std::declval<flash::WriteRequest>().contents.Storage())>>::value);
proxy.Write(address, infra::Head(writingBuffer, size));
WriteBuffer(infra::DiscardHead(writingBuffer, size), address + size, this->onDone.Clone());
});
}

void FlashProxy::ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function<void()> onDone)
{
readingBuffer = buffer;
this->onDone = onDone;

ReadPartialBuffer(address, 0);
}

void FlashProxy::EraseSectors(uint32_t beginIndex, uint32_t endIndex, infra::Function<void()> onDone)
{
this->onDone = onDone;
this->endIndex = endIndex;

proxy.RequestSend([this, beginIndex]()
{
proxy.EraseSectors(beginIndex, this->endIndex - beginIndex);
});
}

void FlashProxy::ReadDone(infra::ConstByteRange contents)
{
infra::Copy(contents, infra::Head(readingBuffer, contents.size()));
readingBuffer = infra::DiscardHead(readingBuffer, contents.size());

--transferBuffers;
if (transferBuffers == 0 && readingBuffer.empty())
onDone();
}

void FlashProxy::WriteDone()
{
--transferBuffers;
if (transferBuffers == 0 && writingBuffer.empty())
onDone();
}

void FlashProxy::EraseSectorsDone()
{
onDone();
}

void FlashProxy::ReadPartialBuffer(uint32_t address, uint32_t start)
{
if (readingBuffer.size() - start > 0)
{
this->start = start;
proxy.RequestSend([this, address]()
{
++transferBuffers;
auto size = std::min<uint32_t>(readingBuffer.size() - this->start, std::tuple_size<std::remove_reference_t<decltype(std::declval<flash::WriteRequest>().contents.Storage())>>::value);
proxy.Read(address + this->start, size);
ReadPartialBuffer(address, this->start + size);
});
}
}

FlashHomogeneousProxy::FlashHomogeneousProxy(services::Echo& echo, uint32_t numberOfSectors, uint32_t sizeOfEachSector)
: FlashProxy(echo)
, numberOfSectors(numberOfSectors)
, sizeOfEachSector(sizeOfEachSector)
{}

uint32_t FlashHomogeneousProxy::NumberOfSectors() const
{
return numberOfSectors;
}

uint32_t FlashHomogeneousProxy::SizeOfSector(uint32_t sectorIndex) const
{
return sizeOfEachSector;
}

uint32_t FlashHomogeneousProxy::SectorOfAddress(uint32_t address) const
{
return address / sizeOfEachSector;
}

uint32_t FlashHomogeneousProxy::AddressOfSector(uint32_t sectorIndex) const
{
return sectorIndex * sizeOfEachSector;
}
}
Loading
Loading