diff --git a/Sts1CobcSw/Periphery/FramMock.cpp b/Sts1CobcSw/Periphery/FramMock.cpp index 2ac7f549..142ac8a6 100644 --- a/Sts1CobcSw/Periphery/FramMock.cpp +++ b/Sts1CobcSw/Periphery/FramMock.cpp @@ -8,72 +8,84 @@ namespace sts1cobcsw::fram { - constexpr auto framSize = (1U << 20U); auto ramSimulation = std::array{}; MockMode mockDevice = MockMode::ram; constexpr auto mockFilename = "FramMock.bin"; -auto FramMockMode(MockMode mockMode) -> void -{ - mockDevice = mockMode; -} +auto doInitialize = DoInitializeDefault; +auto doReadDeviceId = DoReadDeviceIdDefault; +auto doActualBaudRate = DoActualBaudRateDefault; -// Default do functions, doing nothing -auto DoInitializeDefault() -> void + +// --- Mocked functions --- + +auto Initialize() -> void { + return doInitialize(); } -auto DoReadDeviceIdDefault() -> DeviceId + +auto ReadDeviceId() -> DeviceId { - return DeviceId{}; + return doReadDeviceId(); } -auto DoActualBaudRateDefault() -> int32_t + +auto ActualBaudRate() -> int32_t { - return 0; + return doActualBaudRate(); } -auto doInitialize = DoInitializeDefault; -auto doReadDeviceId = DoReadDeviceIdDefault; -auto doActualBaudRate = DoActualBaudRateDefault; - +// --- Set functions --- auto SetDoInitialize(void (*doInitializeFunction)()) -> void { doInitialize = doInitializeFunction; } + auto SetDoReadDeviceId(DeviceId (*doReadDeviceIdFunction)()) -> void { doReadDeviceId = doReadDeviceIdFunction; } + void SetDoActualBaudRate(int32_t (*doActualBaudRateFunction)()) { doActualBaudRate = doActualBaudRateFunction; } -auto Initialize() -> void +// --- Default do functions, doing nothing --- + +auto DoInitializeDefault() -> void { - return doInitialize(); } -auto ReadDeviceId() -> DeviceId + +auto DoReadDeviceIdDefault() -> DeviceId { - return doReadDeviceId(); + return DeviceId{}; } -auto ActualBaudRate() -> int32_t + +auto DoActualBaudRateDefault() -> int32_t { - return doActualBaudRate(); + return 0; +} + + +auto FramMockMode(MockMode mockMode) -> void +{ + mockDevice = mockMode; } namespace internal { +// TODO: This must also forward to a do function which can be set with a SetDoWriteTo function auto WriteTo(Address address, void const * data, std::size_t nBytes) -> void { if(mockDevice == MockMode::file) @@ -96,6 +108,8 @@ auto WriteTo(Address address, void const * data, std::size_t nBytes) -> void } } + +// TODO: This must also forward to a do function which can be set with a SetDoReadFrom function auto ReadFrom(Address address, void * data, std::size_t nBytes) -> void { if(mockDevice == MockMode::file) diff --git a/Sts1CobcSw/Periphery/FramMock.hpp b/Sts1CobcSw/Periphery/FramMock.hpp index 349ac7e0..73abbba7 100644 --- a/Sts1CobcSw/Periphery/FramMock.hpp +++ b/Sts1CobcSw/Periphery/FramMock.hpp @@ -8,36 +8,41 @@ namespace sts1cobcsw::fram { +enum class MockMode +{ + ram, + file +}; + + +// TODO: Add SetDoWriteTo and SetDoReadFrom functions auto SetDoInitialize(void (*doInitializeFunction)()) -> void; auto SetDoReadDeviceId(DeviceId (*doReadDeviceIdFunction)()) -> void; -auto SetDoActualBaudRate(int32_t (*doActualBaudRateFunction)()) -> void; - +auto SetDoActualBaudRate(std::int32_t (*doActualBaudRateFunction)()) -> void; +// TODO: Move to namespace "default" // Default "do" functions that do nothing, used to initialized function pointers auto DoInitializeDefault() -> void; auto DoReadDeviceIdDefault() -> DeviceId; -auto DoActualBaudRateDefault() -> int32_t; - - -enum class MockMode -{ - ram, - file -}; +auto DoActualBaudRateDefault() -> std::int32_t; +// TODO: Remove this auto FramMockMode(MockMode mockMode) -> void; +// TODO: Implement ram::do functions namespace ram { auto DoInitialize() -> void; auto DoReadDeviceId() -> DeviceId; -auto DoActualBaudRate() -> int32_t; +auto DoActualBaudRate() -> std::int32_t; } + +// TODO: Since this isn't fully implemented yet, remove it. The RAM mock should be enough. namespace file { auto DoInitialize() -> void; auto DoReadDeviceId() -> DeviceId; -auto DoActualBaudRate() -> int32_t; +auto DoActualBaudRate() -> std::int32_t; } }