-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
341 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "STS1 COBC Full", | ||
"image": "tuwienspaceteam/sts1-cobc:1.6.0" | ||
"image": "tuwienspaceteam/sts1-cobc:1.6.1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ prefix/ | |
CMakeLists.txt.user | ||
CMakeUserPresets.json | ||
compile_commands.json | ||
FramMock.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
#include <Sts1CobcSw/Periphery/FramMock.hpp> | ||
|
||
#include <cstring> | ||
|
||
|
||
namespace sts1cobcsw::fram | ||
{ | ||
auto doInitialize = empty::DoInitialize; | ||
auto doReadDeviceId = empty::DoReadDeviceId; | ||
auto doActualBaudRate = empty::DoActualBaudRate; | ||
auto doWriteTo = empty::DoWriteTo; | ||
auto doReadFrom = empty::DoReadFrom; | ||
|
||
|
||
// --- Mocked functions --- | ||
|
||
auto Initialize() -> void | ||
{ | ||
return doInitialize(); | ||
} | ||
|
||
|
||
auto ReadDeviceId() -> DeviceId | ||
{ | ||
return doReadDeviceId(); | ||
} | ||
|
||
|
||
auto ActualBaudRate() -> std::int32_t | ||
{ | ||
return doActualBaudRate(); | ||
} | ||
|
||
|
||
namespace internal | ||
{ | ||
auto WriteTo(Address address, void const * data, std::size_t nBytes, std::int64_t timeout) -> void | ||
{ | ||
return doWriteTo(address, data, nBytes, timeout); | ||
} | ||
|
||
|
||
auto ReadFrom(Address address, void * data, std::size_t nBytes, std::int64_t timeout) -> void | ||
{ | ||
return doReadFrom(address, data, nBytes, timeout); | ||
} | ||
} | ||
|
||
|
||
// --- Set functions --- | ||
|
||
auto SetDoInitialize(void (*doInitializeFunction)()) -> void | ||
{ | ||
doInitialize = doInitializeFunction; | ||
} | ||
|
||
|
||
auto SetDoReadDeviceId(DeviceId (*doReadDeviceIdFunction)()) -> void | ||
{ | ||
doReadDeviceId = doReadDeviceIdFunction; | ||
} | ||
|
||
|
||
void SetDoActualBaudRate(std::int32_t (*doActualBaudRateFunction)()) | ||
{ | ||
doActualBaudRate = doActualBaudRateFunction; | ||
} | ||
|
||
|
||
auto SetDoWriteTo(void (*doWriteToFunction)( | ||
Address address, void const * data, std::size_t nBytes, std::int64_t timeout)) -> void | ||
{ | ||
doWriteTo = doWriteToFunction; | ||
} | ||
|
||
|
||
auto SetDoReadFrom(void (*doReadFromFunction)( | ||
Address address, void * data, std::size_t nBytes, std::int64_t timeout)) -> void | ||
{ | ||
doReadFrom = doReadFromFunction; | ||
} | ||
|
||
|
||
// --- Predefined do functions --- | ||
|
||
namespace empty | ||
{ | ||
auto SetAllDoFunctions() -> void | ||
{ | ||
SetDoInitialize(DoInitialize); | ||
SetDoReadDeviceId(DoReadDeviceId); | ||
SetDoActualBaudRate(DoActualBaudRate); | ||
SetDoWriteTo(DoWriteTo); | ||
SetDoReadFrom(DoReadFrom); | ||
} | ||
|
||
|
||
auto DoInitialize() -> void | ||
{ | ||
} | ||
|
||
|
||
auto DoReadDeviceId() -> DeviceId | ||
{ | ||
return DeviceId{}; | ||
} | ||
|
||
|
||
auto DoActualBaudRate() -> std::int32_t | ||
{ | ||
return 0; | ||
} | ||
|
||
|
||
auto DoWriteTo([[maybe_unused]] Address address, | ||
[[maybe_unused]] void const * data, | ||
[[maybe_unused]] std::size_t nBytes, | ||
[[maybe_unused]] std::int64_t timeout) -> void | ||
{ | ||
} | ||
|
||
|
||
auto DoReadFrom([[maybe_unused]] Address address, | ||
[[maybe_unused]] void * data, | ||
[[maybe_unused]] std::size_t nBytes, | ||
[[maybe_unused]] std::int64_t timeout) -> void | ||
{ | ||
} | ||
} | ||
|
||
|
||
namespace ram | ||
{ | ||
std::array<Byte, storageSize> storage{}; | ||
|
||
|
||
auto SetAllDoFunctions() -> void | ||
{ | ||
SetDoInitialize(DoInitialize); | ||
SetDoReadDeviceId(DoReadDeviceId); | ||
SetDoActualBaudRate(DoActualBaudRate); | ||
SetDoWriteTo(DoWriteTo); | ||
SetDoReadFrom(DoReadFrom); | ||
} | ||
|
||
|
||
auto DoInitialize() -> void | ||
{ | ||
} | ||
|
||
|
||
auto DoReadDeviceId() -> DeviceId | ||
{ | ||
static constexpr auto deviceId = | ||
std::to_array({0x03_b, 0x2E_b, 0xC2_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b}); | ||
return deviceId; | ||
} | ||
|
||
|
||
auto DoActualBaudRate() -> std::int32_t | ||
{ | ||
return 6'000'000; // NOLINT(*magic-numbers*) | ||
} | ||
|
||
|
||
auto DoWriteTo(Address address, | ||
void const * data, | ||
std::size_t nBytes, | ||
[[maybe_unused]] std::int64_t timeout) -> void | ||
{ | ||
std::memcpy(storage.data() + address, data, nBytes); | ||
} | ||
|
||
|
||
auto DoReadFrom(Address address, | ||
void * data, | ||
std::size_t nBytes, | ||
[[maybe_unused]] std::int64_t timeout) -> void | ||
{ | ||
std::memcpy(data, storage.data() + address, nBytes); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
|
||
#include <Sts1CobcSw/Periphery/Fram.hpp> | ||
#include <Sts1CobcSw/Serial/Byte.hpp> | ||
|
||
#include <array> | ||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
|
||
namespace sts1cobcsw::fram | ||
{ | ||
auto SetDoInitialize(void (*doInitializeFunction)()) -> void; | ||
auto SetDoReadDeviceId(DeviceId (*doReadDeviceIdFunction)()) -> void; | ||
auto SetDoActualBaudRate(std::int32_t (*doActualBaudRateFunction)()) -> void; | ||
auto SetDoWriteTo(void (*doWriteToFunction)( | ||
Address address, void const * data, std::size_t nBytes, std::int64_t timeout)) -> void; | ||
auto SetDoReadFrom(void (*doReadFromFunction)( | ||
Address address, void * data, std::size_t nBytes, std::int64_t timeout)) -> void; | ||
|
||
|
||
// Empty do functions that do nothing; used to initialized function pointers | ||
namespace empty | ||
{ | ||
auto SetAllDoFunctions() -> void; | ||
|
||
auto DoInitialize() -> void; | ||
auto DoReadDeviceId() -> DeviceId; | ||
auto DoActualBaudRate() -> std::int32_t; | ||
auto DoWriteTo(Address address, void const * data, std::size_t nBytes, std::int64_t timeout) | ||
-> void; | ||
auto DoReadFrom(Address address, void * data, std::size_t nBytes, std::int64_t timeout) -> void; | ||
} | ||
|
||
|
||
// Do functions that simulate the FRAM in RAM | ||
namespace ram | ||
{ | ||
constexpr auto storageSize = (1U << 20U); | ||
extern std::array<Byte, storageSize> storage; | ||
|
||
|
||
auto SetAllDoFunctions() -> void; | ||
|
||
auto DoInitialize() -> void; | ||
auto DoReadDeviceId() -> DeviceId; | ||
auto DoActualBaudRate() -> std::int32_t; | ||
auto DoWriteTo(Address address, void const * data, std::size_t nBytes, std::int64_t timeout) | ||
-> void; | ||
auto DoReadFrom(Address address, void * data, std::size_t nBytes, std::int64_t timeout) -> void; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.